Since the fragments of the package are never started, only allowed, the components of declarative services in them are never activated. The specification specifically states that Service-Component headers (which are converted by annotation) to fragments are ignored.
You can make declarative services work for fragments, but only by referencing the XML file in the fragment from the Service-Component header on the host. Unfortunately, the presence of a nodal node about what is in the fragment is probably the reverse of the architectural pattern to which you belonged. I'm not even sure that such an agreement is possible using SCR annotations. One option is to use a scheme for declarative registration of services from fragments, which really works. There, a tutorial is available at http://aries.apache.org/documentation/tutorials/blueprinthelloworldtutorial.html .
-
Implement OSGi in action: www.manning.com/cummins
source share