use of org.eclipse.gemini.blueprint.OsgiException in project motech by motech.
the class PlatformActivator method registerMdsStartupListener.
private void registerMdsStartupListener() {
Dictionary<String, String[]> properties = new Hashtable<>();
properties.put(EventConstants.EVENT_TOPIC, new String[] { PlatformConstants.MDS_STARTUP_TOPIC });
bundleContext.registerService(EventHandler.class.getName(), new EventHandler() {
@Override
public void handleEvent(Event event) {
try {
postMdsStartup();
} catch (ClassNotFoundException e) {
throw new OsgiException(e);
}
}
}, properties);
}
use of org.eclipse.gemini.blueprint.OsgiException in project motech by motech.
the class OsgiFrameworkService method start.
/**
* Initialize, install and start bundles and the OSGi framework
*/
public void start() {
try {
LOGGER.info("Starting OSGi framework");
osgiFramework.start();
registerJndiLookupService();
Bundle platformBundle = OsgiBundleUtils.findBundleBySymbolicName(osgiFramework.getBundleContext(), PlatformConstants.PLATFORM_BUNDLE_SYMBOLIC_NAME);
if (platformBundle == null) {
throw new OsgiException(PlatformConstants.PLATFORM_BUNDLE_SYMBOLIC_NAME + " not found");
}
LOGGER.info("Starting the Platform Bundle");
platformBundle.start();
LOGGER.info("OSGi framework started");
} catch (BundleException e) {
throw new OsgiException("Failed to start OSGi framework", e);
}
}
use of org.eclipse.gemini.blueprint.OsgiException in project motech by motech.
the class OsgiFrameworkService method init.
public void init(BootstrapConfig bootstrapConfig) {
try (InputStream is = getClass().getResourceAsStream("/osgi.properties")) {
Properties properties = readOSGiProperties(bootstrapConfig, is);
this.setOsgiFramework(new Felix(properties));
} catch (IOException e) {
throw new OsgiException("Cannot read OSGi properties", e);
}
try {
LOGGER.info("Initializing OSGi framework");
ServletContext servletContext = ((WebApplicationContext) applicationContext).getServletContext();
osgiFramework.init();
BundleContext bundleContext = osgiFramework.getBundleContext();
// This is mandatory for Felix http servlet bridge
servletContext.setAttribute(BundleContext.class.getName(), bundleContext);
if (bootstrapConfig != null) {
LOGGER.info("Installing all available bundles");
installAllBundles(servletContext, bundleContext);
registerBundleLoaderExecutor();
}
platformStatusProxy = new PlatformStatusProxy(bundleContext);
LOGGER.info("OSGi framework initialization finished");
} catch (BundleLoadingException e) {
throw new OsgiException("Failed to start the OSGi framework, unable to load bundles", e);
} catch (BundleException e) {
throw new OsgiException("Failed to start the OSGi framework, error processing bundles", e);
} catch (IOException e) {
throw new OsgiException("Failed to start the OSGi framework, IO Error", e);
}
}
use of org.eclipse.gemini.blueprint.OsgiException in project motech by motech.
the class OsgiFrameworkService method stop.
/**
* Stop the OSGi framework.
*/
public void stop() {
try {
if (osgiFramework != null) {
osgiFramework.stop();
LOGGER.info("OSGi framework stopped");
}
} catch (BundleException e) {
throw new OsgiException("Error stopping OSGi framework", e);
}
}
Aggregations