Header Ads

  • Breaking Now

    What is Aspect Oriented Programming and how is it related with Spring?

    Aspect Oriented Programming(AOP) is a paradigm of developmental approach which is based on:

    -separation of concerns encompasses breaking down a program in parts which overlap in functionality as little as possible.
    -cross-cutting concerns is how modules,classes,procedures intersect each other and defy concern like encapsulation
    -advancement in modularization.

    An AOP language consists of crosscutting expressions that encapsulate the concern in one place. AspectJ has a number of such expressions and encapsulates them in a special class, an aspect.

    An aspect can

    -change the behavior of the base code (the non-aspect part of a program) by applying advice(additional behavior) at various joint points (points in a program) specified by query called a point cut (that detects whether a given join point matches).

    -make structural changes to other classes, like adding members or parents.

    Spring implements AOP using

    -dynamic proxies (where an interface exists)
    or
    -CGLIB byte code generation at runtime (which enables proxying of classes). It works well in any application server and standalone environment so there is no vebdor dependency.

    -Spring can use AOP for declarative transaction management eliminating the need of EJB conatiner or JTA for achieving the same.
    -Spring AOP supports method interception and both stateful (one instance per advised object) and stateless interceptors (one instance for all advice).
    -Spring AOP can be used to implement application-specific aspects also.It all depends upon how much comfortable you are with Aspect concepts rather Spring AOP capabilities.
    -Spring AOP integrates transparently with the Spring BeanFactory concept.

    Post Top Ad

    Post Bottom Ad