Sunday, May 22, 2011

Classpath scanning with Equinox OSGi

Today I moved some code to OSGi that heavily relies on Classpath scanning.
There's a new API in BundleWiring that lets you scan for resources:
BundleWiring wiring = ctx.getBundle().adapt(BundleWiring.class);
Collection<String> resources= wiring.listResources(DOMAIN,"*.class",BundleWiring.LISTRESOURCES_LOCAL);
Unfortunately due to a bug in NestedBundleDir you need CVS HEAD from the osgi bundle to make this work inside the IDE. It will be fixed in 3.7 RC2.


Cristiano GaviĆ£o said...

Hi, I thought that 3.7 was based on OSGi 4.2 as 3.6 but this is a R4.3 addition, no?

Do you know a way to do the same on eclipse 3.6 ?



Thomas Kratz said...

Hi Cristiano, I remember that I have read about some hacks once, but I can't tell be now.