org.springframework.aop.interceptor.SimpleTraceInterceptor Java Examples
The following examples show how to use
org.springframework.aop.interceptor.SimpleTraceInterceptor.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ConfigurationClassPostProcessorTests.java From spring-analysis-note with MIT License | 6 votes |
@Test public void genericsBasedInjectionWithLateGenericsMatchingOnCglibProxy() { 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())); beanFactory.preInstantiateSingletons(); String[] beanNames = beanFactory.getBeanNamesForType(Repository.class); assertTrue(ObjectUtils.containsElement(beanNames, "stringRepo")); beanNames = beanFactory.getBeanNamesForType(ResolvableType.forClassWithGenerics(Repository.class, String.class)); assertEquals(1, beanNames.length); assertEquals("stringRepo", beanNames[0]); beanNames = beanFactory.getBeanNamesForType(ResolvableType.forClassWithGenerics(Repository.class, String.class)); assertEquals(1, beanNames.length); assertEquals("stringRepo", beanNames[0]); assertTrue(AopUtils.isCglibProxy(beanFactory.getBean("stringRepo"))); }
Example #2
Source File: ServletAnnotationControllerHandlerMethodTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Test public void proxiedFormController() throws Exception { initServlet(new ApplicationContextInitializer<GenericWebApplicationContext>() { @Override public void initialize(GenericWebApplicationContext wac) { wac.registerBeanDefinition("viewResolver", new RootBeanDefinition(TestViewResolver.class)); DefaultAdvisorAutoProxyCreator autoProxyCreator = new DefaultAdvisorAutoProxyCreator(); autoProxyCreator.setBeanFactory(wac.getBeanFactory()); wac.getBeanFactory().addBeanPostProcessor(autoProxyCreator); wac.getBeanFactory() .registerSingleton("advisor", new DefaultPointcutAdvisor(new SimpleTraceInterceptor())); } }, MyFormController.class); MockHttpServletRequest request = new MockHttpServletRequest("GET", "/myPath.do"); request.addParameter("name", "name1"); request.addParameter("age", "value2"); MockHttpServletResponse response = new MockHttpServletResponse(); getServlet().service(request, response); assertEquals("myView-name1-typeMismatch-tb1-myValue", response.getContentAsString()); }
Example #3
Source File: ServletAnnotationControllerTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Test @SuppressWarnings("serial") public void proxiedStandardHandleMethod() throws Exception { DispatcherServlet servlet = new DispatcherServlet() { @Override protected WebApplicationContext createWebApplicationContext(WebApplicationContext parent) { GenericWebApplicationContext wac = new GenericWebApplicationContext(); wac.registerBeanDefinition("controller", new RootBeanDefinition(MyController.class)); DefaultAdvisorAutoProxyCreator autoProxyCreator = new DefaultAdvisorAutoProxyCreator(); autoProxyCreator.setBeanFactory(wac.getBeanFactory()); wac.getBeanFactory().addBeanPostProcessor(autoProxyCreator); wac.getBeanFactory().registerSingleton("advisor", new DefaultPointcutAdvisor(new SimpleTraceInterceptor())); wac.refresh(); return wac; } }; servlet.init(new MockServletConfig()); MockHttpServletRequest request = new MockHttpServletRequest("GET", "/myPath.do"); MockHttpServletResponse response = new MockHttpServletResponse(); servlet.service(request, response); assertEquals("test", response.getContentAsString()); }
Example #4
Source File: JdkProxyServletAnnotationTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
@SuppressWarnings("serial") private void initServlet(final Class<?> controllerclass) throws ServletException { servlet = new DispatcherServlet() { @Override protected WebApplicationContext createWebApplicationContext(WebApplicationContext parent) throws BeansException { GenericWebApplicationContext wac = new GenericWebApplicationContext(); wac.registerBeanDefinition("controller", new RootBeanDefinition(controllerclass)); DefaultAdvisorAutoProxyCreator autoProxyCreator = new DefaultAdvisorAutoProxyCreator(); autoProxyCreator.setBeanFactory(wac.getBeanFactory()); wac.getBeanFactory().addBeanPostProcessor(autoProxyCreator); wac.getBeanFactory().registerSingleton("advisor", new DefaultPointcutAdvisor(new SimpleTraceInterceptor(true))); wac.refresh(); return wac; } }; servlet.init(new MockServletConfig()); }
Example #5
Source File: CgLibProxyServletAnnotationTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
@SuppressWarnings("serial") private void initServlet(final Class<?> controllerclass) throws ServletException { servlet = new DispatcherServlet() { @Override protected WebApplicationContext createWebApplicationContext(WebApplicationContext parent) throws BeansException { GenericWebApplicationContext wac = new GenericWebApplicationContext(); wac.registerBeanDefinition("controller", new RootBeanDefinition(controllerclass)); DefaultAdvisorAutoProxyCreator autoProxyCreator = new DefaultAdvisorAutoProxyCreator(); autoProxyCreator.setProxyTargetClass(true); autoProxyCreator.setBeanFactory(wac.getBeanFactory()); wac.getBeanFactory().addBeanPostProcessor(autoProxyCreator); wac.getBeanFactory().registerSingleton("advisor", new DefaultPointcutAdvisor(new SimpleTraceInterceptor(true))); wac.refresh(); return wac; } }; servlet.init(new MockServletConfig()); }
Example #6
Source File: ServletAnnotationControllerHandlerMethodTests.java From java-technology-stack with MIT License | 6 votes |
@Test public void proxiedFormController() throws Exception { initServlet(wac -> { wac.registerBeanDefinition("viewResolver", new RootBeanDefinition(TestViewResolver.class)); DefaultAdvisorAutoProxyCreator autoProxyCreator = new DefaultAdvisorAutoProxyCreator(); autoProxyCreator.setBeanFactory(wac.getBeanFactory()); wac.getBeanFactory().addBeanPostProcessor(autoProxyCreator); wac.getBeanFactory() .registerSingleton("advisor", new DefaultPointcutAdvisor(new SimpleTraceInterceptor())); }, MyFormController.class); MockHttpServletRequest request = new MockHttpServletRequest("GET", "/myPath.do"); request.addParameter("name", "name1"); request.addParameter("age", "value2"); MockHttpServletResponse response = new MockHttpServletResponse(); getServlet().service(request, response); assertEquals("myView-name1-typeMismatch-tb1-myValue", response.getContentAsString()); }
Example #7
Source File: CglibProxyControllerTests.java From java-technology-stack with MIT License | 6 votes |
@SuppressWarnings("serial") private void initServlet(final Class<?> controllerClass) throws ServletException { servlet = new DispatcherServlet() { @Override protected WebApplicationContext createWebApplicationContext(@Nullable WebApplicationContext parent) { GenericWebApplicationContext wac = new GenericWebApplicationContext(); wac.registerBeanDefinition("controller", new RootBeanDefinition(controllerClass)); DefaultAdvisorAutoProxyCreator autoProxyCreator = new DefaultAdvisorAutoProxyCreator(); autoProxyCreator.setProxyTargetClass(true); autoProxyCreator.setBeanFactory(wac.getBeanFactory()); wac.getBeanFactory().addBeanPostProcessor(autoProxyCreator); Pointcut pointcut = new AnnotationMatchingPointcut(Controller.class); DefaultPointcutAdvisor advisor = new DefaultPointcutAdvisor(pointcut, new SimpleTraceInterceptor(true)); wac.getBeanFactory().registerSingleton("advisor", advisor); wac.refresh(); return wac; } }; servlet.init(new MockServletConfig()); }
Example #8
Source File: JdkProxyControllerTests.java From java-technology-stack with MIT License | 6 votes |
@SuppressWarnings("serial") private void initServlet(final Class<?> controllerclass) throws ServletException { servlet = new DispatcherServlet() { @Override protected WebApplicationContext createWebApplicationContext(@Nullable WebApplicationContext parent) { GenericWebApplicationContext wac = new GenericWebApplicationContext(); wac.registerBeanDefinition("controller", new RootBeanDefinition(controllerclass)); DefaultAdvisorAutoProxyCreator autoProxyCreator = new DefaultAdvisorAutoProxyCreator(); autoProxyCreator.setBeanFactory(wac.getBeanFactory()); wac.getBeanFactory().addBeanPostProcessor(autoProxyCreator); wac.getBeanFactory().registerSingleton("advisor", new DefaultPointcutAdvisor(new SimpleTraceInterceptor(true))); wac.refresh(); return wac; } }; servlet.init(new MockServletConfig()); }
Example #9
Source File: ConfigurationClassPostProcessorTests.java From java-technology-stack with MIT License | 6 votes |
@Test public void genericsBasedInjectionWithLateGenericsMatchingOnJdkProxyAndRawInstance() { beanFactory.registerBeanDefinition("configClass", new RootBeanDefinition(RawInstanceRepositoryConfiguration.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]); beanNames = beanFactory.getBeanNamesForType(ResolvableType.forClassWithGenerics(RepositoryInterface.class, String.class)); assertEquals(1, beanNames.length); assertEquals("stringRepo", beanNames[0]); assertTrue(AopUtils.isJdkDynamicProxy(beanFactory.getBean("stringRepo"))); }
Example #10
Source File: ConfigurationClassPostProcessorTests.java From java-technology-stack with MIT License | 6 votes |
@Test public 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); assertTrue(ObjectUtils.containsElement(beanNames, "stringRepo")); beanNames = beanFactory.getBeanNamesForType(ResolvableType.forClassWithGenerics(RepositoryInterface.class, String.class)); assertEquals(1, beanNames.length); assertEquals("stringRepo", beanNames[0]); beanNames = beanFactory.getBeanNamesForType(ResolvableType.forClassWithGenerics(RepositoryInterface.class, String.class)); assertEquals(1, beanNames.length); assertEquals("stringRepo", beanNames[0]); assertTrue(AopUtils.isJdkDynamicProxy(beanFactory.getBean("stringRepo"))); }
Example #11
Source File: ConfigurationClassPostProcessorTests.java From java-technology-stack with MIT License | 6 votes |
@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]); beanNames = beanFactory.getBeanNamesForType(ResolvableType.forClassWithGenerics(RepositoryInterface.class, String.class)); assertEquals(1, beanNames.length); assertEquals("stringRepo", beanNames[0]); assertTrue(AopUtils.isJdkDynamicProxy(beanFactory.getBean("stringRepo"))); }
Example #12
Source File: ConfigurationClassPostProcessorTests.java From java-technology-stack with MIT License | 6 votes |
@Test public void genericsBasedInjectionWithEarlyGenericsMatchingOnJdkProxy() { 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())); 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]); beanNames = beanFactory.getBeanNamesForType(ResolvableType.forClassWithGenerics(RepositoryInterface.class, String.class)); assertEquals(1, beanNames.length); assertEquals("stringRepo", beanNames[0]); assertTrue(AopUtils.isJdkDynamicProxy(beanFactory.getBean("stringRepo"))); }
Example #13
Source File: ConfigurationClassPostProcessorTests.java From java-technology-stack with MIT License | 6 votes |
@Test public 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); assertTrue(ObjectUtils.containsElement(beanNames, "stringRepo")); beanNames = beanFactory.getBeanNamesForType(ResolvableType.forClassWithGenerics(Repository.class, String.class)); assertEquals(1, beanNames.length); assertEquals("stringRepo", beanNames[0]); beanNames = beanFactory.getBeanNamesForType(ResolvableType.forClassWithGenerics(Repository.class, String.class)); assertEquals(1, beanNames.length); assertEquals("stringRepo", beanNames[0]); assertTrue(AopUtils.isCglibProxy(beanFactory.getBean("stringRepo"))); }
Example #14
Source File: ConfigurationClassPostProcessorTests.java From java-technology-stack with MIT License | 6 votes |
@Test public 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); assertTrue(ObjectUtils.containsElement(beanNames, "stringRepo")); beanNames = beanFactory.getBeanNamesForType(ResolvableType.forClassWithGenerics(Repository.class, String.class)); assertEquals(1, beanNames.length); assertEquals("stringRepo", beanNames[0]); beanNames = beanFactory.getBeanNamesForType(ResolvableType.forClassWithGenerics(Repository.class, String.class)); assertEquals(1, beanNames.length); assertEquals("stringRepo", beanNames[0]); assertTrue(AopUtils.isCglibProxy(beanFactory.getBean("stringRepo"))); }
Example #15
Source File: ConfigurationClassPostProcessorTests.java From java-technology-stack with MIT License | 6 votes |
@Test public 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); assertTrue(ObjectUtils.containsElement(beanNames, "stringRepo")); beanNames = beanFactory.getBeanNamesForType(ResolvableType.forClassWithGenerics(Repository.class, String.class)); assertEquals(1, beanNames.length); assertEquals("stringRepo", beanNames[0]); beanNames = beanFactory.getBeanNamesForType(ResolvableType.forClassWithGenerics(Repository.class, String.class)); assertEquals(1, beanNames.length); assertEquals("stringRepo", beanNames[0]); assertTrue(AopUtils.isCglibProxy(beanFactory.getBean("stringRepo"))); }
Example #16
Source File: ConfigurationClassPostProcessorTests.java From spring-analysis-note with MIT License | 6 votes |
@Test public 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); assertTrue(ObjectUtils.containsElement(beanNames, "stringRepo")); beanNames = beanFactory.getBeanNamesForType(ResolvableType.forClassWithGenerics(Repository.class, String.class)); assertEquals(1, beanNames.length); assertEquals("stringRepo", beanNames[0]); beanNames = beanFactory.getBeanNamesForType(ResolvableType.forClassWithGenerics(Repository.class, String.class)); assertEquals(1, beanNames.length); assertEquals("stringRepo", beanNames[0]); assertTrue(AopUtils.isCglibProxy(beanFactory.getBean("stringRepo"))); }
Example #17
Source File: ConfigurationClassPostProcessorTests.java From spring-analysis-note with MIT License | 6 votes |
@Test public 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); assertTrue(ObjectUtils.containsElement(beanNames, "stringRepo")); beanNames = beanFactory.getBeanNamesForType(ResolvableType.forClassWithGenerics(Repository.class, String.class)); assertEquals(1, beanNames.length); assertEquals("stringRepo", beanNames[0]); beanNames = beanFactory.getBeanNamesForType(ResolvableType.forClassWithGenerics(Repository.class, String.class)); assertEquals(1, beanNames.length); assertEquals("stringRepo", beanNames[0]); assertTrue(AopUtils.isCglibProxy(beanFactory.getBean("stringRepo"))); }
Example #18
Source File: ConfigurationClassPostProcessorTests.java From spring-analysis-note with MIT License | 6 votes |
@Test public 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); assertTrue(ObjectUtils.containsElement(beanNames, "stringRepo")); beanNames = beanFactory.getBeanNamesForType(ResolvableType.forClassWithGenerics(Repository.class, String.class)); assertEquals(1, beanNames.length); assertEquals("stringRepo", beanNames[0]); beanNames = beanFactory.getBeanNamesForType(ResolvableType.forClassWithGenerics(Repository.class, String.class)); assertEquals(1, beanNames.length); assertEquals("stringRepo", beanNames[0]); assertTrue(AopUtils.isCglibProxy(beanFactory.getBean("stringRepo"))); }
Example #19
Source File: ConfigurationClassPostProcessorTests.java From spring-analysis-note with MIT License | 6 votes |
@Test public void genericsBasedInjectionWithEarlyGenericsMatchingOnJdkProxy() { 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())); 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]); beanNames = beanFactory.getBeanNamesForType(ResolvableType.forClassWithGenerics(RepositoryInterface.class, String.class)); assertEquals(1, beanNames.length); assertEquals("stringRepo", beanNames[0]); assertTrue(AopUtils.isJdkDynamicProxy(beanFactory.getBean("stringRepo"))); }
Example #20
Source File: ConfigurationClassPostProcessorTests.java From spring-analysis-note with MIT License | 6 votes |
@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]); beanNames = beanFactory.getBeanNamesForType(ResolvableType.forClassWithGenerics(RepositoryInterface.class, String.class)); assertEquals(1, beanNames.length); assertEquals("stringRepo", beanNames[0]); assertTrue(AopUtils.isJdkDynamicProxy(beanFactory.getBean("stringRepo"))); }
Example #21
Source File: ConfigurationClassPostProcessorTests.java From spring-analysis-note with MIT License | 6 votes |
@Test public 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); assertTrue(ObjectUtils.containsElement(beanNames, "stringRepo")); beanNames = beanFactory.getBeanNamesForType(ResolvableType.forClassWithGenerics(RepositoryInterface.class, String.class)); assertEquals(1, beanNames.length); assertEquals("stringRepo", beanNames[0]); beanNames = beanFactory.getBeanNamesForType(ResolvableType.forClassWithGenerics(RepositoryInterface.class, String.class)); assertEquals(1, beanNames.length); assertEquals("stringRepo", beanNames[0]); assertTrue(AopUtils.isJdkDynamicProxy(beanFactory.getBean("stringRepo"))); }
Example #22
Source File: ConfigurationClassPostProcessorTests.java From spring-analysis-note with MIT License | 6 votes |
@Test public void genericsBasedInjectionWithLateGenericsMatchingOnJdkProxyAndRawInstance() { beanFactory.registerBeanDefinition("configClass", new RootBeanDefinition(RawInstanceRepositoryConfiguration.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]); beanNames = beanFactory.getBeanNamesForType(ResolvableType.forClassWithGenerics(RepositoryInterface.class, String.class)); assertEquals(1, beanNames.length); assertEquals("stringRepo", beanNames[0]); assertTrue(AopUtils.isJdkDynamicProxy(beanFactory.getBean("stringRepo"))); }
Example #23
Source File: JdkProxyControllerTests.java From spring-analysis-note with MIT License | 6 votes |
@SuppressWarnings("serial") private void initServlet(final Class<?> controllerclass) throws ServletException { servlet = new DispatcherServlet() { @Override protected WebApplicationContext createWebApplicationContext(@Nullable WebApplicationContext parent) { GenericWebApplicationContext wac = new GenericWebApplicationContext(); wac.registerBeanDefinition("controller", new RootBeanDefinition(controllerclass)); DefaultAdvisorAutoProxyCreator autoProxyCreator = new DefaultAdvisorAutoProxyCreator(); autoProxyCreator.setBeanFactory(wac.getBeanFactory()); wac.getBeanFactory().addBeanPostProcessor(autoProxyCreator); wac.getBeanFactory().registerSingleton("advisor", new DefaultPointcutAdvisor(new SimpleTraceInterceptor(true))); wac.refresh(); return wac; } }; servlet.init(new MockServletConfig()); }
Example #24
Source File: CglibProxyControllerTests.java From spring-analysis-note with MIT License | 6 votes |
@SuppressWarnings("serial") private void initServlet(final Class<?> controllerClass) throws ServletException { servlet = new DispatcherServlet() { @Override protected WebApplicationContext createWebApplicationContext(@Nullable WebApplicationContext parent) { GenericWebApplicationContext wac = new GenericWebApplicationContext(); wac.registerBeanDefinition("controller", new RootBeanDefinition(controllerClass)); DefaultAdvisorAutoProxyCreator autoProxyCreator = new DefaultAdvisorAutoProxyCreator(); autoProxyCreator.setProxyTargetClass(true); autoProxyCreator.setBeanFactory(wac.getBeanFactory()); wac.getBeanFactory().addBeanPostProcessor(autoProxyCreator); Pointcut pointcut = new AnnotationMatchingPointcut(Controller.class); DefaultPointcutAdvisor advisor = new DefaultPointcutAdvisor(pointcut, new SimpleTraceInterceptor(true)); wac.getBeanFactory().registerSingleton("advisor", advisor); wac.refresh(); return wac; } }; servlet.init(new MockServletConfig()); }
Example #25
Source File: ServletAnnotationControllerHandlerMethodTests.java From spring-analysis-note with MIT License | 6 votes |
@Test public void proxiedFormController() throws Exception { initServlet(wac -> { wac.registerBeanDefinition("viewResolver", new RootBeanDefinition(TestViewResolver.class)); DefaultAdvisorAutoProxyCreator autoProxyCreator = new DefaultAdvisorAutoProxyCreator(); autoProxyCreator.setBeanFactory(wac.getBeanFactory()); wac.getBeanFactory().addBeanPostProcessor(autoProxyCreator); wac.getBeanFactory() .registerSingleton("advisor", new DefaultPointcutAdvisor(new SimpleTraceInterceptor())); }, MyFormController.class); MockHttpServletRequest request = new MockHttpServletRequest("GET", "/myPath.do"); request.addParameter("name", "name1"); request.addParameter("age", "value2"); MockHttpServletResponse response = new MockHttpServletResponse(); getServlet().service(request, response); assertEquals("myView-name1-typeMismatch-tb1-myValue", response.getContentAsString()); }
Example #26
Source File: ConfigurationClassPostProcessorTests.java From java-technology-stack with MIT License | 6 votes |
@Test public void genericsBasedInjectionWithLateGenericsMatchingOnCglibProxy() { 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())); beanFactory.preInstantiateSingletons(); String[] beanNames = beanFactory.getBeanNamesForType(Repository.class); assertTrue(ObjectUtils.containsElement(beanNames, "stringRepo")); beanNames = beanFactory.getBeanNamesForType(ResolvableType.forClassWithGenerics(Repository.class, String.class)); assertEquals(1, beanNames.length); assertEquals("stringRepo", beanNames[0]); beanNames = beanFactory.getBeanNamesForType(ResolvableType.forClassWithGenerics(Repository.class, String.class)); assertEquals(1, beanNames.length); assertEquals("stringRepo", beanNames[0]); assertTrue(AopUtils.isCglibProxy(beanFactory.getBean("stringRepo"))); }
Example #27
Source File: ServletAnnotationControllerTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test @SuppressWarnings("serial") public void proxiedFormController() throws Exception { DispatcherServlet servlet = new DispatcherServlet() { @Override protected WebApplicationContext createWebApplicationContext(WebApplicationContext parent) { GenericWebApplicationContext wac = new GenericWebApplicationContext(); wac.registerBeanDefinition("controller", new RootBeanDefinition(MyFormController.class)); wac.registerBeanDefinition("viewResolver", new RootBeanDefinition(TestViewResolver.class)); DefaultAdvisorAutoProxyCreator autoProxyCreator = new DefaultAdvisorAutoProxyCreator(); autoProxyCreator.setBeanFactory(wac.getBeanFactory()); wac.getBeanFactory().addBeanPostProcessor(autoProxyCreator); wac.getBeanFactory() .registerSingleton("advisor", new DefaultPointcutAdvisor(new SimpleTraceInterceptor())); wac.refresh(); return wac; } }; servlet.init(new MockServletConfig()); MockHttpServletRequest request = new MockHttpServletRequest("GET", "/myPath.do"); request.addParameter("name", "name1"); request.addParameter("age", "value2"); MockHttpServletResponse response = new MockHttpServletResponse(); servlet.service(request, response); assertEquals("myView-name1-typeMismatch-tb1-myValue", response.getContentAsString()); }
Example #28
Source File: BeanMethodPolymorphismTests.java From java-technology-stack with MIT License | 4 votes |
public TestAdvisor() { super(new SimpleTraceInterceptor()); }
Example #29
Source File: BeanMethodPolymorphismTests.java From spring-analysis-note with MIT License | 4 votes |
public TestAdvisor() { super(new SimpleTraceInterceptor()); }
Example #30
Source File: HandlerMethodAnnotationDetectionTests.java From java-technology-stack with MIT License | 4 votes |
public ControllerAdvisor() { super(getControllerPointcut(), new SimpleTraceInterceptor()); }