Hi,
Yeah, it's expected behavior in OSGi world.
Generally let's say bundleA has some resource in package x.y.z, if
bundleB want to use that resource, it must explicitly import that
package, so that resource is available for bundleB.
But package like META-INF/services/ is a little bit different, as it's
JAVA SPI mechanism, it exist in a lot of bundles, which means it cause
split package issue, so you can't just simply import package META-INF/
services in bundleB. There're several solutions to handle this issue,
like make bundleA as a fragment bundle, attach to bundleB(bundleB as
host bundle), so that all resource from BundleA is available in BundleB.
But IMO you shouldn't use code like
Enumeration en =
Thread.currentThread().getContextClassLoader().getResources("META-INF/
services/"
+ Providers.class.getName());
at all, as SPI mechanism is standard in java, you should let jaxrs-api
to load the jaxrs impl class, so in your code you just use jaxrs api.
Also servicemix specs implement a OSGiLocater, which do the trick that
make SPI works in OSGi world.
Freeman
On 2012-1-12, at 上午12:01, MarkS1900 wrote:
I have OSGi bundle that has configuration files in the META-INF/
services/*
location. (Such as
resteasy-jaxrs-2.2.3.GA.jar/META-INF/services/
javax.ws.rs.ext.Providers).
Now when another bundle attempts to access the resource with the
following
code, this resource is not found:
Enumeration en =
Thread.currentThread().getContextClassLoader().getResources("META-
INF/services/"
+ Providers.class.getName());
Of course if this resource exists in the current OSGi bundle, then
it is
found.
More on this issue described here:
https://issues.jboss.org/browse/RESTEASY-640
Is this expected behaviour? Why?
--
View this message in context:
http://servicemix.396122.n5.nabble.com/OSGi-classpath-getResources-issue-in-ServiceMix-4-4-0-tp5137185p5137185.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.
---------------------------------------------
Freeman Fang
FuseSource
Email:[email protected]
Web: fusesource.com
Twitter: freemanfang
Blog: http://freemanfang.blogspot.com