cool hit counter Spring - Cut-Oriented Programming AOP (II)_Intefrankly

Spring - Cut-Oriented Programming AOP (II)


In addition to the xml approach to configuring aop, we can also use annotations to configure aop. Here we will look at the annotation-based approach to aop configuration.

Enable @AsjectJ support

In the bean's configuration file, add the following:

Type of notification (5 types)

(1) Before: enhancements are done before the target method is called, @Before just specifies the entry point expression

(2) AfterRETURNING: After the target method completes normally, @AfterReturning can specify a return value in addition to the entry point expression, the return value of the target method

(3) AfterThrowing: mainly used to handle unhandled exceptions in the program, @AfterThrowing, in addition to specifying the entry point expression, can also specify a throwing return value shape-reference name, you can use the shape-reference name to access the object of the exception thrown in the target method

(4) After:Do the enhancement after the target method completes, regardless of when the target method completes successfully. @After can specify a cut-point expression

(5) Around:Wraparound notification, before and after the completion of the target method to do enhanced processing, wrap-around notification is the most important type of notification, like transactions, logs, etc. are wrap-around notification, note that the core of the programming is a ProceedingJoinPoint

A chestnut.

Requirement: add log tracking for employee business interfaces

1.Create the interface EmployeeService

2.Create the interface implementation class EmployeeServiceImpl

3.Create the cutscene class LogggingService

4.bean.xml

5.Test category

6.Implementation results.


Recommended>>
1、GradleForAndroid6 Testing Units
2、The Future of Deep Learning
3、DogFaceRecognition
4、GradleForAndroid1 Starting Gradle with AndroidStudio
5、iOS solves the problem of associative input of Chinese characters which causes the word limit to fail

    已推荐到看一看 和朋友分享想法
    最多200字,当前共 发送

    已发送

    朋友将在看一看看到

    确定
    分享你的想法...
    取消

    分享想法到看一看

    确定
    最多200字,当前共

    发送中

    网络异常,请稍后重试

    微信扫一扫
    关注该公众号