Pages Navigation Menu

Coding is much easier than you think

Aspect Oriented Programming(AOP)

Aspect Oriented Programming(AOP)


AOP is one of the main features available in spring that facilitate Cross-cutting of concerns. AOP is another way of organizing the program structure, that complements the OOP. The modularity is implemented in OOP using class, whereas in AOP aspect takes up the job. Aspects enable the modularization of concerns such as transaction management that cut across multiple types and objects. Spring IOC container does not depend upon AOP. That is, using of AOP is totally up to the requirements at hand.

AOP concepts/terminologies


  • ASPECT The cross-cutting functionality is implemented in Spring through Aspect. It can be defined either in Schema based or annotation based configuration. It contains a ‘point-cut’€™ and ‘€˜advice body’€™.
  • JOIN POINT A particular point during the execution of a program where the cross cutting happens and some action is taken. In spring, a join point is nothing but a method execution.
  • ADVICE It is the action taken at a particular join point. The different types of Advice available are ‘before’, ‘afterReturns’€,’€around’€,’€afterThrows’.
  • POINTCUT €“ It is a specification which has to match with the join point so that a particular action is taken correspondingly. Typically, the pattern (name) of the method on which cross-cutting needs to be done is specified. When this matches with the join points, an advice (action) takes place.
  • TARGET OBJECT“ Also referred to as the Advised object. In simple terms, this is the object which is actually called upon, but bypassed by the aspect.
  • WEAVING linking aspects with other application types or objects to create an advised object. This can be done at compile time

Now that the basic terminologies are covered, let us try out some simple programs using Spring AOP concept.

The environment set up are the same as explained in Tutorial – Spring set up


Leave a Comment

Your email address will not be published. Required fields are marked *