Note that there are some explanatory texts on larger screens.

plurals
  1. POSpring AOP misses something
    primarykey
    data
    text
    <p>I'm just playing with AspectJ (1.6) with Spring (2.5), but it seems not to work in the proper way. I set up my "beans.xml" using:</p> <pre><code>&lt;aop:aspectj-autoproxy/&gt; &lt;bean id="testBean1" class="apackage.MyClass"&gt; &lt;bean id="aopBean1" class="apackage.AfterReturningExample"/&gt; </code></pre> <p>with the correct namespaces set and some other beans with no importance. I use a simple bean to test advices:</p> <pre><code>package apackage; @Aspect public class MyClass { public MyClass() { } public Boolean testAspectJ() { System.out.println("returning from MyClass.testAspectJ()"); return false; } } </code></pre> <p>And this is the aop bean:</p> <pre><code>package apackage; @Aspect public class AfterReturningExample { public AfterReturningExample(){} @AfterReturning("execution(* apackage.MyClass.*(..))") public void test() throws Exception{ System.err.println("\n\n#### After Returning MyClass.testAspectJ()\n\n"); } } </code></pre> <p>And finally this is the testing code (in a main method):</p> <pre><code>ApplicationContext ctx = new ClassPathXmlApplicationContext("apackage/beans.xml"); MyClass bean = (MyClass) ctx.getBean("testBean1"); bean.testAspectJ(); </code></pre> <p>The output prints only:</p> <pre><code>returning from MyClass.testAspectJ() </code></pre> <p>The strange thing is that if I use for the pointcut:</p> <pre><code>"execution(public * *(..))" </code></pre> <p>the log shows the System.out.println of the AfterReturningExample class. What am I missing?</p>
    singulars
    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