Search in sources :

Example 51 with Pointcut

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

the class UnsupportedInterceptor method getAdvisedProxy.

private ITestBean getAdvisedProxy(TestBean target) {
    ProxyFactory pf = new ProxyFactory(new Class<?>[] { ITestBean.class });
    pf.setProxyTargetClass(true);
    MethodInterceptor advice = new NopInterceptor();
    Pointcut pointcut = new Pointcut() {

        @Override
        public ClassFilter getClassFilter() {
            return ClassFilter.TRUE;
        }

        @Override
        public MethodMatcher getMethodMatcher() {
            return MethodMatcher.TRUE;
        }

        @Override
        public boolean equals(Object obj) {
            return true;
        }

        @Override
        public int hashCode() {
            return 0;
        }
    };
    pf.addAdvisor(new DefaultPointcutAdvisor(pointcut, advice));
    pf.setTarget(target);
    pf.setFrozen(true);
    pf.setExposeProxy(false);
    return (ITestBean) pf.getProxy();
}
Also used : Pointcut(cn.taketoday.aop.Pointcut) ITestBean(cn.taketoday.beans.testfixture.beans.ITestBean) NopInterceptor(cn.taketoday.aop.NopInterceptor) MethodInterceptor(org.aopalliance.intercept.MethodInterceptor) ProxyFactory(cn.taketoday.aop.framework.ProxyFactory) DefaultPointcutAdvisor(cn.taketoday.aop.support.DefaultPointcutAdvisor)

Aggregations

Pointcut (cn.taketoday.aop.Pointcut)51 Test (org.junit.jupiter.api.Test)42 ITestBean (cn.taketoday.beans.testfixture.beans.ITestBean)13 AnnotationMatchingPointcut (cn.taketoday.aop.support.annotation.AnnotationMatchingPointcut)10 TestBean (cn.taketoday.beans.testfixture.beans.TestBean)10 DefaultPointcutAdvisor (cn.taketoday.aop.support.DefaultPointcutAdvisor)7 ClassFilter (cn.taketoday.aop.ClassFilter)6 MethodMatcher (cn.taketoday.aop.MethodMatcher)6 Qualifier (cn.taketoday.beans.factory.annotation.Qualifier)6 Qualifier (jakarta.inject.Qualifier)6 Method (java.lang.reflect.Method)6 ProxyFactory (cn.taketoday.aop.framework.ProxyFactory)5 NopInterceptor (cn.taketoday.aop.testfixture.interceptor.NopInterceptor)4 Nullable (cn.taketoday.lang.Nullable)4 PointcutExpression (org.aspectj.weaver.tools.PointcutExpression)4 MethodInterceptor (org.aopalliance.intercept.MethodInterceptor)3 DefaultMethodInvocation (cn.taketoday.aop.framework.DefaultMethodInvocation)2 ComposablePointcut (cn.taketoday.aop.support.ComposablePointcut)2 StaticMethodMatcherPointcut (cn.taketoday.aop.support.StaticMethodMatcherPointcut)2 NopInterceptor (cn.taketoday.aop.NopInterceptor)1