/** * Determine whether the given Advisor contains an AspectJ advice. * @param advisor the Advisor to check */ private static boolean isAspectJAdvice(Advisor advisor) { return (advisor instanceof InstantiationModelAwarePointcutAdvisor || advisor.getAdvice() instanceof AbstractAspectJAdvice || (advisor instanceof PointcutAdvisor && ((PointcutAdvisor) advisor).getPointcut() instanceof AspectJExpressionPointcut)); }
/** * Determine whether the Advisors contain matching introductions. */ private static boolean hasMatchingIntroductions(Advisor[] advisors, Class<?> actualClass) { for (Advisor advisor : advisors) { if (advisor instanceof IntroductionAdvisor) { IntroductionAdvisor ia = (IntroductionAdvisor) advisor; if (ia.getClassFilter().matches(actualClass)) { return true; } } } return false; }
@Override public boolean matches(Class<?> clazz) { for (ClassFilter filter : this.filters) { if (!filter.matches(clazz)) { return false; } } return true; }
@Test public void testMatchAll() throws NoSuchMethodException { Pointcut pc = new ComposablePointcut(); assertTrue(pc.getClassFilter().matches(Object.class)); assertTrue(pc.getMethodMatcher().matches(Object.class.getMethod("hashCode"), Exception.class)); }
private SimpleBeforeAdviceImpl getAdviceImpl(ITestBean tb) { Advised advised = (Advised) tb; Advisor advisor = advised.getAdvisors()[0]; return (SimpleBeforeAdviceImpl) advisor.getAdvice(); }
@Override public boolean matches(Method method, Class<?> targetClass) { // We're either instantiated and matching on declared pointcut, // or uninstantiated matching on either pointcut... return (isAspectMaterialized() && this.declaredPointcut.matches(method, targetClass)) || this.preInstantiationPointcut.getMethodMatcher().matches(method, targetClass); }
private boolean hasAspectName(Advisor anAdvisor) { return (anAdvisor instanceof AspectJPrecedenceInformation || anAdvisor.getAdvice() instanceof AspectJPrecedenceInformation); }
@Override public MethodInterceptor getInterceptor(Advisor advisor) { SimpleBeforeAdvice advice = (SimpleBeforeAdvice) advisor.getAdvice(); return new SimpleBeforeAdviceInterceptor(advice) ; }
private void validateIntroductionAdvisor(IntroductionAdvisor advisor) { advisor.validateInterfaces(); // If the advisor passed validation, we can make the change. Class<?>[] ifcs = advisor.getInterfaces(); for (Class<?> ifc : ifcs) { addInterface(ifc); } }
@Override public boolean matches(Method method, Class<?> targetClass, Object... args) { // Because a dynamic intersection may be composed of a static and dynamic part, // we must avoid calling the 3-arg matches method on a dynamic matcher, as // it will probably be an unsupported operation. boolean aMatches = (this.mm1.isRuntime() ? this.mm1.matches(method, targetClass, args) : this.mm1.matches(method, targetClass)); boolean bMatches = (this.mm2.isRuntime() ? this.mm2.matches(method, targetClass, args) : this.mm2.matches(method, targetClass)); return aMatches && bMatches; }
/** * Returns the Spring AOP proxy. Cannot be {@code null}. */ @Override public Object getThis() { return this.methodInvocation.getProxy(); }
@Override public Object invoke(MethodInvocation mi) throws Throwable { Object retVal = mi.proceed(); this.advice.afterReturning(retVal, mi.getMethod(), mi.getArguments(), mi.getThis()); return retVal; }
@Override public Method getMethod() { return methodInvocation.getMethod(); }
@Override public boolean matches(Class<?> clazz) { for (ClassFilter filter : this.filters) { if (filter.matches(clazz)) { return true; } } return false; }
@Override protected boolean matchesClass1(Class<?> targetClass) { return this.cf1.matches(targetClass); }
@Override protected boolean matchesClass2(Class<?> targetClass) { return this.cf2.matches(targetClass); }