Practical AOP woes – Part I

I have spent quite a long time trying to configure WebSphere Portal to use AOP Load-Time Weaving.

I started with Ron Bodkin’s WebSphere ClassLoader Plugin idea but that did not work due to a bug. According to Ron the context ClassLoader is set to the bootstrap loader instead of the application’s loader.

Now I am trying to use AspectWerkz to do that same thing. On the one hand I am excited about AOP but on the other it is very difficult for ordinary people to implement practical usecases using servers like WebSphere etc.

My firm recently showed some interest in weaving logger statements into the application code.

This aspect allows us to print the value added to a list inside a method. So in this case it should print Test1. So if we want to log the value it is possible.

package com.test.aspect;
import java.util.ArrayList;
import java.util.List;
public class TestClass {
public void test(){
List list = new ArrayList();
list.add( new String( "Test1" ) );
* @param args
public static void main(String[] args) {
TestClass t = new TestClass();

Here is the aspect

package com.aspect;
public aspect TestAspect {
pointcut test() : execution( * com.test.aspect.TestClass.test(..) );

before() : test(){
System.out.println( "Test" );
after() : cflow( test() ) && call( * java.util.List.add(..) ){
System.out.println( thisJoinPoint.getArgs()[ 0 ] );

Leave a Reply

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

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

Facebook photo

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

Connecting to %s

%d bloggers like this: