Notification (Advice) is a section (Aspect) Spring offer. But its function is too simple: Only cut woven into all target a target class, unable to complete the cut woven into the target method.
Consultant (Advisor) is another section that Spring provides. It can complete more complex aspect weaving function. PointcutAdvisor is a consultant, you can specify a specific entry point. The notification packaging consultant, will be based on different types of notifications, at different points in time, will cut woven into different entry points.
PointcutAdvisor interface has two more common implementation class:
NameMatchMethodPointcutAdvisor names matching the entry point Consultant
RegexpMethodPointcutAdvisor regular expression matching the entry point Consultant
First, the name of the entry point matching method consultants
NameMatchMethodPointcutAdvisor, that is the name of the entry point matching method adviser. The container may be set starting point method specified in the profile name.
Without modifying the code, only registering a consultant in the configuration file, then notify property advice and the starting point of the method name mappedName configure it. Acting in the section, you can use this consultant .
1, the entity class method
2, implementing entity class
3, inheritance MethodBeforeAdvice, AfterReturningAdvice achieve the afterReturning (front) and before (rear)
4, write applictionContext.xml, bean tag
5, the test class
6 results
Second, regular consultants ( Advisor)
RegexpMethodPointcutAdvisor, that is, the regular expression method adviser. The container may be an entry point provided regular expression.
Note that the regular expression matching object is the name of the interface method, rather than a target class (the class that implements the interface) name.
It is the way of the full name, such as com.lmm.aop10.SomeServiceImpl.doFirst, rather than matching doFirst
1, the entity class method
2, implementing entity class
3, inheritance MethodBeforeAdvice, AfterReturningAdvice achieve the afterReturning (front) and before (rear)
4, write applictionContext.xml, bean tag
result