Hi,
looks like you mix two different things, one is CDI (as with JEE), the other is Declarative Services.
The first will give you std. Contexte and Dependency Injection, for example Bean wiring within the same Bundle (classic dependency injection) etc. when combined with Pax-CDI you're able to Inject OSGi Services into your Bean Context created by either other Pax-CDI enabled CDI bundles or standard OSGi services.
Now talking of Service/Reference annotated services and references. Those are std. Declarative Services and will work with any OSGi Implementation of that Specification. Now those are "portable" accross different frameworks (Equinox, Knopflerfish, etc..) if there is a bundle available that implements the OSGi specification for Declarative Services.
The annotations:
- Reference
is a Declarative Services annotation and will only work with OSGi runtimes as it wires any other OSGi service into your consuming class
- Service
is a Declarative Services annotation and also will only work within an OSGi environment. It declares this class as a OSGi service which can be referenced in any OSGi way – one, for example could be via Declarative Services Reference annotation.
- OsgiServiceProvider
is a Pax-CDI annotation to declare any CDI bean to also be registered as OSGi Service, this will only work if Pax-CDI is available. CDI isn't standardized within the OSGi specifications yet.
- OsgiService
is also a Pax-CDI annotation. With this you're able to inject any kind of OSGi Service in your CDI managed bean context, and therefore into that given CDI Bean. Actually it might be that you reference a Service which is made available via the @Service annotation in a DS bundle.
One major difference between CDI and DS is, CDI will give you bean wiring within your bundle and services while DS only gives you wiring between services, so DS is more coarse grained.
Hope this made it clearer for you.
regards, Achim