Steven E. Harris wrote:
Well, in this case, I'm having to depend on some private
implementation details of the Felix bundlerepository bundle, but note
its bundle plugin configuration:

  <Export-Package>org.osgi.service.obr</Export-Package>
  <Private-Package>org.kxml2.*,org.xmlpull.*,
                   org.apache.felix.bundlerepository.*</Private-Package>

Note that the org.apache.felix.bundlerepository is private. It's not
enough that I can load the bundle. My code has to refer directly to
some things in the org.apache.felix.bundlerepository package.

To be more specific, I'm (temporarily, for experimentation) trying to
hoist the LocalResourceImpl class into my own code, so that I can move
from a Bundle to a Resource. Here are some of the imports necessary to
get this to compile:

  import org.apache.felix.bundlerepository.ResourceImpl;
  import org.apache.felix.bundlerepository.R4Import;
  import org.apache.felix.bundlerepository.R4Package;
  import org.apache.felix.bundlerepository.CapabilityImpl;
  import org.apache.felix.bundlerepository.PropertyImpl;
  import org.apache.felix.bundlerepository.RequirementImpl;

These are all bits and pieces of the parsing and mapping done in
LocalResourceImpl's initialize() method. Even then, I had to comment
out the calls to CapabilityImpl's addP() method, which is
protected. This feels too low-level for API-consuming code.

(I'm working on my experiment as I type, so I can't report yet whether
this is going to work out.)

Yep, I agree it is a little ugly, but that is because it wasn't intended to be public. In the future if we provide a static method to return a Resource from a Bundle, then we would put everything in a public package so that it could be easily imported. Unfortunately, that doesn't exist now, so the only way to do it is to copy that code into your own bundle...or write it yourself from scratch...not sure which is more effort.

Hopefully from your experience we can learn what we need to do to make this easier in the future.

-> richard

Reply via email to