|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT |
@Retention(value=CLASS) @Target(value=METHOD) public @interface Composition
Annotates a method returning the list of objects which are part of a Component implementation.
When implementing complex Components, you often need to use more than one object instances.
Moreover, several of these instances might want to have dependencies injected, as was as lifecycle
callbacks invoked, like the methods annotated with Init
, Start
, Stop
,
Destroy
annotations. In such cases you can tell the dependency manager which instances to
consider, by annotating a method in your Component, returning a list of objects which are part
of the implementation.
This annotation may be applied on a method which is part of class annotated with either a Component
,
AspectService
, AdapterService
, or ResourceAdapterService
annotation.
Here, the "MyComponent" component is composed of the Helper class, which is also injected with service dependencies. The lifecycle callbacks are also invoked in the Helper (if the Helper defines them):
class Helper { LogService logService; // Injected void start() {} // lifecycle callback void bind(OtherService otherService) {} // injected } @Component class MyComponent { // Helper which will also be injected with our service dependencies private Helper helper = new Helper(); @Composition Object[] getComposition() { return new Object[] { this, helper }; } @ServiceDependency private LogService logService; // Helper.logService will be also be injected, if defined. @Start void start() {} // the Helper.start() method will also be called, if defined @ServiceDependency void bind(OtherService otherService) {} // the Helper.bind() method will also be called, if defined }
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT |