AOP Study Notes

Source: Internet
Author: User

Work Involved in the AOP Development Process:

1. Extract the concerns in the system (extract the cross-cutting concerns and general concerns)
Separate core module-level attention points and system-level cross-cutting concerns

Common cross-cutting concerns in the system:
Logs
Security
Permission Verification
Synchronization
Performance monitoring
Thread Security
Protocol Verification
Cache Management
Memory Management

...
2. Independent Development for cross-cutting concerns

3. Set the position (configuration) of the connection points of the focus in the AOP framework)

4. The AOP framework automatically adds the module focus to the specified connection point to complete the final system.

5. Notification (advice) specification and configuration of braided Information

Waver is the key to implementing AOP and describes the overall development strategy.
The strength of AOP lies in the convenience of re-combining the system according to the weaving rules.
For example, some weaving rules can add logs to all public methods of all classes in the system, and can specify public methods for the specified class.

Interaction process between the AOP framework and the original business system:
When you enable AOP, the AOP framework is woven and loaded to the original Business System Based on the configuration information.
After the business system is started, AOP no longer controls it, and the user interaction will still be performed in the original business system.

Note: Due to the introduction of AOP, the system startup process will take a little longer to start the business system because AOP needs to load configuration information and weave the configuration information.

AOP mainly implements two functions:
1. initialize the framework, including configuration information management, aspect management, connection point management, and introduction management.
2. Start the original business system, including configuration information weaving and startup management.

Myaop framework: Framework Function Structure
|
| --- Configuration information management: configuration information management (AOP provides the function of dynamically configuring the attention points and connection points, that is, every time you change the configuration file, you do not need to re-compile all the class files, using annotation, XML)
| --- Notic management: Notification Management
-1. AOP must support three types of notifications: before, after, and around. Before is the operation performed before the connection point, and after is the operation performed before the connection point, replace or skip the connection point operation
-2. To ensure interaction with the original system after the aspect separation, all three types of notifications need to obtain multiple types of connection information in the original system through parameter transmission, such as the parameter type and value of the connection point and the Method Name of the connection point.
-3. AOP provides a notification interface for developers to implement cross-cutting concerns.
| --- Aspect management: manages all aspects of AOP. this is a collection of all notifications added to a connection point. when other connection points use the same function, you only need to add this aspect to the connection point.
| --- Connection point management: connection point management
-According to the current OOP features, AOP supports three types of connection points: method, constructor, and field.
-AOP supports adding multiple notifications to the same connection point. all notifications added to the connection point are executed in sequence, and you can control the notification Execution Process-instead of or skip the notifications to be executed later.
| --- Introduction Management: The introduction management is used to solve the problem of Mixed Inheritance of classes in OOP and change the current single inheritance so that a class can have more than two parent classes. you can add multiple mixins for each introduction to implement hybrid inheritance.
| --- Waver handle: knitting
-1. AOP provides dynamic weaving, and the weaving results cannot change the original system. Code . When the original system is out of AOP, it only lacks the AOP function provided by AOP and can still run normally.
-2. After weaving, no new Source code File. Because of the way code files are woven, the process of code generation and compilation will verify the impact on the running speed.
-3. The configuration information of the weaving process can be dynamically modified. You do not need to recompile the entire AOP framework and original business system every time you change the weaving rules.
| --- Setup management: Launch management, mainly responsible for loading and starting the original Business System

Core Part of AOP-Weaving Technology:

The important part is the knitting timing and implementation strategy.
1. The choice of weaving timing determines the robustness and scalability of the framework.

The Knitting Operation can take place in the following stages:

Compile time: During source code compilation, a special compiler allows us to specifyProgramAnd generates compiled applications based on these rules.
For common applications, it is the most intuitive way to perform weaving operations during compilation. Because the source program contains all the information of the application, this method usually supports the most class connection points.
With compilation knitting, we can use the AOP System for fine-grained weaving operations, such as reading or writing fields. A module formed after source code compilation will cause a lot of information, so we usually use
The coarse-grained AOP method. at the same time, for traditional languages that have compiled into local code, such as C ++ and FORTRAN, the compiled modules are often related to the operating system platform.
Compilation, loading, and runtime knitting machine manufacturing became difficult. for languages with compilation costs, it is most feasible to compile code only during compilation. although compiling has powerful functions,
It has a wide range of advantages, but its shortcomings are also obvious. First of all, it requires programmers to provide all the source code. Therefore, modular projects cannot be used. All modules can be provided in real time
Source code. It also causes disadvantages such as the program's inability to perform incremental compilation and slow Compilation Time.

After compilation: The compiled program modules are woven according to the knitting rules.
To meet the requirements of Modular programming, some AOP frameworks start to support the post-compilation knitting function. Programmers only need to obtain the modules after compilation to perform the weaving operation. In aspnetj
The main logic part of the program can be woven after being a module, and the main logic part can be compiled using the normal javac.
The requirement is that all program modules are compiled using aspectc. It can be seen that using a virtual machine-based language like Java is advantageous for compiling AOP programs.

During loading: knitting during loading of program modules
Although post-compilation knitting has solved the issue of AOP knitting when all source code cannot be obtained, in this popular framework era, we need to arrange our knitting operations more flexibly. If the program
The main logical part and aspect of JBoss are developed as different components, so the most reasonable knitting time is when the framework is loaded. Therefore, we can see that JBoss and spring both provide such
. During the weaving during loading, the results after the weaving operation will not be saved. the main logic and aspects of the program can be developed and compiled separately, and the Knitting Operation is
Loading occurred. aspectj, spring, and JBoss support knitting during loading. in the AOP Implementation of spring and JBoss, the framework is started before the application, and the framework is responsible for the weaving operation. in aspcetc,
A special class loader is used for this purpose. This class loader can be easily embedded into the framework application to provide AOP support for any framework.

Runtime: during runtime, the objects and aspects in the program are woven according to the running conditions.
Runtime knitting may be the most flexible in all knitting methods. During the running process, the program can specify whether to weave specific aspects for a single object. in the JBoss project, use the features of runtime knitting
Completed the JBoss cache project. in JBoss cache, if an object is placed in the cache, its status is monitored by cache AOP and its status is automatically synchronized to a distributed cache.
If this object does not need to be cached, it has no relationship with AOP. modifications to it will not lead to cache synchronization operations. It is worth mentioning that, although aspectj does not explicitly provide the runtime knitting capability
In aspnetj, you can use a simple pattern to implement runtime knitting.

The AOP implementation strategy currently has the following types:
1. javase dynamic code technology
2. Dynamic bytecode Generation Technology
3. Java code generation technology
4. Custom class loading technology
5. Language extension technology

Current Knitting Operation opportunities supported by several mainstream AOP Systems
Aspectj Spring AOP JBoss AOP aspectc
Compile time √
Post compile time √
Load Time √
Run Time √

Dynamic Weaving, il weaving, XML, compilation, and attribute metadata

AOP engine setpoint
setpoint is a type. net all function (full-featured) AOP engine. it focuses on the use of the definitions that depend on RDF/OWL, called semantic pointcuts. its function is an IL-level, highly dynamic Weaver & Lendl, a compelling definition language
project Home Page: http://setpoint.codehaus.org/
document address: http://setpoint.codehaus.org/Tutorials
download address : http://setpoint.codehaus.org/Downloads

AOP engine dotnetaop
Dotnetaop provides the AOP framework for CLR LanguageBasicAttribute.

AOP framework naop
Project home: http://sourceforge.net/projects/aopnet/
: Http://sourceforge.net/projects/aopnet/files

AOP framework aspectsharp
Aspectsharp is a free AOP framework under DOTNET. It uses dynamic proxies and XML as ConfigurationFile.
Project home: http://sourceforge.net/projects/aspectsharp/
: Http://sourceforge.net/projects/aspectsharp/files/

AOP framework encase
encase is C # compile development is. net platform provides the AOP framework. The unique encase provides deployment of the aspect (Aspects) to the runtime Code , other AOP frameworks depend on configuration files. This deployment (Aspects) method helps developers who lack experience to improve development efficiency.
Project homepage: http://theagiledeveloper.com/articles/Encase.aspx

C # AOP framework nkalore
Nkalore isProgramming LanguageIt extends C # to allow the use of AOP on the. NET platform. Nkalore's syntax is simple and intuitive.CompileIs based on the mono C # Compiler (MCS ). Nkalore can only beCommandLine or # develop internal use. Nkalore is compatible with common language specification (CLS), which can be developed in any. netEnvironment, IncludingMicrosoftOfVisual Studio. Net.
Project home: http://aspectsharpcomp.sourceforge.net/
: Http://aspectsharpcomp.sourceforge.net/download.htm

Postsharp
Postsharp reads the. NET byte module and converts itObject Model. Let Plug-ins Analyze and convert the model and write it back to msil.
Postsharp Development Program Analysis Application Programs are easy to analyze Code rules and Design Mode It transforms the idea of program development into an aspect-oriented Software Development (AOSD/AOD) ideology.
Postsharp is a tool that can reduce the number of lines of code in all major Microsoft. net versions and improve its logical decoupling. therefore its helps you delivering higher stability, cleaner design, and cheaper source code maintenance.
Project home: http://www.postsharp.org/
: Http://www.postsharp.org/download

Work Involved in the AOP Development Process:

1. Extract the concerns in the system (extract the cross-cutting concerns and general concerns)
Separate core module-level attention points and system-level cross-cutting concerns

Common cross-cutting concerns in the system:
Logs
Security
Permission Verification
Synchronization
Performance monitoring
Thread Security
Protocol Verification
Cache Management
Memory Management

...
2. Independent Development for cross-cutting concerns

3. Set the position (configuration) of the connection points of the focus in the AOP framework)

4. The AOP framework automatically adds the module focus to the specified connection point to complete the final system.

5. Notification (advice) specification and configuration of braided Information

Waver is the key to implementing AOP and describes the overall development strategy.
The strength of AOP lies in the convenience of re-combining the system according to the weaving rules.
For example, some weaving rules can add logs to all public methods of all classes in the system, and can specify public methods for the specified class.

Interaction process between the AOP framework and the original business system:
When you enable AOP, the AOP framework is woven and loaded to the original Business System Based on the configuration information.
After the business system is started, AOP no longer controls it, and the user interaction will still be performed in the original business system.

Note: Due to the introduction of AOP, the system startup process will take a little longer to start the business system because AOP needs to load configuration information and weave the configuration information.

AOP mainly implements two functions:
1. initialize the framework, including configuration information management, aspect management, connection point management, and introduction management.
2. Start the original business system, including configuration information weaving and startup management.

Myaop framework: Framework Function Structure
|
| --- Configuration information management: configuration information management (AOP provides the function of dynamically configuring the attention points and connection points, that is, every time you change the configuration file, you do not need to re-compile all the class files, using annotation, XML)
| --- Notic management: Notification Management
-1. AOP must support three types of notifications: before, after, and around. Before is the operation performed before the connection point, and after is the operation performed before the connection point, replace or skip the connection point operation
-2. To ensure interaction with the original system after the aspect separation, all three types of notifications need to obtain multiple types of connection information in the original system through parameter transmission, such as the parameter type and value of the connection point and the Method Name of the connection point.
-3. AOP provides a notification interface for developers to implement cross-cutting concerns.
| --- Aspect management: manages all aspects of AOP. this is a collection of all notifications added to a connection point. when other connection points use the same function, you only need to add this aspect to the connection point.
| --- Connection point management: connection point management
-According to the current OOP features, AOP supports three types of connection points: method, constructor, and field.
-AOP supports adding multiple notifications to the same connection point. all notifications added to the connection point are executed in sequence, and you can control the notification Execution Process-instead of or skip the notifications to be executed later.
| --- Introduction Management: The introduction management is used to solve the problem of Mixed Inheritance of classes in OOP and change the current single inheritance so that a class can have more than two parent classes. you can add multiple mixins for each introduction to implement hybrid inheritance.
| --- Waver handle: knitting
-1. AOP provides dynamic weaving, and the weaving result cannot change the code of the original system. When the original system is out of AOP, it only lacks the AOP function provided by AOP and can still run normally.
-2. do not generate new source code files after weaving. Because the code file weaving method is generated, the code generation and compilation process will verify that the running speed is affected.
-3. The configuration information of the weaving process can be dynamically modified. You do not need to recompile the entire AOP framework and original business system every time you change the weaving rules.
| --- Setup management: Launch management, mainly responsible for loading and starting the original Business System

Core Part of AOP-Weaving Technology:

The important part is the knitting timing and implementation strategy.
1. The choice of weaving timing determines the robustness and scalability of the framework.

The Knitting Operation can take place in the following stages:

Compile time: During source code compilation, special compilers allow us to specify various aspects of the Program for weaving rules in some way and generate compiled applications based on these rules.
For common applications, it is the most intuitive way to perform weaving operations during compilation. Because the source program contains all the information of the application, this method usually supports the most class connection points.
With compilation knitting, we can use the AOP System for fine-grained weaving operations, such as reading or writing fields. A module formed after source code compilation will cause a lot of information, so we usually use
The coarse-grained AOP method. at the same time, for traditional languages that have compiled into local code, such as C ++ and FORTRAN, the compiled modules are often related to the operating system platform.
Compilation, loading, and runtime knitting machine manufacturing became difficult. for languages with compilation costs, it is most feasible to compile code only during compilation. although compiling has powerful functions,
It has a wide range of advantages, but its shortcomings are also obvious. First of all, it requires programmers to provide all the source code. Therefore, modular projects cannot be used. All modules can be provided in real time
Source code. It also causes disadvantages such as the program's inability to perform incremental compilation and slow Compilation Time.

After compilation: The compiled program modules are woven according to the knitting rules.
To meet the requirements of Modular programming, some AOP frameworks start to support the post-compilation knitting function. Programmers only need to obtain the modules after compilation to perform the weaving operation. In aspnetj
The main logic part of the program can be woven after being a module, and the main logic part can be compiled using the normal javac.
The requirement is that all program modules are compiled using aspectc. It can be seen that using a virtual machine-based language like Java is advantageous for compiling AOP programs.

During loading: knitting during loading of program modules
Although post-compilation knitting has solved the issue of AOP knitting when all source code cannot be obtained, in this popular framework era, we need to arrange our knitting operations more flexibly. If the program
The main logical part and aspect of JBoss are developed as different components, so the most reasonable knitting time is when the framework is loaded. Therefore, we can see that JBoss and spring both provide such
. During the weaving during loading, the results after the weaving operation will not be saved. the main logic and aspects of the program can be developed and compiled separately, and the Knitting Operation is
Loading occurred. aspectj, spring, and JBoss support knitting during loading. in the AOP Implementation of spring and JBoss, the framework is started before the application, and the framework is responsible for the weaving operation. in aspcetc,
A special class loader is used for this purpose. This class loader can be easily embedded into the framework application to provide AOP support for any framework.

Runtime: during runtime, the objects and aspects in the program are woven according to the running conditions.
Runtime knitting may be the most flexible in all knitting methods. During the running process, the program can specify whether to weave specific aspects for a single object. in the JBoss project, use the features of runtime knitting
Completed the JBoss cache project. in JBoss cache, if an object is placed in the cache, its status is monitored by cache AOP and its status is automatically synchronized to a distributed cache.
If this object does not need to be cached, it has no relationship with AOP. modifications to it will not lead to cache synchronization operations. It is worth mentioning that, although aspectj does not explicitly provide the runtime knitting capability
In aspnetj, you can use a simple pattern to implement runtime knitting.

The AOP implementation strategy currently has the following types:
1. javase dynamic code technology
2. Dynamic bytecode Generation Technology
3. Java code generation technology
4. Custom class loading technology
5. Language extension technology

Current Knitting Operation opportunities supported by several mainstream AOP Systems
Aspectj Spring AOP JBoss AOP aspectc
Compile time √
Post compile time √
Load Time √
Run Time √

Dynamic Weaving, il weaving, XML, compilation, and attribute metadata

AOP engine setpoint
setpoint is a type. net all function (full-featured) AOP engine. it focuses on the use of the definitions that depend on RDF/OWL, called semantic pointcuts. its function is an IL-level, highly dynamic Weaver & Lendl, a compelling definition language
project Home Page: http://setpoint.codehaus.org/
document address: http://setpoint.codehaus.org/Tutorials
download address : http://setpoint.codehaus.org/Downloads

AOP engine dotnetaop
Dotnetaop provides the AOP framework for CLR LanguageBasicAttribute.

AOP framework naop
Project home: http://sourceforge.net/projects/aopnet/
: Http://sourceforge.net/projects/aopnet/files

AOP framework aspectsharp
Aspectsharp is a free AOP framework under DOTNET. It uses dynamic proxies and XML as ConfigurationFile.
Project home: http://sourceforge.net/projects/aspectsharp/
: Http://sourceforge.net/projects/aspectsharp/files/

AOP framework encase
encase is C # compile development is. net platform provides the AOP framework. The unique encase provides deployment of the aspect (Aspects) to the runtime Code , other AOP frameworks depend on configuration files. This deployment (Aspects) method helps developers who lack experience to improve development efficiency.
Project homepage: http://theagiledeveloper.com/articles/Encase.aspx

C # AOP framework nkalore
Nkalore is a programming language that extends C # to allow the use of AOP on the. NET platform. Nkalore's syntax is simple and intuitive.CompileIs based on the mono C # Compiler (MCS ). Nkalore can only beCommandLine or # develop internal use. Nkalore is compatible with common language specification (CLS), which can be developed in any. netEnvironment, IncludingMicrosoftOfVisual Studio. Net.
Project home: http://aspectsharpcomp.sourceforge.net/
: Http://aspectsharpcomp.sourceforge.net/download.htm

Postsharp
Postsharp reads the. NET byte module and converts itObject Model. Let Plug-ins Analyze and convert the model and write it back to msil.
Postsharp Development Program Analysis Application Programs are easy to analyze Code rules and Design Mode It transforms the idea of program development into an aspect-oriented Software Development (AOSD/AOD) ideology.
Postsharp is a tool that can reduce the number of lines of code in all major Microsoft. net versions and improve its logical decoupling. therefore its helps you delivering higher stability, cleaner design, and cheaper source code maintenance.
Project home: http://www.postsharp.org/
: Http://www.postsharp.org/download

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.