Announcement Announcement Module
Collapse
No announcement yet.
AOP Interceptors and String 2.5 Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • AOP Interceptors and String 2.5

    Hello everyone!

    I did use AOP interceptors (org.aopalliance.intercept.MethodInterceptor) before 2.0 and all worked great.

    Now I moved to 2.5.

    The questions I have:
    1. Would the old style Method Interceptors work ?
    2. If I'd like to implement then in the new style (via aop:config) how would I go about intercepting before and after ? I want to clock how much time each method called takes

    Can you gimme an example of how the "around advice" is implemented for the code below ?

    Code:
    <aop:config>
    <aop:pointcut id="genericMethod" expression="execution(* *..*.*(..))"/>
    <aop:advisor pointcut-ref="genericMethod" advice-ref="clockingInterceptor" />
    </aop:config>
    Thanks in advance!
    Q

  • #2
    AOPAlliance advices are fully supported by the new aop schema configuration. There was an example about that already - "Bridge" between AspectJ and Interceptors? .

    The reference mentions example of the simple logging aspect several times, e.g. here:
    Code:
    public class SimpleProfiler {
    
       public Object profile(ProceedingJoinPoint call, String name, int age) throws Throwable {
          StopWatch clock = new StopWatch(
                "Profiling for '" + name + "' and '" + age + "'");
          try {
             clock.start(call.toShortString());
             return call.proceed();
          } finally {
             clock.stop();
             System.out.println(clock.prettyPrint());
          }
       }
    }

    Comment

    Working...
    X