Note that there are some explanatory texts on larger screens.

plurals
  1. POwhy is this Spring AOP pointcut not triggered?
    text
    copied!<p>I'm writing very basic schema-based Spring AOP, here's the .xml</p> <pre class="lang-xml prettyprint-override"><code>&lt;bean id="aoplistener" class="tao.zhang.Listener"/&gt; &lt;aop:config&gt; &lt;aop:aspect ref="aoplistener"&gt; &lt;aop:pointcut id="whenCalled" expression="execution(* callme(..))" /&gt; &lt;aop:after method="scream" pointcut-ref="whenCalled" /&gt; &lt;/aop:aspect&gt; &lt;/aop:config&gt; </code></pre> <p>The method <strong>scream()</strong> in tao.zhang.Listener just prints out some text, <strong>and is supposed to be executed whenever a method callme() is called.</strong></p> <p>I have a bean called <strong>logger</strong> which has the methods log() and callme()</p> <pre class="lang-java prettyprint-override"><code>public void log(){ callme(); System.out.println("Hello from logger ~~~~~~~~~~~~~~~~~~~"); } public void callme(){ System.out.println("I'm called"); } </code></pre> <p>Note that callme() is called by log()</p> <p>Now I have a scheduler which calls log() every 5 seconds:</p> <pre class="lang-xml prettyprint-override"><code>&lt;task:scheduler id="myScheduler" pool-size="10"/&gt; &lt;task:scheduled-tasks scheduler="myScheduler"&gt; &lt;task:scheduled ref="logger" method="log" fixed-rate="5000"/&gt; &lt;/task:scheduled-tasks&gt; </code></pre> <p>Strangely, <strong>scream()</strong> is not invoked, but if callme() is called directly:</p> <pre class="lang-xml prettyprint-override"><code>&lt;task:scheduler id="myScheduler" pool-size="10"/&gt; &lt;task:scheduled-tasks scheduler="myScheduler"&gt; &lt;task:scheduled ref="logger" method="callme" fixed-rate="5000"/&gt; &lt;/task:scheduled-tasks&gt; </code></pre> <p><strong>scream()</strong> is invoked!</p> <p>Any suggestions? It seems to me that this pointcut doesn't match methods called inside another method ...</p>
 

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