Search in sources :

Example 1 with AnnotationMatchingPointcut

use of cn.taketoday.aop.support.AnnotationMatchingPointcut in project today-framework by TAKETODAY.

the class AspectAutoProxyCreator method addCandidateAdvisors.

private void addCandidateAdvisors(BeanDefinition aspectDef, @Nullable Method aspectMethod, Stream<MergedAnnotation<Advice>> adviceAttributes) {
    adviceAttributes.forEach(advice -> {
        MethodInterceptor interceptor = getInterceptor(aspectDef, aspectMethod, advice);
        if (log.isTraceEnabled()) {
            log.trace("Found Interceptor: [{}]", interceptor);
        }
        // Annotations
        Class<? extends Annotation>[] annotations = advice.getClassArray(MergedAnnotation.VALUE);
        if (ObjectUtils.isNotEmpty(annotations)) {
            for (Class<? extends Annotation> annotation : annotations) {
                AnnotationMatchingPointcut matchingPointcut = AnnotationMatchingPointcut.forMethodAnnotation(annotation);
                DefaultPointcutAdvisor pointcutAdvisor = new DefaultPointcutAdvisor(matchingPointcut, interceptor);
                annotationAdvisors.add(pointcutAdvisor);
            }
        }
    });
}
Also used : AnnotationMatchingPointcut(cn.taketoday.aop.support.AnnotationMatchingPointcut) SuppliedMethodInterceptor(cn.taketoday.aop.support.SuppliedMethodInterceptor) MethodInterceptor(org.aopalliance.intercept.MethodInterceptor) DefaultPointcutAdvisor(cn.taketoday.aop.support.DefaultPointcutAdvisor) MergedAnnotation(cn.taketoday.core.annotation.MergedAnnotation) Annotation(java.lang.annotation.Annotation)

Aggregations

AnnotationMatchingPointcut (cn.taketoday.aop.support.AnnotationMatchingPointcut)1 DefaultPointcutAdvisor (cn.taketoday.aop.support.DefaultPointcutAdvisor)1 SuppliedMethodInterceptor (cn.taketoday.aop.support.SuppliedMethodInterceptor)1 MergedAnnotation (cn.taketoday.core.annotation.MergedAnnotation)1 Annotation (java.lang.annotation.Annotation)1 MethodInterceptor (org.aopalliance.intercept.MethodInterceptor)1