Package org.osgi.framework.launch

Examples of org.osgi.framework.launch.Framework


        boot.setBuildDir(outputDirectory);
        boot.setCarFile(getArtifactInRepositoryDir());
        boot.setLocalRepo(repository);
        boot.setPlan(planFile);
        Framework framework = getFramework();
        BundleContext bundleContext = framework.getBundleContext();
        boot.setBundleContext(bundleContext);

        // Keep the same behavior with RepositoryConfigurationStore
        boot.setExpanded(false);
View Full Code Here


        Main main = new Main(args);
        main.launch();
        Thread.sleep(1000);
       
        Framework framework = main.getFramework();
        String activatorName = TimeoutShutdownActivator.class.getName().replace('.', '/') + ".class";
        Bundle bundle = framework.getBundleContext().installBundle("foo",
                TinyBundles.newBundle()
                    .set( Constants.BUNDLE_ACTIVATOR, TimeoutShutdownActivator.class.getName() )
                    .add( activatorName, getClass().getClassLoader().getResourceAsStream( activatorName ) )
                    .build( withBnd() )
        );
        bundle.start();      
       
        BundleContext ctx = framework.getBundleContext();
        ServiceReference[] refs = ctx.getServiceReferences(StartLevel.class.getName(), null);
        StartLevel sl = (StartLevel) ctx.getService(refs[0]);

        MockLock lock = (MockLock) main.getLock();
View Full Code Here

    System.setProperty("karaf.maven.convert", "false");

    Main main = new Main(args);
    main.launch();
    Thread.sleep(1000);
    Framework framework = main.getFramework();
    Bundle[] bundles = framework.getBundleContext().getBundles();
    Assert.assertEquals(3, bundles.length);
    Assert.assertEquals(fileMVNbundle, bundles[1].getLocation());
    Assert.assertEquals(mvnUrl, bundles[2].getLocation());
    Assert.assertEquals(Bundle.ACTIVE, bundles[1].getState());
    Assert.assertEquals(Bundle.ACTIVE, bundles[2].getState());
View Full Code Here


        Main main = new Main(args);
        main.launch();
        Thread.sleep(1000);
        Framework framework = main.getFramework();
        String activatorName = TimeoutShutdownActivator.class.getName().replace('.', '/') + ".class";
        Bundle bundle = framework.getBundleContext().installBundle("foo",
                TinyBundles.newBundle()
                    .set( Constants.BUNDLE_ACTIVATOR, TimeoutShutdownActivator.class.getName() )
                    .add( activatorName, getClass().getClassLoader().getResourceAsStream( activatorName ) )
                    .build( withBnd() )
        );
View Full Code Here

    System.setProperty("karaf.maven.convert", "false");

    Main main = new Main(args);
    main.launch();
    Thread.sleep(1000);
    Framework framework = main.getFramework();
    Bundle[] bundles = framework.getBundleContext().getBundles();
    Assert.assertEquals(3, bundles.length);
    Assert.assertEquals(fileMVNbundle, bundles[1].getLocation());
    Assert.assertEquals(mvnUrl, bundles[2].getLocation());
    Assert.assertEquals(Bundle.ACTIVE, bundles[1].getState());
    Assert.assertEquals(Bundle.ACTIVE, bundles[2].getState());
View Full Code Here


        Main main = new Main(args);
        main.launch();
        Thread.sleep(1000);
        Framework framework = main.getFramework();
        String activatorName = TimeoutShutdownActivator.class.getName().replace('.', '/') + ".class";
        Bundle bundle = framework.getBundleContext().installBundle("foo",
                TinyBundles.newBundle()
                    .set( Constants.BUNDLE_ACTIVATOR, TimeoutShutdownActivator.class.getName() )
                    .add( activatorName, getClass().getClassLoader().getResourceAsStream( activatorName ) )
                    .build( withBnd() )
        );
View Full Code Here

            BundleProvider[] bundleProviders = loadBundleProviders();

            logVerbose("Launching OSGi framework\n- factory:\t%s\n- properties:\t%s\n- providers:\t%s\n",
                frameworkFactory.getClass().getName(), m_configuration, Arrays.toString(bundleProviders));

            Framework framework = frameworkFactory.newFramework(m_configuration);
            framework.init();

            BundleContext context = framework.getBundleContext();

            for (BundleProvider bundleProvider : bundleProviders) {
                installBundles(context, bundleProvider);
            }

            framework.start();

            logVerbose("Startup complete...");

            framework.waitForStop(0);
        }
        catch (Exception e) {
            e.printStackTrace(System.err);
            rc = 1;
        }
View Full Code Here

        return karaf.getFramework();
    }

    @Override
    protected BundleContext startFramework() throws BundleException {
        Framework framework = karaf.getFramework();
        return framework.getBundleContext();
    }
View Full Code Here


        Main main = new Main(args);
        main.launch();
        Thread.sleep(1000);
        Framework framework = main.getFramework();
        String activatorName = TimeoutShutdownActivator.class.getName().replace('.', '/') + ".class";
        Bundle bundle = framework.getBundleContext().installBundle("foo",
                TinyBundles.newBundle()
                    .set( Constants.BUNDLE_ACTIVATOR, TimeoutShutdownActivator.class.getName() )
                    .add( activatorName, getClass().getClassLoader().getResourceAsStream( activatorName ) )
                    .build( withBnd() )
        );
View Full Code Here

        System.setProperty("karaf.lock.delay","1000");
        System.setProperty("karaf.lock.class","org.apache.karaf.main.MockLock");

        Main main = new Main(args);
        main.launch();
        Framework framework = main.getFramework();
        String activatorName = TimeoutShutdownActivator.class.getName().replace('.', '/') + ".class";
        Bundle bundle = framework.getBundleContext().installBundle("foo",
                TinyBundles.bundle()
                    .set( Constants.BUNDLE_ACTIVATOR, TimeoutShutdownActivator.class.getName() )
                    .add( activatorName, getClass().getClassLoader().getResourceAsStream( activatorName ) )
                    .build( withBnd() )
        );
       
        bundle.start();      
       
        Thread.sleep(2000);
       
        FrameworkStartLevel sl = framework.adapt(FrameworkStartLevel.class);
       
        MockLock lock = (MockLock) main.getLockManager().getLock();       

        Assert.assertEquals(100, sl.getStartLevel());      
View Full Code Here

TOP

Related Classes of org.osgi.framework.launch.Framework

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.