Note that there are some explanatory texts on larger screens.

plurals
  1. POAspectJ Load-time Weaving in Spring with method-call pointcuts?
    primarykey
    data
    text
    <p>I'm experimenting with AspectJ Load-time Weaving in Spring as described <a href="http://www.springbyexample.org/examples/aspectj-ltw.html" rel="nofollow noreferrer">here</a>. I've checked out the <a href="http://www.springbyexample.org/examples/aspectj-ltw-reference.html" rel="nofollow noreferrer">sample code</a>, and it works as advertised.</p> <p>But when I try to change the pointcut of the <a href="http://svn.springbyexample.org/core/aspectj-load-time-weaving/tags/1.0/src/test/java/org/springbyexample/aspectjLoadTimeWeaving/PerformanceAdvice.java" rel="nofollow noreferrer">PerformanceAdvice</a> from <code>execution(..)</code> to <code>call(..)</code> semantics, the advice no longer gets executed. </p> <p>I know that Spring AOP does not support <code>call(..)</code> semantics, but that should not apply here since I'm using AspectJ LTW (the sample code successfully works with non-Spring-managed objects).</p> <p>Can anyone shed some light?</p> <p><strong>Update:</strong> In order to confirm that LTW works, I added the following system properties to the argline configuration in pom.xml:</p> <ul> <li><code>-Dorg.aspectj.weaver.showWeaveInfo=true</code></li> <li><code>-Daj.weaving.verbose=true</code></li> <li><code>-Dorg.aspectj.tracing.enabled=true</code></li> <li><code>-Dorg.aspectj.tracing.factory=default</code> </li> <li><code>-Dorg.aspectj.tracing.file=/tmp/aspectj-trace.txt</code></li> </ul> <p>Now the output of running <code>mvn test</code> contains the following lines: <code><pre>[AppClassLoader] info AspectJ Weaver Version 1.5.3 built on Wednesday Nov 22, 2006 at 11:18:15 GMT [AppClassLoader] info register classloader sun.misc.Launcher$AppClassLoader@5acac268 [AppClassLoader] info using configuration /private/tmp/aspectj-load-time-weaving/target/test-classes/META-INF/aop.xml [AppClassLoader] info register aspect org.springbyexample.aspectjLoadTimeWeaving.PerformanceAdvice [AppClassLoader] weaveinfo Join point 'method-execution(void org.springbyexample.aspectjLoadTimeWeaving.Processor.process())' in Type 'org.springbyexample.aspectjLoadTimeWeaving.Processor' (Processor.java:38) advised by around advice from 'org.springbyexample.aspectjLoadTimeWeaving.PerformanceAdvice' (PerformanceAdvice.java) [AppClassLoader] weaveinfo Join point 'method-execution(void org.springbyexample.aspectjLoadTimeWeaving. PerformanceAdvice.aspectjLoadTimeWeavingExamples())' in Type 'org.springbyexample.aspectjLoadTimeWeaving.PerformanceAdvice' (PerformanceAdvice.java:37) advised by around advice from 'org.springbyexample.aspectjLoadTimeWeaving.PerformanceAdvice' (PerformanceAdvice.java) </pre></code></p> <p>So it seems that AspectJ has picked up the PerformanceAdvice and found 2 join points to weave it in. But if I replace <code>execution(..)</code> with <code>call(..)</code> in the PerformanceAdvice's join point and run maven again, the output does not contain those last 2 lines, and the advice is not executed. The AspectJ trace contains lots of log statements, but I couldn't make much sense out of it. I scanned it for errors or warnings, but found none.</p> <p>(I assume that I should be able to simply replace <code>execution(..)</code> with <code>call(..)</code>, because their syntax is described as <code>execution(MethodPattern)</code> and <code>call(MethodPattern)</code> respectively in the <a href="http://www.eclipse.org/aspectj/doc/next/progguide/semantics-pointcuts.html" rel="nofollow noreferrer">AspectJ programming guide</a>).</p> <p>I also tried using a more recent version of AspectJ (1.6.6), but to no avail.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload