..


Sponsored Links

AOP - Aspect-Oriented Programming Overview

The aspect-oriented programming (Aspect-Oriented Programming, or, more briefly, AOP) is another way of seeing the design of software.
Instead of programming that is focused on the objects (Object-Oriented Programming - OOP), where the main element is the class, everything is based on the AOP aspect.

One aspect is a modularization of a cross-sectional report across multiple classes, ie a module that contains several classes that have a common interest (such as transaction management).
In addition there are other concepts to the aspect on which the AOP:

  • Join point: a point of running a program, such as executing a method.
  • advice: it's been going from one aspect the action in a given join point.
  • pointcut: it is written through a predicate expression that binds a join point in a advice, that advice is executed when a pointcut matches a join a point. For example, suppose that a class has the method doSomething (), the execution of the method is the join points, pointcuts and instead might be an expression such as "before the execution of the method doSomething ()".
  • Target object: they are the objects on which the advice is executed.
  • introduction: a attraveso introdutction you can add new interfaces, and thus new methods to target object.
  • AOP proxy is the object that is created dall'AOP framework to implement the advice and the execution.
  • weaving: the process that binds the various aspect advice to create the target object. Usually this process takes place at runtime.

The advice can be of various types:

  • advice before: they are the advice that run before a join point, for example, before execution of a method. They can not stop the flow execution unless casts no exception.
  • after returning advice: advice are the ends that are executed when a join point in a normal way, ie without throwing exceptions.
  • after throwing advice: they are the advice that is executed when a join point terminates abnormally, ie throwing an exception.
  • after advice: it is the advice that is executed when a join point finishes in ways both normal and abnormally.
  • Around advice: advice are the most powerful and are executed before and after a join point. Through this kind of advice you can stop the execution flow, for example by preventing the execution of a method, change its return value or throws an exception.

In Spring the joins are only supported point of the implementation of a method, then Spring AOP does not offer a complete implementation period, however, sufficient to solve the most common enterprise applications.

To implement the functionality of each target object is AOP Wrap in a proxy that exposes the same interfaces that the object implements. By default we use the J2SE dynamic proxies, but allow only proxied interfaces or set of interfaces.
The proxies of CGLIB instead are used when an object does not implement interfaces, they can force the use in the rare cases where you have to create a pointcut on a method that is not exposed in the interface.

Spring Java Guide
E-Learning
Linux (Course) Linux (Course)
Complete guide to open-source system. From 49 €.
PHP (Course) PHP (Course)
Full course for creating dynamic Web sites. From 49 €.
Ruby and Ruby on Rails (Course) Ruby and Ruby on Rails (Course)
Create software and Web applications with Ruby and RoR. From 39 €.
Sponsored Links