spring aop example in spring✖️struts

Intercepter

 

import org.aopalliance.intercept.MethodInterceptor;

import org.aopalliance.intercept.MethodInvocation;

 

public class MyMethodIntercepter implements MethodInterceptor {

 

@Override

public Object invoke(MethodInvocation invocation) throws Throwable {

// TODO 自動生成されたメソッド・スタブ

        System.out.println("メソッド実行前です");

        System.out.println(invocation.getMethod().getAnnotations());

        Object result = invocation.proceed();

        System.out.println("メソッド実行後です");

returnresult;

}

 

}

aop

 

<bean id="sample" class="jp.terasoluna.thin.tutorial.web.common.aop.MyMethodIntercepter">

</bean>

 

 <aop:config> 

   <aop:advisor pointcut="execution(* org.apache.struts.action.Action+.execute(..))"

     advice-ref="sample"  /> 

 </aop:config>