How to ensure that my OSGi fragments are installed before the host package?

I am trying to deploy guice in JBoss AS7 (7.2.0-Alpha). This happens as the number of cans. I'm interested in:

  • Guice
  • Guice servlet
  • Guice-persist

guice is the host, and guice-servlet and guice-persist are fragments of this host.

When I start the container, the host is always installed, resolved and becomes active. Fragments are always set, and sometimes resolved and "included" in the host node, and sometimes not. It seems random.

I also tried Eclipse Virgo, and everything was different, but it has the ability to define plans through which you can work around this problem by specifying the installation order. (I seemed to be able to make it work anyway).

Looking at the OSGi specification and reading the answer to this question , it looks like this is the expected behavior. JBoss is an OSGi 4.2 container, so the Require-Capability and Provide-Capability headers are not an option - plus I don’t want to change banks that are not mine.

How can I get host / fragment packages for reliable installation and resolution?

One of my ideas (which I reluctantly do as it seems to me to be wrong) is to use maven-bundle-plugin / bndtools and combine the sets of images together into one set of super-guice packages during build, which the container does not do for me at runtme.

+4
source share
1 answer

As I said in my answer to the question you contacted: the fragment will be attached to the host if it is installed before the node resolves. The easiest way to achieve this is to first install all packages (including fragments) before allowing any of them to be resolved.

In many cases, the solution starts trying to run the package. One of the most common mistakes that people make in OSGi is trying to run each bundle immediately after installing it. You should not do this, i.e. You should not run any package until you have installed all the packages that you intend to run.

+7
source

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


All Articles