The component inside the fragment is never activated

When I create a component inside a fragment using the OSGi declarative service path, this component is not activated, but my components in the node set are activated. Am I missing something? My snippet has the correct meta-inf file entry for the symbolic node name.

I declare the component this way

 @Component(immediate = true) 
+4
source share
1 answer

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

+6
source

Source: https://habr.com/ru/post/925146/


All Articles