1 16 17 package org.springframework.aop.aspectj; 18 19 import java.lang.reflect.Method ; 20 21 import org.aopalliance.intercept.MethodInterceptor; 22 import org.aopalliance.intercept.MethodInvocation; 23 import org.aspectj.lang.ProceedingJoinPoint; 24 import org.aspectj.weaver.tools.JoinPointMatch; 25 26 import org.springframework.aop.ProxyMethodInvocation; 27 28 36 public class AspectJAroundAdvice extends AbstractAspectJAdvice implements MethodInterceptor { 37 38 public AspectJAroundAdvice( 39 Method aspectJAroundAdviceMethod, AspectJExpressionPointcut pointcut, AspectInstanceFactory aif) { 40 41 super(aspectJAroundAdviceMethod, pointcut, aif); 42 } 43 44 public boolean isBeforeAdvice() { 45 return false; 46 } 47 48 public boolean isAfterAdvice() { 49 return false; 50 } 51 52 53 public Object invoke(MethodInvocation mi) throws Throwable { 54 if (!(mi instanceof ProxyMethodInvocation)) { 55 throw new IllegalStateException ("MethodInvocation is not a Spring ProxyMethodInvocation: " + mi); 56 } 57 ProxyMethodInvocation pmi = (ProxyMethodInvocation) mi; 58 ProceedingJoinPoint pjp = lazyGetProceedingJoinPoint(pmi); 59 JoinPointMatch jpm = getJoinPointMatch(pmi); 60 return invokeAdviceMethod(pjp, jpm, null, null); 61 } 62 63 70 protected ProceedingJoinPoint lazyGetProceedingJoinPoint(ProxyMethodInvocation rmi) { 71 return new MethodInvocationProceedingJoinPoint(rmi); 72 } 73 74 } 75 | Popular Tags |