What is the most common use for AOP in spring project

MatBanik picture MatBanik · Jan 17, 2011 · Viewed 18.2k times · Source

After reviewing the AOP pattern, I'm overwhelmed with the ways of how and what to use it for in my spring project.

I'd like to use it as audit log system of all the financial business logic. It just seems to be easy to integrate. But I'd like to hear your take on this.

The question is - what other uses should I consider that are common for this pattern? I would not mind refactoring my current logic to be used with AOP as long as there is benefits to it.

Answer

Nilesh picture Nilesh · Jan 18, 2011

The most common usage is where your application has cross cutting concerns i.e. a piece of logic or code that is going to be written in multiple classes/layers.

And this could vary based on your needs. Some very common examples of these could be:

  1. Transaction Management
  2. Logging
  3. Exception Handling (especially when you may want to have detailed traces or have some plan of recovering from exceptions)
  4. Security aspects
  5. Instrumentation

Hope that helps.