The framework has a built in mechanism called "Aspects" that allows plug-in modules to execute code right before and right after a FunctionalSegment is executed. This mechanism is used to implement internal framework features such as caching and validation.
LimeDS users can develop their own Aspect to further extend the possibilities of the framework. To do this, two interfaces need to be implemented: AspectFactory (which must be registered as an OSGi service) and Aspect.
AspectFactory requires two methods to be implemented:
- getPriority: Use this method to specify the priority of the aspect, this will have an impact on when the aspect will be executed relatively to the other aspects registered with the system.
- createInstance: This method allows LimeDS to create appropriate Aspect instances and should return an empty results if the current SegmentContext (the Segment for which the aspect will be used) is incompatible with the aspect.
Aspect requires four methods to be implemented:
- init: Defines what to do if the aspect is initialized.
- doBefore: Defines what to do before each time the Segment (to which the aspect is being applied) is called.
- doAfter: Defines what to do after each time the Segment (to which the aspect is being applied) was called.
- destroy: Defines what to do if the aspect is no longer needed.