I'm trying to get my head around the new <aop:...> stuff.
One approach I've done works, and another which I believe should be equivalent does NOT work. Does anyone know what i'm doing wrong? I think i'm missing something fundamental here.
Using Spring 2.0 final.
This works, in that specified method calls have logging information printed before the call.
The above works in that I get the log.debug message printed out when the com.myco.tx.SomeObject.doAnother method is called.Code:(spring config) <aop:aspectj-autoproxy/> <bean id="logger" class="com.myco.tx.SimpleLogger"/> <aop:config> <aop:aspect id="loggingAspect" ref="logger"> <aop:before pointcut="execution(* com.myco.tx.SomeObject.doAnother*(com.myco.tx.MyData)) and args(myData)" method="logMessage" arg-names="myData"/> </aop:aspect> </aop:config> ... (java class) public void logMessage(MyData myData) { log.debug(myData.getStr() + " **********************"); }
Now, if I create a LoggingAspect class (see end of post), and then replace this pointcut expression
with this replacemnt pointcut expression:Code:execution(* com.myco.tx.SomeObject.doAnother*(com.myco.tx.MyData)) and args(myData)
then I get an error at ::0 formal unbound in pointcut startup error.Code:com.myco.tx.LoggingAspect.logged()
Note that the experssion in the @Pointcut annotation above is a copy/paste of the expression in the first <aop:config> based example.Code:@Aspect public class LoggingAspect { private Log log = LogFactory.getLog(LoggingAspect.class); @Pointcut("execution(* com.myco.tx.SomeObject.doAnother*(com.myco.tx.MyData)) and args(myData)") public void logged() { } }
See http://static.springframework.org/sp...rence/aop.html, section 6.2.3.3 Sharing common pointcut definitions.


Reply With Quote