"Java EE Spring" 14, the concept of AOP

Source: Internet
Author: User

The concepts in AOP

1) Facets (Aspect): Refers to the cross-business logic collectively, such as logs, transactions, security;
2) Notice (Advice): refers to the specific implementation of the plane;
3) connection point (Joinpoint): Refers to the plane can be woven into (applied to) the target object position (level), two: Method/property Proxy mode, called the proxy object, the agent maintains a target object properties; Before invoking the method, write the log first; Then call the concrete implementation method; Before calling properties, intercept to do the processing, rarely used; Spring does not support this at this time;
4) Pointcut (Pointcut): Refers to which methods or properties of the target object that the notification (the specific implementation of the slice) is applied to; Org.springframework.aop.PointcutSpring defines the pointcut according to the class name and method name, which indicates the timing of advice weaving into the application;
5) Introduction (Introduction): Refers to the dynamic process of adding methods or attributes to an object; it is a special kind of notice;
6) Weaving (weaving): the process of applying facets (notifications) to the target object generation agent;
7) Proxy object (proxy): The target object applies the agent generated after the slice (the new proxy object generated after the slice is woven into the plane);
8) Target object: the implementation of the specific business logic (objects that need to be woven into the plane);

Http://zhidao.baidu.com/link?url=xdWJL948zjOJ1Yfm4EZn81RkLhI1WSjBKGlF40c_n7pa0V6PT8zK9dWk44Rp0KnfQvwospBiC8wLhR3x_60hXK

Again, AOP, or the above example.
For example, if you want to check your pen for ink before each writing, it is common practice to call the method that determines whether there is ink in the action of writing. One aspect of doing this is that the action of writing and whether there is ink are dependent, and if you have more than 10 different pens to write, every action in the pen should invoke the method of judging whether there is ink, and the other is: in terms of object-oriented programming, The method of writing and judging whether there is ink is the same level, if you let write this action to judge whether there is ink is not human, it is contrary to the idea of object-oriented program design.
If you use spring's AOP, it is to write the action as a facet, before each call different pen to write the method, call to determine whether there is ink method. It is defined by the label in the spring configuration file, in the form of:




Here, Com.baidu.dao all the way to the beginning of the write to do a tangent, do the operation is to do with the following pointcut-ref= "Allmanagermethod" to define.

Execution (* j3t10.dao.userdao.* (..))
The first * number above indicates any of the return value types. The second asterisk represents an arbitrary method in the Userdao class. (..) Represents any of the method parameters.
Execution (* com.baidu.dao.write* (..))
The return type is unlimited, all methods under the Com.baidu.dao.write package, unlimited parameters

Http://zhidao.baidu.com/link?url=pohGuU1u5Pa4Ky9LyK5x4Z5Kb_DzFq-5IPzm9d6rRRtANJUow-Nag12nox0-rCsbabVTZivNeijOrGqzhJxkU_

"Java EE Spring" 14, the concept of AOP

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.