AOP stand for
Aspect Oriented Programming. It’s very important module for
Spring framework. In the enterprise level application programming we used to add different types of services to our application at runtime automatically, like logging, email, transaction, authentication services. These actions we called
AOP do this job.
Let’s see a normal instance:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
In above codes, we have a class called MyLogicClass, in this class there are two logic methods, and both them call authentication, logging, transaction, email services. We called these service are
cross-cutting functionalities. So there are some problems, one is these
cross-cutting functionalities increase the class size. Second is we need changed this class and recompile, re-deploy it again when we changed the services.
So how to overcome these problems, can we separate the services and our logic client? Yep, we can do this in Spring
AOP, adding these
cross-cutting functionalities at runtime don’t need to write them in the logic codes.
So if we use
AOP, our logic class will be like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
In above codes, we separate the business logic and the services, we call this process of separation as
AOP. So Using
AOP business logic and
cross-cutting functionalities are implemented separately and executed at runtime as combine automatically.