AOP Aspect Oriented Programming

Source: Internet
Author: User

Principle
AOP (Aspect oriented programming) is the technique of aspect-oriented programming. AOP is a useful complement to OOP based on the IOC Foundation.
AOP divides the application system into two parts, the core business logic (concerns) and the general logic of the landscape, the so-called aspect crosscutting enterprise concerns, for example, All medium-to-large applications involve persistent management (persistent), transaction management (Transaction Management), Security Management (safety), log Management (Logging), and debug Management (Debugging).
AOP is becoming the next Halo in software development. With AOP, you can inject code that processes aspect into the main program, and usually the main purpose of the main program is not to handle these aspect. AOP can prevent code clutter.
The Spring framework is a promising AOP technology. As a non-aggressive, lightweight AOP framework, you can use it in a Java program without using a precompiled or other meta tags. This means that only one person in the development team has to deal with the AOP framework, and others are programmed as usual.

AOP Concepts
Let's start by defining some important AOP concepts.
-Aspect (Aspect): A focus of modularity, this focus implementation may be additional crosscutting multiple objects. Transaction management is a good example of crosscutting concerns in the Java EE application. The aspect is implemented with spring's advisor or interceptor.
-Connection point (Joinpoint): an explicit point during program execution, such as a call to a method or a particular exception being thrown.
-Notification (Advice): The action performed by the AOP framework at a specific connection point. Various types of notifications include "around", "before", and "throws" notifications. The notification type is discussed below. Many of the AOP frameworks, including spring, are notification models with interceptors, maintaining a chain of interceptors around the connection point.
-Pointcut (Pointcut): Specifies a collection of connection points to which a notification will be raised. The AOP framework must allow developers to specify pointcuts, for example, using regular expressions.
-Introduced (Introduction): Adds a method or field to the class being notified. Spring allows the introduction of new interfaces to any notified object. For example, you can simplify caching by using an introduction that enables any object to implement the IsModified interface.
-target object: The object that contains the connection point, also known as the notified or Proxied object.
-AOP Agent (AOP proxy): An object created by the AOP framework that contains notifications. In spring, an AOP proxy can be either a JDK dynamic agent or a cglib proxy.
-Weaving (Weaving): Assembling aspects to create a notified object. This can be done at compile time (for example, with the ASPECTJ compiler), or at run time. Spring, like other pure Java AOP frameworks, completes weaving at run time.

AOP Aspect Oriented Programming

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.