Spring AOP Best Practices
In this technical session, I will discuss how Spring AOP, one of the key components of Spring framework, can be used to greatly improve the design and development of Java applications. I will talk about the role of SpringAOP in the areas of Domain-Driven Design (DDD), Persistence (JPA), and JMX monitoring. We will also look at implementing custom Java annotations using Spring AOP.
The session will include the demonstration of a sample Java application which implements an Object Cache Monitoring framework using Spring AOP, JMX, and Rome technologies. The use case includes the cache monitoring implementation using different Spring AOP design options such as the Aspect Definition style (Annotation or XML, @AspectJ style), AOP Declaration Style (AspectJ or SpringAOP) and Aspect Weaving options (Compile time, Binary or Load Time Weaving).
The session will conclude with the discussion on tool support and best practices when using Spring AOP in Java application development.
Aspect oriented programming (AOP) complements OOP principles by managing the cross-cutting concerns like transaction management, persistence, application security, caching and architecture enforcement. It helps developers to add behavior to objects in a non-obtrusive manner through static and dynamic crosscutting and code cross-cutting concerns in separate modules and apply them in a declarative way.
Spring AOP, one of the key components of Spring framework, is used to provide declarative enterprise services such as transaction management. Coupled with Dependency Injection (DI) principle, AOP provides a powerful design and development technique to achieve higher modularity, extensibility, unit testability of various components in a typical J2EE application that is not possible with traditional design techniques.
Spring AOP is implemented in pure Java so there is no need for a special compilation process. Spring's support for AOP comes in four flavors: Classic Spring proxy-based AOP, @AspectJ annotation-driven aspects, Pure-POJO aspects, and Injected AspectJ aspects. A typical J2EE application implemented using Spring AOP includes the design decisions on what Aspect Definition style (Annotation or XML, @AspectJ style) to use, AOP Declaration Style (AspectJ or SpringAOP) and Aspect Weaving option (Compile time, binary weaving or Load Time Weaving).
In this technical session, I will discuss how Spring AOP can be used to greatly improve the design and development of Java applications to make them modular and extensible. I will talk about the role of SpringAOP in the areas of Domain-Driven Design (DDD), Persistence (JPA), and JMX monitoring. Spring AOP module has gone through major design refactoring from version 1.0 to the latest 3.0 version. We will look at how the implementation of SpringAOP aspects has changed from the previous versions to the latest version of Spring framework.
Spring AOP module allows users to implement custom aspects, complementing their use of OOP with AOP. We will also look at implementing custom Java annotations using Spring AOP. The session will include the demonstration of a sample Java application which implements an Object Cache Monitoring framework using Spring AOP, JMX, and Rome technologies. Adding the power of AOP in the object cache monitoring provides a loosely coupled, highly flexible and reusable module. The use case includes the cache monitoring implementation using different Spring AOP design options. The session will conclude with the discussion on tool support and best practices when using Spring AOP in Java application development.
About Srini Penchikala
Srini Penchikala currently works as an Enterprise Architect at a major financial organization in Metropolitan Detroit area. He has over 14 years of IT experience and has been working on Java projects since 1996 and J2EE technology since 2000. His main areas of interest are Agile Enterprise and Service Oriented Architectures, Domain Driven Design & Development In Practice, Aspect-Oriented Programming (AOP), Architecture Rules Enforcement, Enterprise Integration Patterns, and light-weight middleware frameworks such as Spring and Hibernate. He has presented at conferences and Java User Groups on topics like Agile Enterprise Architectures, Architecture Governance, and Domain-Driven Design. He has published numerous articles on J2EE topics on websites like InfoQ.com, ServerSide.com, O'Reilly Java Network (ONJava), DevX Java, java.net and JavaWorld. Srini also publishes a blog on Java, JEE, and other topics at http://srinip2007.blogspot.com/. He is also a leader of Detroit Java User Group (http://sites.google.com/site/detroitjug/).
More About Srini »