-
Notifications
You must be signed in to change notification settings - Fork 600
OSGi current recommended usage patterns and 'how to' s.
For mandatory static references the preferred way to inject is to use constructor injection:
@Activate
public NettyFrameworkImpl(@Reference ExecutorService executorService) {
this.executorService = executorService;
}
Use a @Component
rather than a .bnd file entry and there is no need
to have the service.vendor field
If your component is configurable then the target filter for the reference can be configured with configuration admin. For example if you gave your reference a name @Reference(name="example1") and your component PID is mypid then in the server.xml it could be configured like:
<mypid example1.target="(some.property=select.this.one)" />
Slack
Slack The most simple is always to get directly injected with the service object implementation with a simple @Reference. Only after you prove that such a simple reference contributes to a performance issue should you consider using AtomicServiceReference to try to have lazy service instantiation.
Keep Java types for references as simple as possible: Slack