use of cn.taketoday.aop.framework.AdvisedSupport in project today-framework by TAKETODAY.
the class UnsupportedInterceptor method testProxyAProxy.
@Test
public void testProxyAProxy() {
ITestBean target = new TestBean();
mockTargetSource.setTarget(target);
AdvisedSupport as = new AdvisedSupport();
as.setTargetSource(mockTargetSource);
as.addAdvice(new NopInterceptor());
CglibAopProxy cglib = new CglibAopProxy(as);
ITestBean proxy1 = (ITestBean) cglib.getProxy();
mockTargetSource.setTarget(proxy1);
as = new AdvisedSupport(new Class<?>[] {});
as.setTargetSource(mockTargetSource);
as.addAdvice(new NopInterceptor());
cglib = new CglibAopProxy(as);
assertThat(cglib.getProxy()).isInstanceOf(ITestBean.class);
}
use of cn.taketoday.aop.framework.AdvisedSupport in project today-framework by TAKETODAY.
the class AopProxyUtilsTests method testCompleteProxiedInterfacesAdvisedIncluded.
@Test
public void testCompleteProxiedInterfacesAdvisedIncluded() {
AdvisedSupport as = new AdvisedSupport();
as.addInterface(ITestBean.class);
as.addInterface(Comparable.class);
as.addInterface(Advised.class);
Class<?>[] completedInterfaces = AopProxyUtils.completeProxiedInterfaces(as);
assertThat(completedInterfaces.length).isEqualTo(4);
// Can't assume ordering for others, so use a list
List<?> l = Arrays.asList(completedInterfaces);
assertThat(l.contains(Advised.class)).isTrue();
assertThat(l.contains(ITestBean.class)).isTrue();
assertThat(l.contains(Comparable.class)).isTrue();
}
use of cn.taketoday.aop.framework.AdvisedSupport in project today-framework by TAKETODAY.
the class AopProxyUtilsTests method testCompleteProxiedInterfacesWorksWithNullOpaque.
@Test
public void testCompleteProxiedInterfacesWorksWithNullOpaque() {
AdvisedSupport as = new AdvisedSupport();
as.setOpaque(true);
Class<?>[] completedInterfaces = AopProxyUtils.completeProxiedInterfaces(as);
assertThat(completedInterfaces.length).isEqualTo(1);
}
use of cn.taketoday.aop.framework.AdvisedSupport in project today-framework by TAKETODAY.
the class NoneProxyMethodGenerator method generate.
@Override
public boolean generate(Method method, GeneratorContext context) {
final AdvisedSupport config = context.getConfig();
final MethodInterceptor[] interceptors = context.getConfig().getInterceptors(method, context.getTargetClass());
if (ObjectUtils.isEmpty(interceptors)) {
final TargetSource targetSource = config.getTargetSource();
if (targetSource.isStatic()) {
invokeStaticTarget(method, context);
} else {
invokeTargetFromTargetSource(method, context);
}
return true;
}
return false;
}
Aggregations