Weaving java.util.concurrent API using AspectJ

I stopped using AspectJ long back because we were not really coding aspects because it required an enormous amount of effort to train others. But recently I wrote this to weave into java.util.concurrent libraries to try to explore how the ForkJoin library works. Even though the code works I thought it is not a recommended way to weave into libraries dealing with concurrency written by experts. I pulled  the source and created a custom JAR and used -Xbootclasspath to make it work.

 

@Aspect
public class ForkJoinProjector {

	
	
    @Pointcut( "execution ( int java.util.concurrent.ForkJoinPool.registerWorker(java.util.concurrent.ForkJoinWorkerThread)) &&" +
			                " args(thread) &&" +
			                " target(pool)" )
    public void buildQueues( ForkJoinWorkerThread thread,
	                     ForkJoinPool pool){}
	
    @After("buildQueues( thread,pool)")
    public void build( ForkJoinWorkerThread thread,
    		           ForkJoinPool pool ) {
    	System.out.println( "ID " + thread.getId() + " Name " + thread.getName() );
    }


}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s

%d bloggers like this: