if (bundleGeneration.getState() != Bundle.STARTING) return;
final BundleController bundleController = bundleGeneration.getBundleController();
ArchiveStore archiveStore = bundleGeneration.getArchiveStore();
fireBundleEvent(new BundleEvent(BundleEvent.STARTING, bundleController));
bundleGeneration.getClassLoader().setLazyActivation(false);
try
{
String bundleActivatorClassName = archiveStore.getBundleActivatorClass();
if (bundleActivatorClassName != null)
{
Class bundleActivatorClass = bundleGeneration.getClassLoader().loadClass(bundleActivatorClassName);
if (bundleActivatorClass == null) throw new BundleException("Bundle activator class " + bundleActivatorClassName + " not found");
final BundleActivator bundleActivator = (BundleActivator) bundleActivatorClass.newInstance();
bundleController.setBundleActivator(bundleActivator);
SecurityUtils.doPrivilegedExceptionAction(new PrivilegedExceptionAction<Void>()
{
public Void run() throws Exception
{
bundleActivator.start(bundleController.getBundleContext());
return null;
}
},
framework.getAcc());
}
bundleGeneration.setState(Bundle.ACTIVE);
fireBundleEvent(new BundleEvent(BundleEvent.STARTED, bundleController));
return;
}
catch (ClassNotFoundException cnfe)
{
LOGGER.log(Level.WARNING, "Unable to load bundle activator class", cnfe);
}
catch (InstantiationException ie)
{
LOGGER.log(Level.WARNING, "Unable to instantiate bundle activator class", ie);
}
catch (IllegalAccessException iae)
{
LOGGER.log(Level.WARNING, "Unable to instantiate bundle activator class", iae);
}
catch (ClassCastException cce)
{
LOGGER.log(Level.WARNING, "Bundle activator not an instance of BundleActivator", cce);
}
catch (Throwable t)
{
LOGGER.log(Level.WARNING, "Unable to start bundle activator class", t);
}
bundleGeneration.setState(Bundle.STOPPING);
fireBundleEvent(new BundleEvent(BundleEvent.STOPPING, bundleController));
bundleGeneration.setState(Bundle.RESOLVED);
fireBundleEvent(new BundleEvent(BundleEvent.STOPPED, bundleController));
}
catch (InterruptedException ie)
{
Thread.currentThread().interrupt();
throw new BundleException("Interrupted while waiting to start bundle", ie);