@Override public boolean matches(Method method, Class<?> targetClass, boolean hasIntroductions) { return (matchesClass1(targetClass) && MethodMatchers.matches(this.mm1, method, targetClass, hasIntroductions)) || (matchesClass2(targetClass) && MethodMatchers.matches(this.mm2, method, targetClass, hasIntroductions)); } }
/** * Return an introduction advisor mixin that allows the AOP proxy to be * cast to ThreadLocalInvokerStats. */ public IntroductionAdvisor getStatsMixin() { DelegatingIntroductionInterceptor dii = new DelegatingIntroductionInterceptor(this); return new DefaultIntroductionAdvisor(dii, ThreadLocalTargetSourceStats.class); }
/** * Match all methods that <i>either</i> (or both) of the given MethodMatchers matches. * @param mm1 the first MethodMatcher * @param mm2 the second MethodMatcher * @return a distinct MethodMatcher that matches all methods that either * of the given MethodMatchers matches */ public static MethodMatcher union(MethodMatcher mm1, MethodMatcher mm2) { return (mm1 instanceof IntroductionAwareMethodMatcher || mm2 instanceof IntroductionAwareMethodMatcher ? new UnionIntroductionAwareMethodMatcher(mm1, mm2) : new UnionMethodMatcher(mm1, mm2)); }
/** * Return the actual bean class of the given bean instance. * This is the class exposed to description-style JMX properties. * <p>Default implementation returns the target class for an AOP proxy, * and the plain bean class else. * @param managedBean the bean instance (might be an AOP proxy) * @return the bean class to expose * @see org.springframework.aop.support.AopUtils#getTargetClass(Object) */ protected Class<?> getTargetClass(Object managedBean) { return AopUtils.getTargetClass(managedBean); }
private Advisor createSpringAOPAfterAdvice(int order) { AfterReturningAdvice advice = new AfterReturningAdvice() { @Override public void afterReturning(@Nullable Object returnValue, Method method, Object[] args, @Nullable Object target) throws Throwable { } }; DefaultPointcutAdvisor advisor = new DefaultPointcutAdvisor(this.anyOldPointcut, advice); advisor.setOrder(order); return advisor; }
/** * Match all methods that <b>either</b> (or both) of the given pointcuts matches. * @param pc1 the first Pointcut * @param pc2 the second Pointcut * @return a distinct Pointcut that matches all methods that either * of the given Pointcuts matches */ public static Pointcut union(Pointcut pc1, Pointcut pc2) { return new ComposablePointcut(pc1).union(pc2); }
/** * Create the actual pointcut: By default, a {@link JdkRegexpMethodPointcut} * will be used. * @return the Pointcut instance (never {@code null}) */ protected AbstractRegexpMethodPointcut createPointcut() { return new JdkRegexpMethodPointcut(); }
/** * Can the given pointcut apply at all on the given class? * <p>This is an important test as it can be used to optimize * out a pointcut for a class. * @param pc the static or dynamic pointcut to check * @param targetClass the class to test * @return whether the pointcut can apply on any method */ public static boolean canApply(Pointcut pc, Class<?> targetClass) { return canApply(pc, targetClass, false); }
@Override public boolean matches(Method method, Class<?> targetClass, boolean hasIntroductions) { return (matchesClass1(targetClass) && MethodMatchers.matches(this.mm1, method, targetClass, hasIntroductions)) || (matchesClass2(targetClass) && MethodMatchers.matches(this.mm2, method, targetClass, hasIntroductions)); } }
public DelegatePerTargetObjectIntroductionInterceptor(Class<?> defaultImplType, Class<?> interfaceType) { this.defaultImplType = defaultImplType; this.interfaceType = interfaceType; // Create a new delegate now (but don't store it in the map). // We do this for two reasons: // 1) to fail early if there is a problem instantiating delegates // 2) to populate the interface map once and once only Object delegate = createNewDelegate(); implementInterfacesOnObject(delegate); suppressInterface(IntroductionInterceptor.class); suppressInterface(DynamicIntroductionAdvice.class); }
/** * Set the method names defining methods to match. * Matching will be the union of all these; if any match, * the pointcut matches. * @see NameMatchMethodPointcut#setMappedNames */ public void setMappedNames(String... mappedNames) { this.pointcut.setMappedNames(mappedNames); }
/** * Match all methods that <i>both</i> of the given MethodMatchers match. * @param mm1 the first MethodMatcher * @param mm2 the second MethodMatcher * @return a distinct MethodMatcher that matches all methods that both * of the given MethodMatchers match */ public static MethodMatcher intersection(MethodMatcher mm1, MethodMatcher mm2) { return (mm1 instanceof IntroductionAwareMethodMatcher || mm2 instanceof IntroductionAwareMethodMatcher ? new IntersectionIntroductionAwareMethodMatcher(mm1, mm2) : new IntersectionMethodMatcher(mm1, mm2)); }
/** * Match all methods that <i>either</i> (or both) of the given MethodMatchers matches. * @param mm1 the first MethodMatcher * @param cf1 the corresponding ClassFilter for the first MethodMatcher * @param mm2 the second MethodMatcher * @param cf2 the corresponding ClassFilter for the second MethodMatcher * @return a distinct MethodMatcher that matches all methods that either * of the given MethodMatchers matches */ static MethodMatcher union(MethodMatcher mm1, ClassFilter cf1, MethodMatcher mm2, ClassFilter cf2) { return (mm1 instanceof IntroductionAwareMethodMatcher || mm2 instanceof IntroductionAwareMethodMatcher ? new ClassFilterAwareUnionIntroductionAwareMethodMatcher(mm1, cf1, mm2, cf2) : new ClassFilterAwareUnionMethodMatcher(mm1, cf1, mm2, cf2)); }
/** * Apply a union with the given MethodMatcher. * @param other the MethodMatcher to apply a union with * @return this composable pointcut (for call chaining) */ public ComposablePointcut union(MethodMatcher other) { this.methodMatcher = MethodMatchers.union(this.methodMatcher, other); return this; }
/** * Create a new advisor for this DeclareParents field. * @param interfaceType static field defining the introduction * @param typePattern type pattern the introduction is restricted to * @param defaultImpl the default implementation class */ public DeclareParentsAdvisor(Class<?> interfaceType, String typePattern, Class<?> defaultImpl) { this(interfaceType, typePattern, new DelegatePerTargetObjectIntroductionInterceptor(defaultImpl, interfaceType)); }
/** * Initialize exclusion {@link Pattern Patterns} from the supplied {@code String[]}. */ @Override protected void initExcludedPatternRepresentation(String[] excludedPatterns) throws PatternSyntaxException { this.compiledExclusionPatterns = compilePatterns(excludedPatterns); }
/** * Set the {@link ClassFilter} to use for this pointcut. * Default is {@link ClassFilter#TRUE}. * @see NameMatchMethodPointcut#setClassFilter */ public void setClassFilter(ClassFilter classFilter) { this.pointcut.setClassFilter(classFilter); }
@Override public int hashCode() { // Allow for matching with regular UnionMethodMatcher by providing same hash... return super.hashCode(); } }
/** * Return an IntroductionAdvisor that providing a mixin * exposing statistics about the pool maintained by this object. */ public DefaultIntroductionAdvisor getPoolingConfigMixin() { DelegatingIntroductionInterceptor dii = new DelegatingIntroductionInterceptor(this); return new DefaultIntroductionAdvisor(dii, PoolingConfig.class); }