Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Absolutely it can be done with Spring's AOP support. You can apply the first part as "before" advice and the 2nd as "after-finally" advice or you can apply both as "around" advice and programmatically invoke the target method like so:</p> <pre><code>methodInvocation.invoke(); // returns Object </code></pre> <p>If you want to declare your aspects in XML you can read about how to do it here:</p> <p><a href="http://static.springframework.org/spring/docs/2.5.x/reference/aop.html#aop-schema" rel="nofollow noreferrer">http://static.springframework.org/spring/docs/2.5.x/reference/aop.html#aop-schema</a> <a href="http://static.springframework.org/spring/docs/2.5.x/reference/aop.html#aop-schema-advice-before" rel="nofollow noreferrer">http://static.springframework.org/spring/docs/2.5.x/reference/aop.html#aop-schema-advice-before</a> <a href="http://static.springframework.org/spring/docs/2.5.x/reference/aop.html#aop-schema-advice-after-finally" rel="nofollow noreferrer">http://static.springframework.org/spring/docs/2.5.x/reference/aop.html#aop-schema-advice-after-finally</a> <a href="http://static.springframework.org/spring/docs/2.5.x/reference/aop.html#aop-ataspectj-around-advice" rel="nofollow noreferrer">http://static.springframework.org/spring/docs/2.5.x/reference/aop.html#aop-ataspectj-around-advice</a></p> <p>Or if you want to do it with annotations there is info here:</p> <p><a href="http://static.springframework.org/spring/docs/2.5.x/reference/aop.html#aop-ataspectj" rel="nofollow noreferrer">http://static.springframework.org/spring/docs/2.5.x/reference/aop.html#aop-ataspectj</a></p> <p>Personally I prefer doing it with XML since the behavior of the aspects can be altered without recompiling the application. Let's say you have a multi-module project where B depends A. A contains reusable advice and is using annotations for order, pointcuts, etc. If you need to change that behavior, you must rebuild A. If you are using XML in project B to configure the aspect from project A, no rebuild of A is needed.</p> <p>My feeling is that advice is more reusable when you define the behavior in a class and how that behavior is applied in XML.</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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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