I have an Interface called 'Foo' and i have a bundle 'b'.
Now I want to get all classes implementing interface 'Foo' in bundle b
Something like below
org.osgi.framework.Bundle bundle = ...;
List<Class<? extends Foo>> allImplemetation = getAllImplementation(bundle);
The clean way to find implementations in OSGi is to let each bundle publish each implementation as an OSGi service. This allows to keep the impl classes private and makes sure your central bundle is nicely decoupled from the user bundles. Here you can find some guidance how to do this .
If this is not possible then you can use a BundleTracker to get a call back when new bundles are installed. You can then use Javassist or XBean finder to scan the bundle class path for classes that implement and interface. This variant is pretty difficult to do right though. So I would try to avoid it.
A kind of a middle of the road solution would be to use the same approach as ServiceLoader. You create a file at a special directory in the jars that contains the class names of the implementations to load. You can then use the BundleTracker like above to find the newly installed bundle, read this resource and then use the ClassLoader of the bundle to load the implementation class.