I can't get LTW to work in Spring Boot 1.2.2 w/ Embedded Tomcat.
My application is a WAR file, not a .JAR file. When I run in DEBUG, it never stops in my aspect even with hitting calls that should match the pointcuts, so that is how I figure it is not working...
My run script does this:
-javaagent:path/to/spring-instrument-xxx.jar -javaagent:path/to/aspectjweaver-1.2.8.jar
In Spring Boot, I load this AOP Config as an ApplicationInitializer, so it is in a parent ApplicationContext right away and should be there for all the rest of my embedded tomcat web application context thereafter.
@EnableLoadTimeWeaving(aspectjWeaving=AspectJWeaving.ENABLED)
@Configuration
public class AopConfig {
private Log log = LogFactory.getLog(AopConfig.class);
public AopConfig() {
log.info("Creating AopConfig");
}
@Bean
public LoadTimeWeaver loadTimeWeaver() {
log.info("Creating InstrumentationLoadTimeWeaver");
return new InstrumentationLoadTimeWeaver();
}
}
My Aspect looks like this:
package my.aop.profiler.MethodTimerAspect;
@Aspect
public class MethodTimerAspect {
private static final String DELIMITER = "|";
private static final String PROFILER = "profiler";
private static final String DATE_FORMAT = "h:mm:ss";
private static final Log LOG = LogFactory.getLog(PROFILER);
public MethodTimerAspect() {}
@Pointcut("execution (* my.web.*Controller.*(..))")
protected void controllers() {}
@Pointcut("execution (* my.services..*Facade.*(..))")
protected void services() {}
@Pointcut("execution (* my.services..*Exchange.*(..))")
protected void data() {}
/**
* If profiling is enabled with trace, it will log the amount of time
* spent in the method
*
* @param joinPoint
* @return Object
* @throws Throwable
*/
@Around("controllers() || services() || data()")
public Object doProfiling(ProceedingJoinPoint joinPoint) throws Throwable {
// (...)
}
}
My Embedded WAR's META-INF/aop.xml is this:
<!DOCTYPE aspectj PUBLIC "-//AspectJ//DTD//EN" "http://www.eclipse.org/aspectj/dtd/aspectj.dtd">
<aspectj>
<weaver>
<!-- only weave classes in our application-specific packages -->
<include within="cdot.*"/>
</weaver>
<aspects>
<!-- weave in just this aspect -->
<aspect name="my.aop.profiler.MethodTimerAspect"/>
</aspects>
</aspectj>