|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT |
@Retention(value=CLASS) @Target(value=METHOD) public @interface Init
Annotates a method which will be invoked when the Service is initializing. All required dependencies are already injected before the annotated method is called, and optional dependencies on class fields are injected with NullObjects if the optional dependencies are not currently available.
If some dependencies are declared using a named @ServiceDependency
annotation,
then the annotated method may optionally return a Map used to dynamically configure such
dependencies (Please refer to @ServiceDependency.name()
attribute for more
information about this feature).
After the init method returns, the component is then invoked in the method annotated with
@Start
, in order to notify that the component is about to be registered into the OSGi
registry (if this one provides a service). However, you can take control of when the service is registered,
using the @LifecycleController
annotation).
@Component public class VideoPlayer { @ServiceDependency LogService log; @Init void init() {} // initialize our service (the "log" dependency is already injected). }
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT |