Aspect-oriented programming (AOP) is a programming model in which the crosscutting
concerns are cut off from the core business logic and moved to a different class, called an aspect.
The cross-cutting concerns that an aspect defines are referred to as advices. You can think of an advice as a method that provides an implementation for a cross-cutting concern. Because advice needs to be applied to a business method,a pointcut expression is used to identify the business methods to which a particular
advice should be applied.
To put it into object-oriented terms, in AOP you create a class called an aspect, and inside it you define methods, called advices, that address cross-cutting concerns. These methods are associated with an expression, called a pointcut expression, that identifies business methods in the application to which the advice should be applied. At runtime, business methods that match the pointcut expression of an advice are
intercepted, and the advice is executed.
In applications, cross-cutting concerns include transaction management, logging, security, and so on. For instance, if you’re using programmatic transaction management in your application, you’ll start the transaction at the beginning of the service method and commit it at the end of the service method. Transaction management isn’t part of the main business logic of the application, so it’s a candidate for AOP
No comments:
Post a Comment