I'm in a similar situation..
I'm trying @AspectJ with java 5 annot. and
just trying to get it working.
I've added the configs:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">
<aop:aspectj-autoproxy>
<aop:include name="errorLogger" />
</aop:aspectj-autoproxy>
<bean id="errorLogger" class="org.springframework.webflow.samples.util.ErrorLogger" />
</beans>
ErrorLogger has the following
Code:
@Aspect
public class ErrorLogger implements Serializable {
@Pointcut("execution(* org.springframework.webflow.samples.util.SearchCriteria.*(..))")
public void say(){}
@Before("say()")
public void sayHi(){
System.out.println("sayHi()");
}
}
org.springframework.webflow.samples.util.SearchCri teria has method
Code:
public void throwExcept(){
System.out.println("throwExcept()");
try{
//int error = 2/0;
System.out.println("Annie are u OK?");
}
catch(Exception e){
System.out.println("throwExcept()"+e.getMessage());
e.printStackTrace();
//throw new Exception(e);
}
}
to trigger the aspect in the flow...
Code:
<var name="searchCriteria" class="org.springframework.webflow.samples.util.SearchCriteria" />
<on-start>
<evaluate expression="searchCriteria.throwExcept()" />
</on-start>
when this runs I get
Code:
2009-11-28 17:14:38,031 DEBUG [org.springframework.webflow.execution.AnnotatedAction] - <Putting action execution attributes map[[empty]]>
throwExcept()
Annie are u OK?
so the aspect doesn't get triggered.
However if I change the pointcut to..
Code:
@Before("execution(public * *(..))")
the aspect does get triggered and I get "sayHi" everywhere
eventually crashing the API.
So what gives? why doesn't
Code:
@Pointcut("execution(* org.springframework.webflow.samples.util.SearchCriteria.*(..))")
This work? I've tried many variations but no way of selecting my method ( as a test run).
Is Webflow complicating the way Spring AOP normally works?