Search in sources :

Example 1 with ComposablePointcut

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

the class AsyncAnnotationAdvisor method buildPointcut.

/**
 * Calculate a pointcut for the given async annotation types, if any.
 *
 * @param asyncAnnotationTypes the async annotation types to introspect
 * @return the applicable Pointcut object, or {@code null} if none
 */
protected Pointcut buildPointcut(Set<Class<? extends Annotation>> asyncAnnotationTypes) {
    ComposablePointcut result = null;
    for (Class<? extends Annotation> asyncAnnotationType : asyncAnnotationTypes) {
        Pointcut cpc = new AnnotationMatchingPointcut(asyncAnnotationType, true);
        Pointcut mpc = new AnnotationMatchingPointcut(null, asyncAnnotationType, true);
        if (result == null) {
            result = new ComposablePointcut(cpc);
        } else {
            result.union(cpc);
        }
        result = result.union(mpc);
    }
    return (result != null ? result : Pointcut.TRUE);
}
Also used : Pointcut(cn.taketoday.aop.Pointcut) AnnotationMatchingPointcut(cn.taketoday.aop.support.annotation.AnnotationMatchingPointcut) ComposablePointcut(cn.taketoday.aop.support.ComposablePointcut) AnnotationMatchingPointcut(cn.taketoday.aop.support.annotation.AnnotationMatchingPointcut) ComposablePointcut(cn.taketoday.aop.support.ComposablePointcut)

Example 2 with ComposablePointcut

use of cn.taketoday.aop.support.ComposablePointcut in project today-infrastructure by TAKETODAY.

the class AsyncAnnotationAdvisor method buildPointcut.

/**
 * Calculate a pointcut for the given async annotation types, if any.
 *
 * @param asyncAnnotationTypes the async annotation types to introspect
 * @return the applicable Pointcut object, or {@code null} if none
 */
protected Pointcut buildPointcut(Set<Class<? extends Annotation>> asyncAnnotationTypes) {
    ComposablePointcut result = null;
    for (Class<? extends Annotation> asyncAnnotationType : asyncAnnotationTypes) {
        Pointcut cpc = new AnnotationMatchingPointcut(asyncAnnotationType, true);
        Pointcut mpc = new AnnotationMatchingPointcut(null, asyncAnnotationType, true);
        if (result == null) {
            result = new ComposablePointcut(cpc);
        } else {
            result.union(cpc);
        }
        result = result.union(mpc);
    }
    return (result != null ? result : Pointcut.TRUE);
}
Also used : Pointcut(cn.taketoday.aop.Pointcut) AnnotationMatchingPointcut(cn.taketoday.aop.support.annotation.AnnotationMatchingPointcut) ComposablePointcut(cn.taketoday.aop.support.ComposablePointcut) AnnotationMatchingPointcut(cn.taketoday.aop.support.annotation.AnnotationMatchingPointcut) ComposablePointcut(cn.taketoday.aop.support.ComposablePointcut)

Aggregations

Pointcut (cn.taketoday.aop.Pointcut)2 ComposablePointcut (cn.taketoday.aop.support.ComposablePointcut)2 AnnotationMatchingPointcut (cn.taketoday.aop.support.annotation.AnnotationMatchingPointcut)2