Main

Aspect-Oriented Frameworks Archives

May 25, 2007

AspectJ Framework

Some aspects of system implementation, such as logging, error handling, standards enforcement and feature variations are notoriously difficult to implement in a modular way. The result is that code is tangled across a system and leads to quality, productivity and maintenance problems. AspectJ is a seamless aspect-oriented extension to the Java programming language that enables clean modularization of these 'crosscutting concerns'. For the best AspectJ development experience, the AspectJ Development Tools (AJDT) project provides Eclipse platform based tool support for AOSD with AspectJ - see Eclipse AJDT project.

Features of AspectJ

* a seamless aspect-oriented extension to the Java programming language
* Java platform compatible
* easy to learn and use

AspectJ Enables

clean modularization of crosscutting concerns, such as error checking and handling, synchronization, context-sensitive behavior, performance optimizations, monitoring and logging, debugging support, and multi-object protocols.

AspectJ Downloads:

http://www.eclipse.org/aspectj/downloads.php

Documentation

Popular AspectJ docs: AspectJ 5 Developer's Notebook | Programming Guide | More docs...

AspectJ Project Home Page
http://www.eclipse.org/aspectj/

AspectWerkz - Simple, high-performant, dynamic, lightweight and powerful AOP for Java

AspectWerkz is a dynamic, lightweight and high-performant AOP framework for Java.

AspectWerkz offers both power and simplicity and will help you to easily integrate AOP in both new and existing projects.

AspectWerkz utilizes bytecode modification to weave your classes at project build-time, class load time or runtime. It hooks in using standardized JVM level APIs. It has a rich and highly orthogonal join point model. Aspects, advices and introductions are written in plain Java and your target classes can be regular POJOs. You have the possibility to add, remove and re-structure advice as well as swapping the implementation of your introductions at runtime. Your aspects can be defined using either Java 5 annotations, Java 1.3/1.4 custom doclets or a simple XML definition file.

AspectWerkz provides an API to use the very same aspects for proxies, hence providing a transparent experience, allowing a smooth transition for users familiar with proxies.

AspectWerkz performance is reported in this separate project.

AspectWerkz is Free Software. The LGPL-style license allows the use of AspectWerkz 2.0 in both commercial and open source projects.

AspectWerkz Features

This is a very incomplete list, see the documentation for all features.

* Very high-performant. Weaved code is entirely statically compiled. AspectWerkz ranks 1st or 2nd in most of the benchmarks. Read more about the figures on the AspectWerkz Bench project pages.

* Annotation support: Matching on annotations (both JavaDoc and JSR-175). Supports user-defined annotations, retrieval of annotations. Both JavaDoc and JSR-175 annotations are accessed through one single API and both schemes are strongly typed.

* Aspects, advices and introductions are written in plain old Java code. I.e. no new language to learn, no new compilation phases, no need to tell your manager ;-). Will work seamlessly in any IDE, debugger, refactoring tool and test framework.

* The target classes can be regular POJOs (Plain Old Java Objects), i.e. do not require to have an interface.

* Weaving (bytecode modification) at compile time, load time and runtime. Hooks in and transforms classes loaded by any class loader except the bootstrap class loader. Which basically means that you can easily transform any (legacy) application or external library apart from rt.jar both at runtime and compile time.
JSR-163 JVMTI is supported for Java 1.5 usage as well.

* The join point model supports: staticinitialization, method execution and call, constructor execution and call, field access, field modification, catch handlers, cflow, within and withincode, hasmethod and hasfield. All advice works with all join points.

* Rich semantics allow to access runtime information about the join point within the advice using regular types without any casting or object array access. Reflective access to runtime information is also possible.

* Introductions/Inter type declarations (also called Mixins), i.e. the possibility to add interfaces and implementations to existing classes.

* META-INF/aop.xml container: Support for deploying several aop.xml Aspect defintion/deployment files alongside deployed application ( WEB-INF/aop.xml, META-INF/aop.xml) and have them following the classloader hierarchy.

* Annotation definition. Define your aspects and mixins using annotations using wether standardized Java 5 Annotations (JSR-175) or Java 1.3/1.4 custom doclet with strongly typed access.

* XML definition. Define your aspects and mixins using XML. The XML definition can also be used to refine, override and resolve the annotation definition.

* Pluggable aspect manager that can make it work seamlessly with IoC frameworks like Spring or PicoContainer.

* Support several different deployment models (scope) for aspects (perJVM(singleton), perClass, perInstance) and for mixin (perInstance, perClass, perJVM(singleton)).

* Hot deployment, aspects can be deployed and undeployed at runtime using a simple API.

* Fine-grained pattern language for selecting the join points.

* Highly orthogonal underlying model. All advice works with all join points and pointcut composition supports mixing all kinds of pointcuts.

* "Offline" transformation (can be used as a post-processor).

* Support for passing configuration parameters to the advices through the definition.

* Simple usage and configuration.

* Extensible container architecture allows to run any Aspects (AspectWerkz, Spring AOP, AOP Alliance, subset of AspectJ) within the AspectWerkz runtime.

AspectWerkz Downloads

http://aspectwerkz.codehaus.org/releases.html

Documentation & Tutorials for AspectWerkz
http://aspectwerkz.codehaus.org/introduction.html
http://docs.codehaus.org/display/AW/Tutorials

Nanning Aspects - Java Framework

Nanning Aspects is a simple yet scaleable aspect-oriented framework for Java.

Nanning is also nice "little" town in Guanxi province in southern China. It's about 1-2 million inhabitants which barely qualifies it as a town by chinese standards. It is not to be confused with the much larger Nanking/Nanjing.

Nanning Features:

Nanning Aspects has the following features:

* An aspected object consists of a set of mixins. Every mixin is an interface, a target-object and a set of interceptors (advises on method-calls), these interceptors intercept calls on the interface on it's way to the target.
* An aspected object is used by creating a Proxy with the Reflection API. This proxy will implement all the interfaces of all the mixins by invoking all the interceptors for the called method and finally calling the proper implementation of the target object.
* Attributes (as Javadoc-like tags in the source code or as an xml-document with the same name as the class) can also be added to classes, fields and methods. These attributes are accesible at runtime.
* Inherited interfaces will call correct target. If several aspects implement same interface the first one will take precedence. The target of the aspect-class will always take precedence before the rest.
* An XML-config format that's actually a Jelly-script .
* Method-selectors that selects what methods an interceptor should intercept.
* Super-simple implementation. Really! Anybody can do it!

Nanning Restrictions

Nanning Aspects has the following restrictions

* You can only advise on method-call pointcuts which is far from the power that for example AspectJ offers. On the other hand compared to the complexity of AspectJ Nanning is much, much simpler. In reality many of the benefits of AOP can be reached with this simple construct. At the moment there is also some experimental support for intercepting object-instantiation.
* All your objects need to have interface and implementation separated, that is all public methods (accessible to clients) needs to be placed in an interface which is implemented by the actual class. In contrast to EJB your implementation must implement the interface, which also forces your implementation to stay in sync with your interface. (This is actually good, because the java-compiler will choke if they're out of sync before your code even hits unit-tests.)
* You'll get indeterministic effects if your interface has a method with same name as a method of another interface for the aspected object. (Currently considering disallowing this altogether.)


Most documentation is located at our SnipSnap http://nanning.snipsnap.org . It's an ongoing effort.

Download Nanning
http://nanning.codehaus.org/download.html

JBoss AOP - Organizing Cross Cutting Concerns

JBoss AOP is a 100% Pure Java aspected oriented framework usuable in any programming environment or tightly integrated with our application server. Aspects allow you to more easily modularize your code base when regular object oriented programming just doesn't fit the bill. It can provide a cleaner separation from application logic and system code. It provides a great way to expose integration points into your software. Combined with JDK 1.5 Annotations, it also is a great way to expand the Java language in a clean pluggable way rather than using annotations solely for code generation.

JBoss AOP is not only a framework, but also a prepackaged set of aspects that are applied via annotations, pointcut expressions, or dynamically at runtime. Some of these include caching, asynchronous communication, transactions, security, remoting, and many many more.

JBoss AOP Download
http://labs.jboss.com/jbossaop/downloads

JBoss AOP Documentation
http://labs.jboss.com/portal/jbossaop/docs/index.html

JBoss AOP Project Home
http://labs.jboss.com/jbossaop/

dynaop

dynaop, a proxy-based Aspect-Oriented Programming (AOP) framework, enhances Object-Oriented (OO) design in the following areas:

* code reuse
* decomposition
* dependency reduction

dynaop Project Home Page
https://dynaop.dev.java.net/

dynaop Downloads
https://dynaop.dev.java.net/servlets/ProjectDocumentList

dynaop Documentation
https://dynaop.dev.java.net/nonav/release/1.0-beta/manual/index.html