Part 2. Applications of AspectJ with Spring

 

Part 2 puts the knowledge you gained in the first part to practical use by showing how AspectJ and the Spring Framework simplify enterprise applications. Although Spring provides dependency injection and enterprise service abstraction, AspectJ completes the picture by modularizing crosscutting concerns. We’ll explore the two ways Spring integrates with AspectJ: through dynamic proxies and through byte-code weaving. You should be able to use most of the example code in your applications without much modification. Even if you aren’t using Spring, you’ll find that you can adopt these examples to suit your applications. We include a few examples from outside of Spring—specifically Swing and EJB—to show that AOP concepts are applicable in any kind of applications.

We begin by examining a classic application of AOP: monitoring and tracing. Then, we’ll modularize the policy-enforcement concerns to create a safety net that ensures you won’t get into trouble by violating programming policies. The examples in chapters 10 and 11 demonstrate how you can use AOP to improve your personal productivity during the development phase. You can take out these aspects when you deploy your system without affecting the correctness of the core system. Of course, as we explain, you can continue using these aspects in the deployed system and gain even more benefits.