Brian's Waste of Time

Thu, 13 May 2004

Solved: Advice on Started Threads

Moved the subject into a WeakHashMap keyed to Thread and simply populated it based on the started thread =)

package org.skife.objectfilter;

public aspect AssociateSubjectWithSpawnedThreads
{
    pointcut startThread(Thread thread): target(thread)
                                         && call(void java.lang.Thread.start());

    before(Thread thread) : startThread(thread) {
        Filter.instance().setSubject(thread, Filter.instance().getSubject());
    }
}

Next glaring hole: block ability to change subject except when allowed by a given pointcut. Funny how most of the configuration for this tool is pointcut definition.

My goal for ObjectFilter, btw, is to give someone the ability to execute arbitrary code (Groovy, BeanShell, Jython, etc) in a VM, with access to the sources for whatever is in it, and still be able to prevent any information leakage =)

Pushed newest tarball as well. Lots of minor changes.

0 writebacks [/src/java/aop] permanent link