Search in sources :

Example 6 with Felix

use of org.apache.felix.framework.Felix in project felix by apache.

the class FelixLauncher method start.

public void start() throws BundleException {
    StringBuffer autostart = new StringBuffer();
    for (int i = 0; i < bundles.size(); i++) {
        String bundle = (String) bundles.get(i);
        autostart.append(bundle).append(" ");
    }
    props.put("felix.auto.start.1", autostart.toString());
    StringBuffer spkg = new StringBuffer((String) packages.get(0));
    packages.remove(0);
    for (int i = 0; i < packages.size(); i++) {
        String pkg = (String) packages.get(i);
        spkg.append(", " + pkg);
    }
    props.put(Constants.FRAMEWORK_SYSTEMPACKAGES, spkg.toString());
    framework = new Felix(props, null);
    framework.start();
}
Also used : Felix(org.apache.felix.framework.Felix)

Example 7 with Felix

use of org.apache.felix.framework.Felix 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);
    }
}
Also used : Felix(org.apache.felix.framework.Felix) JarInputStream(java.util.jar.JarInputStream) InputStream(java.io.InputStream) BundleLoadingException(org.motechproject.server.ex.BundleLoadingException) OsgiException(org.eclipse.gemini.blueprint.OsgiException) ServletContext(javax.servlet.ServletContext) IOException(java.io.IOException) BundleException(org.osgi.framework.BundleException) Properties(java.util.Properties) WebApplicationContext(org.springframework.web.context.WebApplicationContext) BundleContext(org.osgi.framework.BundleContext)

Aggregations

Felix (org.apache.felix.framework.Felix)7 HashMap (java.util.HashMap)3 BundleException (org.osgi.framework.BundleException)3 File (java.io.File)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 Iterator (java.util.Iterator)2 Entry (java.util.Map.Entry)2 Properties (java.util.Properties)2 JarFile (java.util.jar.JarFile)2 ZipEntry (java.util.zip.ZipEntry)2 BundleContext (org.osgi.framework.BundleContext)2 InputStream (java.io.InputStream)1 MalformedURLException (java.net.MalformedURLException)1 List (java.util.List)1 Attributes (java.util.jar.Attributes)1 JarEntry (java.util.jar.JarEntry)1 JarInputStream (java.util.jar.JarInputStream)1 Manifest (java.util.jar.Manifest)1 ServletContext (javax.servlet.ServletContext)1