spring aop中引介拦截器的用法

public class Other implements IntroductionInterceptor,IOther{
 public void doOther(){
  System.out.println("Other对象的功能");
 }
 
 public Object invoke(MethodInvocation methodInvocation) throws Throwable {
  if(implementsInterface(methodInvocation.getMethod().getDeclaringClass())){
   return methodInvocation.getMethod().invoke(this, methodInvocation.getArguments());
  }
  else{
   return methodInvocation.proceed();
  }
 }
 public boolean implementsInterface(Class arg0){
  boolean assignableFrom = arg0.isAssignableFrom(IOther.class);
  return assignableFrom;
 } 
}

 

上一篇:ServletRequestAttributeListener的用法和实例


下一篇:消息中间件ActiveMQ的简单使用-Spring整合开发(2)