spring-aop-DefaultAdvisorAutoProxyCreator

阅读更多
ProxyFactory:手工编程实现AOP,编程式 添加advice 和 target 以及proxyInterfaces
ProxyFactoryBean: spring 管理,配置interceptorNames,proxyInterfaces,target
DefaultAdvisorAutoProxyCreator:spring 自动发现PointcutAdvisor,根据PointcutAdvisor的 Pointcut 判断是否进行代理


例子:
xml 配置:

   
   
   
      
   
   
   
   
   
      
   
   
   
   
      
      
   
   
   
   
   
     
       com.*login  
     
     
       
     
   
   
   
   
   
     
       login  
     
     
       
     
   
   
   
     


test:

public class LoginServiceImplTest {

	public static void main(String[] args) {
		ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext(
				"classpath:spring/applicationContext.xml");
		LoginService userService = applicationContext.getBean("loginServiceImpl",LoginService.class);
		User user  = new User();
		user.setUsername("xinchun.wang");
		user.setPassword("123456");
		userService.login(user);
		System.out.println(userService.getClass());
	}

你可能感兴趣的:(aop,spring)