spring study day 8 (advisor)

1. About a mistake before: aop output sequence, in fact, the official documents did not say whether the output of the writing order, you may have inside 1000 800 sequentially outputs 200 random output. <Aop: aspect> order attribute has a smaller value of the first output.

2.Advisor: notifier, or have a certain type of notification aspect classes

Such notifications are implemented by specific interfaces certain represented. 
Spring following interfaces to indicate different types of notifications
the MethodBeforeAdvice: Front notify
the AfterReturningAdvice: Returns the notification
ThrowsAdvice: abnormality notification
MethodInterceptor: Surround notification
Note: no final notification (after notification)

advisor such an approach is no longer recommended, mainly older version of a spring arrangement, but spring transaction configuration used in this method

<aop:config><aop:pointcut><aop:advisor></aop:config>

java code, respectively, to achieve mainly four kinds of interfaces:

MethodBeforeAdvice Front
AfterReturningAdvice return
MethodInterceptor surrounded (rewrite invoke method, there are two interfaces with the same name)
ThrowsAdvice throw

ThrowsAdvice is an empty interface, but it has a method signature requirements

Abnormality notification interface is empty interface 
signature method must be *:
* 1 The return type is void
* 2. The method afterThrowing name
* 3. The method parameters may be
* 3.1 Method method, Object [] args, Object target ( receiving show All exceptions)
* 3.2 or Method method, Object [] args, Object target, exception classes (represented only accept one definition of abnormality)

Guess you like

Origin www.cnblogs.com/woyujiezhen/p/11761512.html