0

I am using Apache Felix to create an embedded OSGi host application. I am using the following code to expose the packages I want to expose:

List<String> extra = new ArrayList<>();
extra.add("some.example.packag.to.expose.1");
extra.add("some.example.packag.to.expose.2");
extra.add("some.example.packag.to.expose.3");
config.put(Constants.FRAMEWORK_SYSTEMPACKAGES_EXTRA, extra.toString().replace("[","").replace("]", ""));

Everything works great and these packages are exposed. However, I need the bundles to have access to ALL the host project declared dependencies. So for example the parent application has Jackson, Apache (various), etc. declared and I need the bundles to have access to these.

I tried adding the packages explicitly but that does not seem to do the trick when they are dependencies. So for example in the bundle I want to use Jacksons com.fasterxml.jackson.core.type.TypeReference; so I added com.fasterxml.jackson.core.type to the above EXTRA list but it does not appear to solve the problem, the package still doesn't get exposed.

In a perfect work I just want to make ALL the host dependencies available without having to explicitly state each one.

tarka
  • 5,289
  • 10
  • 51
  • 75

1 Answers1

0

You will have to configure each package. In OSGi you would normally install the dependencies as bundles. So the settings do not suppot to mass export system packages.

Christian Schneider
  • 19,420
  • 2
  • 39
  • 64
  • Ok, so it sounds like there is no built in mechanism to mass export dependencies. Not the end of the work, I am happy to find a work around solution to list the dependency packages to expose. But what do you mean when you say "configure each package". As I explained in the question, declaring the dependency in the EXTRA list does not seem to work. – tarka Nov 01 '15 at 08:35
  • The package should be available in OSGi if you export it like you showed. How do you see that it does not work? – Christian Schneider Nov 01 '15 at 10:58
  • If there was a built-in mechanism to mass-export packages from the base application... where should it stop? Should it export absolutely everything from the application classpath? How about the extension classloader and the boot classloader? How about all the `com.sun` and `sun.misc` stuff in the JRE? In a standard Java program there is no defined way to enumerate all packages that are part of an "application", versus those that are part of the Java SE spec, and which are non-standard packages in the JVM you happen to be running. This is why you have to specify the packages yourself. – Neil Bartlett Nov 01 '15 at 22:16