try {
Boolean graviaEnabled = Boolean.parseBoolean(getHeaders().get(Constants.GRAVIA_ENABLED));
String moduleActivatorName = getHeaders().get(Constants.MODULE_ACTIVATOR);
String bundleActivatorName = getHeaders().get("Bundle-Activator");
if (moduleActivatorName != null || bundleActivatorName != null) {
ModuleActivator moduleActivator;
synchronized (MODULE_ACTIVATOR_KEY) {
moduleActivator = getAttachment(MODULE_ACTIVATOR_KEY);
if (moduleActivator == null) {
if (moduleActivatorName != null) {
Object result = loadClass(moduleActivatorName).newInstance();
moduleActivator = (ModuleActivator) result;
putAttachment(MODULE_ACTIVATOR_KEY, moduleActivator);
} else if (bundleActivatorName != null && graviaEnabled) {
Object result = loadClass(bundleActivatorName).newInstance();
moduleActivator = new ModuleActivatorBridge((BundleActivator) result);
putAttachment(MODULE_ACTIVATOR_KEY, moduleActivator);
}
}
}
if (moduleActivator != null) {
moduleActivator.start(getModuleContext());
}
}
}
// If the {@code ModuleActivator} is invalid or throws an exception then: