I want to start OSGI bundle from a OSGI bundle. As you can see this code starts bundle by deploying it from a directory:
private void installStartBundle(BundleContext bc, String location, String name) throws BundleException
{
debug("installing " + location + "...");
Bundle[] all = bc.getBundles();
for (Bundle bundle : all)
{
String l = bundle.getLocation();
if (l.indexOf(name) != -1)
{
debug("already installed bundle " + bundle.getBundleId() + "|" + bundle.getLocation() + ">" + bundle.getSymbolicName());
return;
}
}
Bundle b = bc.installBundle(location);
debug("starting " + b.getSymbolicName());
b.start();
}
I noticed a problem: For example I have a bundle with xml configuration file and main bundle which loads the xml configuration file by deploying it into Felix and accessing the package into the xml bundle.
I can successfully install bundle from a bundle but the package which is exported by the dependency bundle is not accessible. Maybe the deployment procedure is too slow for the bundle loader to find the exported package. Any idea how this can be solved?
P.S can you tell me how I can check if a bundle is successfully deployed in Felix?