hstaudacher / osgi-jax-rs-connector

An OSGi - JAX-RS 2.0 Connector, software repository available on the link below
http://hstaudacher.github.io/osgi-jax-rs-connector
Other
191 stars 98 forks source link

Initializing ResourceFilter before publisher #179

Open tobias-- opened 7 years ago

tobias-- commented 7 years ago

I would like to apply a ResourceFilter as described in #96. The FAQ states that a ResourceFilter has to be registered before the publisher. When I register the ResourceFilter as a DS, the publisher is already started and the AllServicesTracker is being used. Do I really need to manually start the publisher bundle after the ResourceFilter is registered? In my current setup the publisher bundle is installed and started alongside every other bundle. Starting a single bundle manually seems very inconvenient.

Am I missing something?

doggy-dev commented 7 years ago

Hello @tobias-- , are you starting an RCP application? If so you can set the start levels of your bundles and just start your bundle with the ResourceFilter one level earlier as the publisher.

tobias-- commented 7 years ago

Hi @doggy-dev, I am using the launcher from bndtools, which installs and launches all runbundles (in order) after starting the framework. However, specifying the bundle containing the filter before the publisher does not seem to suffice: The filter does not get picked up until I manually restart the publisher bundle.

Yes, I certainly could change the way and order bundles are being installed, but maybe there could be a way (possibily a system property?!) to change the (greedy) default behaviour of the publisher to track all services.

doggy-dev commented 7 years ago

Sorry, I'm not familiar with this launcher. Maybe you shoud debug and checkif the order is really applied. Also make sure you have lazy-loading in your bundle manifest with the DS ResourceFilter. You should take in account that not the install or resolve order is important in this case, but the start order of the bundles. On the linked page I can't see anything about run order. Maybe there isn't any. Am I missing something?

BryanHunt commented 7 years ago

In general, if you have to set a specific start order for your bundles, something is wrong. If someone wants to dig into this and provide a PR, I'll give that priority over the holidays when I start looking at this project again.

doggy-dev commented 7 years ago

Yes, unfortunately something is wrong with the connector itself. It doesn't wait for a ResourceFilter service. It touches and initializes every service found in the osgi container. See #96 . Now if you have a Hibernate service factory e.g. you'll get couple of nasty exceptions about missing configs. A require-capability may be a nice solution for the next major release.

But the discussion gets off topic here. Creating a new issue is better.