Aspects are nice to have add-ons or features that help your business logic without being part of the business logic.
Aspects are OSGi bundles:
All the aspects are OSGi bundles and thus offer the ability of their life cycle management, say through management console. Aspect bundles are like libraries.
aspects-api is the collection of all aspects apis. Every aspect has its own OSGi bundle, aspects-<aspect-name>, e.g. aspects-cache.
The composite application/service assembly/application depends on aspects-api and thus could make use of any aspect functionality. Every aspect, depends on aspects-api. This way your application only depends on one bundle, aspects-api and only the aspects of your interest can be running as per your choice.
Aspects and Interceptors:
Aspects need be handled separately from that of business functionality as they really are not part of that logic.
Any component starts its functionality immediately after that component receives the message to process. Pre-message and Post-message handlers within the message handler are one way to achieve aspects. To start with, this approach loosely couples with your business logic. But then, adding control logic to choose when to handle the aspects raises the coupling. And there is no way to stop receiving the message, if that message in-deed not required to be received like in cases of Caching, Content-based-routing.
of Fuji provides a niche platform to handle Aspects. Actually, Aspects can be treated as one use-case for interceptors. Handling aspects within interceptors, decouples the business logic. Interceptor scoping of choosing providers and consumers and message flow controls provide all the right tools to handle several aspects including Caching, Content-based-routing.
An example - Cache
A prototype Cache aspect implementation is available in Fuji. Here are the steps to use it.
Modify <FujiSourceCodeBase>/trunk/core/core/pom.xml default-profile to add <module>aspects</module> so that aspects can be built.
Add aspects-api dependency to the composite application
You can do it either of the following ways:
Add as a library: In Netbeans, under your project, Right click on Libraries and Click on Add Library...
Edit pom: In Netbeans, under your project, Project Files, pom.xml