Hello,
I am going nuts: I am new and just want to implement a simple profiler within my app that is basically based on that from the Spring docs.
First:
- I use Java 1.5
- Spring is 2 RC3
- I regard pointcuts as part of my config, so they reside within my XML file
- all my implementations are based on interfaces
- features of AspectJ not required
So, I just want all methods of my implementations to cause invokation of a profiler method. My config looks like this:
This is the SimpleProfiler implementation: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.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd"> <bean id="profiler" class="my.package.SimpleProfiler" /> <aop:config> <aop:aspect id="profiling" ref="profiler"> <aop:around pointcut="execution(* my.package.*.*(..))" method="profile" /> </aop:aspect> </aop:config> [...] </beans>
As said, straight from the Spring docs. However, whatever pointcuts I try, nothing happens, although I invoke methods from my implementations - all created by the Spring container. Additionally, the AOP config is parsed; so if I do errors in aop: elements or their attribute names, I get an exception.Code:package my.package; import org.aspectj.lang.ProceedingJoinPoint; import org.springframework.util.StopWatch; public class SimpleProfiler { public Object profile(ProceedingJoinPoint call) throws Throwable { System.out.println("Profiler"); StopWatch clock = new StopWatch( "Profiling..."); try { clock.start(call.toShortString()); return call.proceed(); } finally { clock.stop(); System.out.println(clock.prettyPrint()); } } }
Do I have to activate AOP somewhere? I have read the docs and forums quite some times but fail to get a solution. Also, as you see my pointcut is quite general - do I have to name interfaces there? Although I have interfaces, I do not know if this bytecode modification stuff applies here...
Thanks and regards,
Timo
P.S.: this is no web-app but a simple standalone app launched from a shell


Reply With Quote