One
1. When the configuration file is XML, the slice class does not write AOP anotation
1 PackageCom.springinaction.springidol;2 3 Public classMagicianImplementsMindReader {4 PrivateString Thoughts;5 6 Public voidInterceptthoughts (String thoughts) {7SYSTEM.OUT.PRINTLN ("Intercepting volunteer ' s Thoughts");8 This. Thoughts =thoughts;9 }Ten One PublicString getthoughts () { A returnthoughts; - } -}
2.
1<?xml version= "1.0" encoding= "UTF-8"?>2<beans xmlns= "Http://www.springframework.org/schema/beans"3Xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance"4xmlns:aop= "HTTP://WWW.SPRINGFRAMEWORK.ORG/SCHEMA/AOP"5Xsi:schemalocation= "Http://www.springframework.org/schema/beans6http//www.springframework.org/schema/beans/spring-beans.xsd7http//WWW.SPRINGFRAMEWORK.ORG/SCHEMA/AOP8http//www.springframework.org/schema/aop/spring-aop.xsd ">9 Ten<bean id= "Volunteer" One class= "Com.springinaction.springidol.Volunteer"/> A<bean id= "Magician" - class= "Com.springinaction.springidol.Magician"/> - the<!--<start id= "Mindreading_aspect"/>--> -<aop:config> -<aop:aspect ref= "Magician" > -<aop:pointcut id= "thinking" +expression= "Execution (* - com.springinaction.springidol.Thinker.thinkOfSomething (String)) +and args (thoughts) "/> A at<Aop:before -Pointcut-ref= "thinking" -Method= "Interceptthoughts" -arg-names= "Thoughts"/> -</aop:aspect> -</aop:config> in<!--<end id= "Mindreading_aspect"/>--> - to</beans>
SPRING in ACTION 4th Edition notes-fourth chapter aspect-oriented spring-009-with Parameters ADVICE2 configuration file is XML