Search in sources :

Example 1 with SimpleTraceInterceptor

use of cn.taketoday.aop.interceptor.SimpleTraceInterceptor in project today-infrastructure by TAKETODAY.

the class ConfigurationClassPostProcessorTests method genericsBasedInjectionWithLateGenericsMatchingOnCglibProxyAndRawFactoryMethod.

@Test
void genericsBasedInjectionWithLateGenericsMatchingOnCglibProxyAndRawFactoryMethod() {
    beanFactory.registerBeanDefinition("configClass", new RootBeanDefinition(RawFactoryMethodRepositoryConfiguration.class));
    new ConfigurationClassPostProcessor().postProcessBeanFactory(beanFactory);
    DefaultAdvisorAutoProxyCreator autoProxyCreator = new DefaultAdvisorAutoProxyCreator();
    autoProxyCreator.setProxyTargetClass(true);
    autoProxyCreator.setBeanFactory(beanFactory);
    beanFactory.addBeanPostProcessor(autoProxyCreator);
    beanFactory.registerSingleton("traceInterceptor", new DefaultPointcutAdvisor(new SimpleTraceInterceptor()));
    beanFactory.preInstantiateSingletons();
    String[] beanNames = beanFactory.getBeanNamesForType(Repository.class).toArray(new String[0]);
    assertThat(beanNames).contains("stringRepo");
    beanNames = beanFactory.getBeanNamesForType(ResolvableType.fromClassWithGenerics(Repository.class, String.class)).toArray(new String[0]);
    assertThat(beanNames.length).isEqualTo(1);
    assertThat(beanNames[0]).isEqualTo("stringRepo");
    beanNames = beanFactory.getBeanNamesForType(ResolvableType.fromClassWithGenerics(Repository.class, String.class)).toArray(new String[0]);
    assertThat(beanNames.length).isEqualTo(1);
    assertThat(beanNames[0]).isEqualTo("stringRepo");
    assertThat(AopUtils.isCglibProxy(beanFactory.getBean("stringRepo"))).isTrue();
}
Also used : DefaultAdvisorAutoProxyCreator(cn.taketoday.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator) SimpleTraceInterceptor(cn.taketoday.aop.interceptor.SimpleTraceInterceptor) RootBeanDefinition(cn.taketoday.beans.factory.support.RootBeanDefinition) DefaultPointcutAdvisor(cn.taketoday.aop.support.DefaultPointcutAdvisor) Test(org.junit.jupiter.api.Test)

Example 2 with SimpleTraceInterceptor

use of cn.taketoday.aop.interceptor.SimpleTraceInterceptor in project today-infrastructure by TAKETODAY.

the class ConfigurationClassPostProcessorTests method genericsBasedInjectionWithEarlyGenericsMatchingOnCglibProxy.

@Test
void genericsBasedInjectionWithEarlyGenericsMatchingOnCglibProxy() {
    beanFactory.registerBeanDefinition("configClass", new RootBeanDefinition(RepositoryConfiguration.class));
    new ConfigurationClassPostProcessor().postProcessBeanFactory(beanFactory);
    DefaultAdvisorAutoProxyCreator autoProxyCreator = new DefaultAdvisorAutoProxyCreator();
    autoProxyCreator.setProxyTargetClass(true);
    autoProxyCreator.setBeanFactory(beanFactory);
    beanFactory.addBeanPostProcessor(autoProxyCreator);
    beanFactory.registerSingleton("traceInterceptor", new DefaultPointcutAdvisor(new SimpleTraceInterceptor()));
    String[] beanNames = beanFactory.getBeanNamesForType(Repository.class).toArray(new String[0]);
    assertThat(beanNames).contains("stringRepo");
    beanNames = beanFactory.getBeanNamesForType(ResolvableType.fromClassWithGenerics(Repository.class, String.class)).toArray(new String[0]);
    assertThat(beanNames.length).isEqualTo(1);
    assertThat(beanNames[0]).isEqualTo("stringRepo");
    beanNames = beanFactory.getBeanNamesForType(ResolvableType.fromClassWithGenerics(Repository.class, String.class)).toArray(new String[0]);
    assertThat(beanNames.length).isEqualTo(1);
    assertThat(beanNames[0]).isEqualTo("stringRepo");
    assertThat(AopUtils.isCglibProxy(beanFactory.getBean("stringRepo"))).isTrue();
}
Also used : DefaultAdvisorAutoProxyCreator(cn.taketoday.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator) SimpleTraceInterceptor(cn.taketoday.aop.interceptor.SimpleTraceInterceptor) RootBeanDefinition(cn.taketoday.beans.factory.support.RootBeanDefinition) DefaultPointcutAdvisor(cn.taketoday.aop.support.DefaultPointcutAdvisor) Test(org.junit.jupiter.api.Test)

Example 3 with SimpleTraceInterceptor

use of cn.taketoday.aop.interceptor.SimpleTraceInterceptor in project today-infrastructure by TAKETODAY.

the class ConfigurationClassPostProcessorTests method genericsBasedInjectionWithLateGenericsMatchingOnCglibProxyAndRawInstance.

@Test
void genericsBasedInjectionWithLateGenericsMatchingOnCglibProxyAndRawInstance() {
    beanFactory.registerBeanDefinition("configClass", new RootBeanDefinition(RawInstanceRepositoryConfiguration.class));
    new ConfigurationClassPostProcessor().postProcessBeanFactory(beanFactory);
    DefaultAdvisorAutoProxyCreator autoProxyCreator = new DefaultAdvisorAutoProxyCreator();
    autoProxyCreator.setProxyTargetClass(true);
    autoProxyCreator.setBeanFactory(beanFactory);
    beanFactory.addBeanPostProcessor(autoProxyCreator);
    beanFactory.registerSingleton("traceInterceptor", new DefaultPointcutAdvisor(new SimpleTraceInterceptor()));
    beanFactory.preInstantiateSingletons();
    String[] beanNames = beanFactory.getBeanNamesForType(Repository.class).toArray(new String[0]);
    assertThat(beanNames).contains("stringRepo");
    beanNames = beanFactory.getBeanNamesForType(ResolvableType.fromClassWithGenerics(Repository.class, String.class)).toArray(new String[0]);
    assertThat(beanNames.length).isEqualTo(1);
    assertThat(beanNames[0]).isEqualTo("stringRepo");
    beanNames = beanFactory.getBeanNamesForType(ResolvableType.fromClassWithGenerics(Repository.class, String.class)).toArray(new String[0]);
    assertThat(beanNames.length).isEqualTo(1);
    assertThat(beanNames[0]).isEqualTo("stringRepo");
    assertThat(AopUtils.isCglibProxy(beanFactory.getBean("stringRepo"))).isTrue();
}
Also used : DefaultAdvisorAutoProxyCreator(cn.taketoday.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator) SimpleTraceInterceptor(cn.taketoday.aop.interceptor.SimpleTraceInterceptor) RootBeanDefinition(cn.taketoday.beans.factory.support.RootBeanDefinition) DefaultPointcutAdvisor(cn.taketoday.aop.support.DefaultPointcutAdvisor) Test(org.junit.jupiter.api.Test)

Example 4 with SimpleTraceInterceptor

use of cn.taketoday.aop.interceptor.SimpleTraceInterceptor in project today-infrastructure by TAKETODAY.

the class ConfigurationClassPostProcessorTests method genericsBasedInjectionWithLateGenericsMatchingOnJdkProxy.

@Test
void genericsBasedInjectionWithLateGenericsMatchingOnJdkProxy() {
    beanFactory.registerBeanDefinition("configClass", new RootBeanDefinition(RepositoryConfiguration.class));
    new ConfigurationClassPostProcessor().postProcessBeanFactory(beanFactory);
    DefaultAdvisorAutoProxyCreator autoProxyCreator = new DefaultAdvisorAutoProxyCreator();
    autoProxyCreator.setBeanFactory(beanFactory);
    beanFactory.addBeanPostProcessor(autoProxyCreator);
    beanFactory.registerSingleton("traceInterceptor", new DefaultPointcutAdvisor(new SimpleTraceInterceptor()));
    beanFactory.preInstantiateSingletons();
    String[] beanNames = beanFactory.getBeanNamesForType(RepositoryInterface.class).toArray(new String[0]);
    assertThat(beanNames).contains("stringRepo");
    beanNames = beanFactory.getBeanNamesForType(ResolvableType.fromClassWithGenerics(RepositoryInterface.class, String.class)).toArray(new String[0]);
    assertThat(beanNames.length).isEqualTo(1);
    assertThat(beanNames[0]).isEqualTo("stringRepo");
    beanNames = beanFactory.getBeanNamesForType(ResolvableType.fromClassWithGenerics(RepositoryInterface.class, String.class)).toArray(new String[0]);
    assertThat(beanNames.length).isEqualTo(1);
    assertThat(beanNames[0]).isEqualTo("stringRepo");
    assertThat(AopUtils.isJdkDynamicProxy(beanFactory.getBean("stringRepo"))).isTrue();
}
Also used : DefaultAdvisorAutoProxyCreator(cn.taketoday.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator) SimpleTraceInterceptor(cn.taketoday.aop.interceptor.SimpleTraceInterceptor) RootBeanDefinition(cn.taketoday.beans.factory.support.RootBeanDefinition) DefaultPointcutAdvisor(cn.taketoday.aop.support.DefaultPointcutAdvisor) Test(org.junit.jupiter.api.Test)

Example 5 with SimpleTraceInterceptor

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

the class ConfigurationClassPostProcessorTests method genericsBasedInjectionWithLateGenericsMatchingOnJdkProxyAndRawFactoryMethod.

@Test
void genericsBasedInjectionWithLateGenericsMatchingOnJdkProxyAndRawFactoryMethod() {
    beanFactory.registerBeanDefinition("configClass", new RootBeanDefinition(RawFactoryMethodRepositoryConfiguration.class));
    new ConfigurationClassPostProcessor().postProcessBeanFactory(beanFactory);
    DefaultAdvisorAutoProxyCreator autoProxyCreator = new DefaultAdvisorAutoProxyCreator();
    autoProxyCreator.setBeanFactory(beanFactory);
    beanFactory.addBeanPostProcessor(autoProxyCreator);
    beanFactory.registerSingleton("traceInterceptor", new DefaultPointcutAdvisor(new SimpleTraceInterceptor()));
    beanFactory.preInstantiateSingletons();
    String[] beanNames = beanFactory.getBeanNamesForType(RepositoryInterface.class).toArray(new String[0]);
    assertThat(beanNames).contains("stringRepo");
    beanNames = beanFactory.getBeanNamesForType(ResolvableType.fromClassWithGenerics(RepositoryInterface.class, String.class)).toArray(new String[0]);
    assertThat(beanNames.length).isEqualTo(1);
    assertThat(beanNames[0]).isEqualTo("stringRepo");
    beanNames = beanFactory.getBeanNamesForType(ResolvableType.fromClassWithGenerics(RepositoryInterface.class, String.class)).toArray(new String[0]);
    assertThat(beanNames.length).isEqualTo(1);
    assertThat(beanNames[0]).isEqualTo("stringRepo");
    assertThat(AopUtils.isJdkDynamicProxy(beanFactory.getBean("stringRepo"))).isTrue();
}
Also used : DefaultAdvisorAutoProxyCreator(cn.taketoday.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator) SimpleTraceInterceptor(cn.taketoday.aop.interceptor.SimpleTraceInterceptor) RootBeanDefinition(cn.taketoday.beans.factory.support.RootBeanDefinition) DefaultPointcutAdvisor(cn.taketoday.aop.support.DefaultPointcutAdvisor) Test(org.junit.jupiter.api.Test)

Aggregations

DefaultAdvisorAutoProxyCreator (cn.taketoday.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator)16 SimpleTraceInterceptor (cn.taketoday.aop.interceptor.SimpleTraceInterceptor)16 DefaultPointcutAdvisor (cn.taketoday.aop.support.DefaultPointcutAdvisor)16 RootBeanDefinition (cn.taketoday.beans.factory.support.RootBeanDefinition)16 Test (org.junit.jupiter.api.Test)16