On 22/02/2008, Kyrill Alyoshin <[EMAIL PROTECTED]> wrote:
>
> Hi gurus,
>
> I am trying to figure out a way, given an "OSGI-enabled" classloader
> like, for example,
> org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader to discover all
> available jars that this classloader can see (as list of URLs or URIs).
>
> It is a fairly trivial exercise in "normal" Java. :-)  You can call
> ClassLoader#findResources("META-INF/MANIFEST.MF"), and you'd get back a
> transitive closure of all jars in the following format:
> jar:file:/foo/bar/baz.jar!/META-INF/MANIFEST.MF.
>
> Well, with org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader, I
> get the following response from this method (as a sample):
> bundleresource://105:1/META-INF/MANIFEST.MF.
>
> How would I parse it to get to the actual jars?


the Java spec for ClassLoader#findResources says that it should return an
enumeration of URLs - it is an implementation detail as to the form of these
URLs, and afaik there's nothing stopping a JVM from using it's own scheme
as long as it also provides a handler for the scheme

I believe you should be able to use the URLs from the OSGi classloader to
access the bundle content - each framework typically registers its own URL
handlers for this purpose - but the actual form of the URL is implementation
dependent and therefore you should consider it as opaque

HTH

What about in general? How is an OSGI classloader supposed to query its
> resource bundles?


check out the javadoc for the Bundle class - there are several query methods


> Thanks so much for your help!
>
> -Kyrill
>
>
>
>
>
>
>
>
> _______________________________________________
> OSGi Developer Mail List
> [email protected]
> https://www2.osgi.org/mailman/listinfo/osgi-dev
>



-- 
Cheers, Stuart
_______________________________________________
OSGi Developer Mail List
[email protected]
https://www2.osgi.org/mailman/listinfo/osgi-dev

Reply via email to