7

I have a fragment bundle that I created to access some add functionality to a second-party jar. My fragment should register a service to expose this new functionality. It doesn't seem to work. Before I get deep into troubleshooting, I'd like to know if this is even allowed? That is, does Felix SCR's bundle watcher look at or ignore fragments?

Chris Dolan
  • 8,905
  • 2
  • 35
  • 73

2 Answers2

9

Aha, I found the answer myself in the spec, section 112.4.2: "A Service-Component manifest header specified in a fragment is ignored by SCR." This is consistent with 3.14.3: "The following list contains the headers that must not be used in a fragment bundle: Bundle-Activator"

Chris Dolan
  • 8,905
  • 2
  • 35
  • 73
  • 1
    See also http://stackoverflow.com/questions/8592860/component-inside-a-fragment-never-activated, which confirms what you just said, but with the added information that blueprint does work for fragments. – Holly Cummins Jul 14 '12 at 01:06
6

Yes. But the host bundle must be open to this. By open, I mean the host bundle must have the Service-Components header configured such that any descriptors in the fragment will be found. For example:

Service-Components: OSGI-INF/*.xml 

will find all .xml files in the OSGi-INF/ folder of the host bundle all the attached fragments.

I saw Eclipse SmartHome project use this solution to make their UI more customizable.

More information: http://apache-felix.18485.x6.nabble.com/DS-amp-fragments-td5004610.html

thangdc94
  • 1,542
  • 2
  • 26
  • 38