Spring配置文件applicationContext.xml(2)之AOP

  1. AOP的xml版本
  2. <?xml version="1.0" encoding="UTF-8"?>   
  3. <beans   
  4. xmlns="http://www.springframework.org/schema/beans"  
  5. xmlns  si="http://www.w3.org/2001/XMLSchema-instance"  
  6. xmlns:context="http://www.springframework.org/schema/context"  
  7. xmlns:aop="http://www.springframework.org/schema/aop"  
  8. xsi:schemaLocation="http://www.springframework.org/schema/beans   
  9. http://www.springframework.org/schema/beans/spring-beans-2.5.xsd   
  10. http://www.springframework.org/schema/aop   
  11. http://www.springframework.org/schema/aop/spring-aop-2.5.xsd   
  12. http://www.springframework.org/schema/context   
  13. http://www.springframework.org/schema/context/spring-context-2.5.xsd   
  14. ">   
  15.   
  16. <aop:aspectj-autoproxy></aop:aspectj-autoproxy>   
  17.   
  18. <bean id="personService"></bean>   
  19. <bean id="aspectBean"></bean>   
  20.   
  21. <aop:config>   
  22. <aop:aspect id="myaop" ref="aspectBean">   
  23. <aop:pointcut id="mycut" expression="execution(* com.persia.service.impl.PersonServiceImpl.*(..))"/>   
  24. <aop:pointcut id="argcut" expression="execution(* com.persia.service.impl.PersonServiceImpl.*(..)) and args(name)"/>   
  25. <aop:before pointcut-ref="mycut" method="doAccessCheck"  />   
  26. <aop:after-returning pointcut-ref="mycut" method="doAfterReturning"/>   
  27. <aop:after-throwing pointcut-ref="mycut" method="doThrowing"/>   
  28. <aop:after pointcut-ref="argcut" method="doAfter" arg-names="name"/>   
  29. <aop:around pointcut-ref="mycut" method="arround"/>   
  30. </aop:aspect>   
  31.   
  32. </aop:config>   
  33.   
  34. </beans>
相關文章
相關標籤/搜索