Hi all! I'm just playing with AspectJ (1.6) with Spring (2.5), but it seems not to work in the proper way. I set up my "beans.xml" using:
<aop:aspectj-autoproxy/>
<bean id="testBean1" class="apackage.MyClass">
<bean id="aopBean1" class="apackage.AfterReturningExample"/>
with the correct namespaces set and some other beans with no importance. I use a simple bean to test advices:
package apackage;
@Aspect
public class MyClass {
public MyClass()
{
}
public Boolean testAspectJ()
{
System.out.println("returning from MyClass.testAspectJ()");
return false;
}
}
And this is the aop bean:
package apackage;
@Aspect
public class AfterReturningExample {
public AfterReturningExample(){}
@AfterReturning("execution(* apackage.MyClass.*(..))")
public void test() throws Exception{
System.err.println("\n\n#### After Returning MyClass.testAspectJ()\n\n");
}
}
And finally this is the testing code (in a main method):
ApplicationContext ctx = new ClassPathXmlApplicationContext("apackage/beans.xml");
MyClass bean = (MyClass) ctx.getBean("testBean1");
bean.testAspectJ();
The output prints only:
returning from MyClass.testAspectJ()
The strange thing is that if I use for the pointcut:
"execution(public * *(..))"
the log shows the System.out.println of the AfterReturningExample class. What am I missing?