Aspect-Oriented Programming on JBoss 4.0
by Kevin Bedell
I got a chance to listen to Bill Burke, Chief Architect of The JBoss Group, speak at TheServerSide Symposium on the new Aspect-Oriented Programming (AOP) features that are in the upcoming JBoss 4.0 release.
The AOP features of JBoss 4.0 really are in two parts. First, there is the AOP Framework that enables AOP features to be implmented. Second, there are a series of AOP Services (or system-level aspects) that have been developed and are provided with JBoss.
What is AOP?
AOP is an approach to application development that is based on developing functionality that can be applied, or layered, on any of the Java objects you develop.
If you think of Object-Oriented Design (OOD) as designing interfaces and classes that other classes can then implement or inherit behavior from, then think of AOP as defining functionality that can be applied to ALL your classes -- declaratively, not programmatically.
For example, you can literally add a method declaratively (without modifying the Java source code) to any class (or to all classes) in your application using what's called an 'Introduction'.
The ability to add 'Introductions' to your classes is based on the ability to use what are called 'Interceptors'. An interceptor works by intercepting program flow just at the point between when you invoke a method and when that method is actually executed.
These 'interception points' are called 'pointcuts' because of how you are adding functionality just at the 'point' between when the object access is called and when the object is actually accessed.
The JBoss AOP Framework and AOP Features in JBoss 4.0
JBoss 4.0 comes with an AOP Framework that can be used to develop applicatins with AOP features. A number of AOP features, called system-level aspects, have been built by the JBoss group and are supplied in JBoss 4.0.
Among these features is the ability to make plain Java objects transactional. Using this capability, you can declare plain Java objects to be transactional and then have the JBoss container roll-back or commit changes to the Java objects based on how your transaction is progressing.
Another feature this allows is the application of the J2EE security model on top of plain Java objects as well. Using this capability, you can define security on top of plain Java objects.
Another feature is 'remoting'. This allows you to declaratively specify that an object exists in a remote container (specified by a URL) and then access that object as if it were a normal object.
I'm really just scratching the surface. For more information, refer to the JBoss page on JBoss Aspect Oriented Programming
It will be nice to have links releated to AOP in general.
Here are a couple good links:
Other AOP Frameworks
See http://www.mackmo.com/nick/blog/java/?permalink=aop-frameworks-review.txt for a decent comparison of some other AOP framworks with JBoss