AOP is a powerful feature for cross-cutting concerns. However, if used extensive and for the wrong things an application can get unmaintainable. Therefore we give you the best practices where and how to use AOP properly.
We follow these principles:
-
We use spring AOP based on dynamic proxies (and fallback to cglib).
-
We avoid AspectJ and other mighty and complex AOP frameworks whenever possible
-
We only use AOP where we consider it as necessary (see below).
We recommend to use AOP with care but we consider it established for the following cross cutting concerns:
-
Trace-Logging (for testing and debugging)
-
Exception facades for services but only if no other solution is possible (use alternatives such as JAX-RS provider instead).
When using AOP with dynamic proxies the debugging of your code can get nasty. As you can see by the red boxes in the call stack in the debugger there is a lot of magic happening while you often just want to step directly into the implementation skipping all the AOP clutter. When using Eclipse this can easily be archived by enabling step filters. Therefore you have to enable the feature in the Eclipse tool bar (highlighted in read).
In order to properly make this work you need to ensure that the step filters are properly configured:
Ensure you have at least the following step-filters configured and active:
ch.qos.logback.*
com.devonfw.module.security.*
java.lang.reflect.*
java.security.*
javax.persistence.*
org.apache.commons.logging.*
org.apache.cxf.jaxrs.client.*
org.apache.tomcat.*
org.h2.*
org.springframework.*