Search in sources :

Example 26 with DefaultAdvisorAutoProxyCreator

use of org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator in project spring-framework by spring-projects.

the class HandlerMethodAnnotationDetectionTests method setUp.

private void setUp(Class<?> controllerType, boolean useAutoProxy) {
    GenericWebApplicationContext context = new GenericWebApplicationContext();
    context.registerBeanDefinition("controller", new RootBeanDefinition(controllerType));
    context.registerBeanDefinition("handlerMapping", new RootBeanDefinition(RequestMappingHandlerMapping.class));
    context.registerBeanDefinition("handlerAdapter", new RootBeanDefinition(RequestMappingHandlerAdapter.class));
    context.registerBeanDefinition("exceptionResolver", new RootBeanDefinition(ExceptionHandlerExceptionResolver.class));
    if (useAutoProxy) {
        DefaultAdvisorAutoProxyCreator autoProxyCreator = new DefaultAdvisorAutoProxyCreator();
        autoProxyCreator.setBeanFactory(context.getBeanFactory());
        context.getBeanFactory().addBeanPostProcessor(autoProxyCreator);
        context.registerBeanDefinition("controllerAdvice", new RootBeanDefinition(ControllerAdvisor.class));
    }
    context.refresh();
    this.handlerMapping = context.getBean(RequestMappingHandlerMapping.class);
    this.handlerAdapter = context.getBean(RequestMappingHandlerAdapter.class);
    this.exceptionResolver = context.getBean(ExceptionHandlerExceptionResolver.class);
    context.close();
}
Also used : DefaultAdvisorAutoProxyCreator(org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator) RootBeanDefinition(org.springframework.beans.factory.support.RootBeanDefinition) GenericWebApplicationContext(org.springframework.web.context.support.GenericWebApplicationContext)

Example 27 with DefaultAdvisorAutoProxyCreator

use of org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator in project druid by alibaba.

the class DruidSpringAopConfiguration method advisorAutoProxyCreator.

@Bean
@ConditionalOnProperty(name = "spring.aop.auto", havingValue = "false")
public DefaultAdvisorAutoProxyCreator advisorAutoProxyCreator() {
    DefaultAdvisorAutoProxyCreator advisorAutoProxyCreator = new DefaultAdvisorAutoProxyCreator();
    advisorAutoProxyCreator.setProxyTargetClass(true);
    return advisorAutoProxyCreator;
}
Also used : DefaultAdvisorAutoProxyCreator(org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator) Bean(org.springframework.context.annotation.Bean) ConditionalOnProperty(org.springframework.boot.autoconfigure.condition.ConditionalOnProperty)

Aggregations

DefaultAdvisorAutoProxyCreator (org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator)27 SimpleTraceInterceptor (org.springframework.aop.interceptor.SimpleTraceInterceptor)16 DefaultPointcutAdvisor (org.springframework.aop.support.DefaultPointcutAdvisor)16 RootBeanDefinition (org.springframework.beans.factory.support.RootBeanDefinition)15 Bean (org.springframework.context.annotation.Bean)9 Test (org.junit.jupiter.api.Test)8 DependsOn (org.springframework.context.annotation.DependsOn)7 GenericWebApplicationContext (org.springframework.web.context.support.GenericWebApplicationContext)6 ShiroFilterFactoryBean (org.apache.shiro.spring.web.ShiroFilterFactoryBean)5 Test (org.junit.Test)3 MockHttpServletRequest (org.springframework.mock.web.test.MockHttpServletRequest)3 MockHttpServletResponse (org.springframework.mock.web.test.MockHttpServletResponse)3 PathPatternsParameterizedTest (org.springframework.web.servlet.handler.PathPatternsParameterizedTest)3 MockHttpServletRequest (org.springframework.web.testfixture.servlet.MockHttpServletRequest)3 MockHttpServletResponse (org.springframework.web.testfixture.servlet.MockHttpServletResponse)3 WebApplicationContext (org.springframework.web.context.WebApplicationContext)2 DispatcherServlet (org.springframework.web.servlet.DispatcherServlet)2 MockServletConfig (org.springframework.web.testfixture.servlet.MockServletConfig)2 HttpSession (jakarta.servlet.http.HttpSession)1 Map (java.util.Map)1