Framework application: Spring FRAMEWORK-AOP Technology

Source: Internet
Author: User

Basic Concepts

Method Stacks in Threads

    

When the Java program virtual machine starts, the program code is loaded, and the virtual machines generates into a method call stack for each running line, and the thread runs as the execution unit in the method.

AOP Concepts and goals

AOP is aspect-oriented programming, which actually embeds some other code in your module without modifying the code module.

  The goal is to unify the modules to extract and eliminate some of the blocky code scattered in the system (non-logical business).

AOP Terminology diagram

Connection point: Is the method of all threads and can be used as a candidate for embedding code;

Entry point: The last object to be selected as an embedded code;

Facets: implementation of embedded objects;

Enhanced Notifications: Embedded content (some defined methods, including pre-notification, post-notification, exception notification, final notification, surround notification)

Weaving: The entire process of embedding code is called weaving

AOP Principles

The advent of AOP is the presence of some non-business code embedded in the business code, such as a log notification, such as a connection to a database.

  

1. Modify the source code, over-coupling unrelated business code;

2. Whether the use of inheritance or interface implementation to add unrelated business code, the object will be over-coupling between objects;

3. Using dynamic Proxy mode to implement AOP, let the container to help us embed code.

AOP Usage Parsing

1. Importing jar packages (including core packages and AOP packages)

    

2. Create a spring core configuration file and import AOP constraints

    

3. Configure the Bean object, inject into the container, and configure the tangent and tangent points

    

Note: Commonly used expressions

Execution (< access modifier >?< return type >< method name > (< parameter >) < exception >)

(1)Execution (* com.harry.aop.service.UserService.add (..))

(2)Execution (* com.harry.aop.service.userservic.* (..))

(3)Execution (* * * * (..))

(4) match all methods of Save start Execution (* save* (..))

  

Framework application: Spring FRAMEWORK-AOP Technology

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.