@Retention(value=CLASS)
@Target(value=METHOD)
public @interface Composition
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
, FactoryConfigurationAdapterService
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 }