J | ava | A | spect | C | omponents |
JAC aspect-oriented features and framework are based on a dynamic wrapping system that is used to weave the aspects together within the application. The global framework is further explained and represented in the following figure.
The key feature of the JAC framework are dynamic wrappers, also called generic advices in relation to the aspect-oriented terminology (see org.objectweb.jac.core.Wrapper). A dynamic wrapper is defined in as a regular stand-alone object (i.e. it contains fields that form its states and methods that define it functionalities). However, a dynamic wrapper can implement several methods that have special semantics. Generally speaking, a dynamic wrapper is an object that defines behaviours that are not stand-alone since they must be applied to a regular object to be activated.
When a dynamic wrapper (generic advice) wraps (is applied to) a base object, the reference of the base object is not changed so that it does not disturb the clients. A base object can be wrapped by as many wrappers as needed and the set of wrappers is called a wrapping chain (or an advices chain).
Dynamic wrappers can define 3 kinds of methods in addition to regular methods that defines the functional interface of the advice itself:
The definition of which generic advice (dynamic wrapper) will be applied to which regular object is done within special components called Aspect Components (see org.objectweb.jac.core.AspectComponent). In the AOP terminology, we say that this components define the pointcuts with-tin the base program.
In order to allow the aspect components to easily define pointcuts, some extra meta-informations must be constructed by the JAC system. These extra informations are:
java.lang.reflect
package since it is more
precise, more flexible, faster, and (the last but not the least)
aspects compliantThus, a JAC application composed of regular object can be aspectized by programming a set of aspect components that extends its core behaviour. The aspect components install the dynamic wrappers when they receive events from the internal MOP defined by org.objectweb.jac.core.BaseProgramListener. This installation (creation of new wrappers and linkages with the base objects) create new dedicated MOPs that allow the modification of the base objects behaviours.
Notice also that the aspect parts of the application implement the org.objectweb.jac.core.CollaborationParticipant interface that allows them to retrieve some contextual information about what is happening in the base program (a collaboration is the reification of a set of interactions between some objects).
JAC uses BCEL to translate the regular object classes of the application so that they become wrappable. BCEL works at bytecode load-time so that the source code of the application is not needed (an aspect can be applied to a previously programmed application). The class files are not changed on disk so that a JAC application class can be used by regular Java programs.
For more details about how the bytecode translation is performed, see the org.objectweb.jac.core.WrappeeTranslator and org.objectweb.jac.core.WrappeeTemplate classes.
JAC is a more framework than a new language. On contrary to AspectJ that focuses on defining new languages constructs to define crosscutting and aspects, JAC focuses on dynamicity and composition of aspects. Since JAC works at runtime and on a per-object basis, it is more suitable for distributed programming since an aspect can be dynamically applied or removed during the execution of the application and on a subset of instances.
JAC's final goal is to propose an extension that can be used to easily construct distributed applications in an Aspect-Oriented fashion. We are currently working on a programming model for Aspect-Oriented Distributed Programming that is based on groups of objects.