1 16 17 package org.springframework.aop.support; 18 19 import org.aopalliance.intercept.MethodInvocation; 20 21 import org.springframework.aop.DynamicIntroductionAdvice; 22 import org.springframework.aop.IntroductionInterceptor; 23 import org.springframework.aop.ProxyMethodInvocation; 24 import org.springframework.util.Assert; 25 26 51 public class DelegatingIntroductionInterceptor extends IntroductionInfoSupport 52 implements IntroductionInterceptor { 53 54 58 private Object delegate; 59 60 61 66 public DelegatingIntroductionInterceptor(Object delegate) { 67 init(delegate); 68 } 69 70 75 protected DelegatingIntroductionInterceptor() { 76 init(this); 77 } 78 79 80 84 private void init(Object delegate) { 85 Assert.notNull(delegate, "delegate is required"); 86 this.delegate = delegate; 87 implementInterfacesOnObject(delegate); 88 89 suppressInterface(IntroductionInterceptor.class); 91 suppressInterface(DynamicIntroductionAdvice.class); 92 } 93 94 95 100 public Object invoke(MethodInvocation mi) throws Throwable { 101 if (isMethodOnIntroducedInterface(mi)) { 102 Object retVal = AopUtils.invokeJoinpointUsingReflection(this.delegate, mi.getMethod(), mi.getArguments()); 106 107 if (retVal == this.delegate && mi instanceof ProxyMethodInvocation) { 110 retVal = ((ProxyMethodInvocation) mi).getProxy(); 111 } 112 return retVal; 113 } 114 115 return doProceed(mi); 116 } 117 118 125 protected Object doProceed(MethodInvocation mi) throws Throwable { 126 return mi.proceed(); 128 } 129 130 } 131 | Popular Tags |