Search in sources :

Example 11 with SimpleTraceInterceptor

use of org.springframework.aop.interceptor.SimpleTraceInterceptor in project spring-framework by spring-projects.

the class ConfigurationClassPostProcessorTests method genericsBasedInjectionWithLateGenericsMatchingOnJdkProxy.

@Test
public 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);
    assertTrue(ObjectUtils.containsElement(beanNames, "stringRepo"));
    beanNames = beanFactory.getBeanNamesForType(ResolvableType.forClassWithGenerics(RepositoryInterface.class, String.class));
    assertEquals(1, beanNames.length);
    assertEquals("stringRepo", beanNames[0]);
    assertTrue(AopUtils.isJdkDynamicProxy(beanFactory.getBean("stringRepo")));
}
Also used : DefaultAdvisorAutoProxyCreator(org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator) SimpleTraceInterceptor(org.springframework.aop.interceptor.SimpleTraceInterceptor) RootBeanDefinition(org.springframework.beans.factory.support.RootBeanDefinition) DefaultPointcutAdvisor(org.springframework.aop.support.DefaultPointcutAdvisor) Test(org.junit.Test)

Aggregations

DefaultAdvisorAutoProxyCreator (org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator)11 SimpleTraceInterceptor (org.springframework.aop.interceptor.SimpleTraceInterceptor)11 DefaultPointcutAdvisor (org.springframework.aop.support.DefaultPointcutAdvisor)11 RootBeanDefinition (org.springframework.beans.factory.support.RootBeanDefinition)10 Test (org.junit.Test)9 GenericWebApplicationContext (org.springframework.web.context.support.GenericWebApplicationContext)5 MockHttpServletRequest (org.springframework.mock.web.test.MockHttpServletRequest)3 MockHttpServletResponse (org.springframework.mock.web.test.MockHttpServletResponse)3 MockServletConfig (org.springframework.mock.web.test.MockServletConfig)2 WebApplicationContext (org.springframework.web.context.WebApplicationContext)2 DispatcherServlet (org.springframework.web.servlet.DispatcherServlet)2 HttpSession (javax.servlet.http.HttpSession)1