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


         * That will result in ClassCastException.
         */
        resetFrameworkProperties();

        ServiceLoader<FrameworkFactory> loader = ServiceLoader.load(FrameworkFactory.class);
        Framework framework = loader.iterator().next().newFramework(properties);
        framework.start();
        //enable mvn url handling
//        new org.ops4j.pax.url.mvn.internal.Activator().start(framework.getBundleContext());
        //don't allow mvn urls
        if (systemProperties == null) {
            systemProperties = new HashMap<String, String>();
View Full Code Here

            + "Bundle-Version: 1.1.0\n"
            + "Bundle-ManifestVersion: 2\n"
            + "Import-Package: org.osgi.framework\n";
        File bundleFile = createBundle(mf, cacheDir);

        Framework f = new Felix(params);
        f.init();
        f.start();

        try {
            final Bundle bundle = f.getBundleContext().installBundle(bundleFile.toURI().toString());

            new Thread()
            {
                public void run()
                {
                    try
                    {
                        bundle.start();
                    }
                    catch (BundleException e)
                    {
                        e.printStackTrace();
                    }
                }
            }.start();
            Thread.sleep(DELAY / 4);
            long t0 = System.currentTimeMillis();
            bundle.stop();
            long t1 = System.currentTimeMillis();

            assertEquals(Bundle.RESOLVED, bundle.getState());
            assertTrue((t1 - t0) > DELAY / 2);

            bundle.start();

            new Thread()
            {
                public void run()
                {
                    try
                    {
                        bundle.stop();
                    }
                    catch (BundleException e)
                    {
                        e.printStackTrace();
                    }
                }
            }.start();
            Thread.sleep(DELAY / 4);
            t0 = System.currentTimeMillis();
            bundle.start();
            t1 = System.currentTimeMillis();

            assertEquals(Bundle.ACTIVE, bundle.getState());
            assertTrue((t1 - t0) > DELAY / 2);
        } finally {
            f.stop();
            deleteDir(cacheDir);
        }
    }
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.getLock();

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

    System.setProperty("karaf.home", home.toString());
    System.setProperty("karaf.data", data.toString());

    main = new Main(args);
    main.launch();
    Framework framework = main.getFramework();
    Bundle[] bundles = framework.getBundleContext().getBundles();
    Assert.assertEquals(3, bundles.length);
   
    // Give the framework some time to start the bundles
    Thread.sleep(1000);

    Bundle bundle1 = framework.getBundleContext().getBundle("mvn:org.apache.aries.blueprint/org.apache.aries.blueprint.api/1.0.0");
    Assert.assertEquals(Bundle.ACTIVE, bundle1.getState());

    Bundle bundle2 = framework.getBundleContext().getBundle("pax-url-mvn.jar");
    Assert.assertEquals(Bundle.ACTIVE, bundle2.getState());
  }
View Full Code Here

        try {
            Map<String, Object> frameworkProperties = createFrameworkProperties();
            if (m_verbose)
                System.out.println("Launching OSGi framework.. " + frameworkProperties);
            FrameworkFactory factory = createFrameworkFactory();
            Framework framework = factory.newFramework(frameworkProperties);
            framework.start();

            if (m_verbose)
                System.out.println("Configuring Management Agent.. " + m_configuration);
            BundleContext context = framework.getBundleContext();
            ServiceReference[] references = context.getServiceReferences(ManagementAgentFactory.class.getName(), null);
            if (references != null) {
                ManagementAgentFactory service = (ManagementAgentFactory) context.getService(references[0]);
                service.updated(m_configuration);
                context.ungetService(references[0]);
            }
            else {
                System.err.println("Can not find Management Agent config service! Aborting..");
                System.exit(1);
            }

            if (m_verbose)
                System.out.println("Startup complete..");
            framework.waitForStop(0);
        }
        catch (Exception e) {
            System.err.println(e.getMessage());
            e.printStackTrace();
            System.exit(1);
View Full Code Here

    public void run() throws Exception {
        Map frameworkProperties = createFrameworkProperties();
        FrameworkFactory factory = createFrameworkFactory();

        Framework framework = factory.newFramework(frameworkProperties);

        framework.start();

        try {
            framework.waitForStop(0);
        }
        finally {
            System.exit(0);
        }
    }
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

         * That will result in ClassCastException.
         */
        resetFrameworkProperties();

        ServiceLoader<FrameworkFactory> loader = ServiceLoader.load(FrameworkFactory.class);
        Framework framework = loader.iterator().next().newFramework(properties);
        framework.start();
        //enable mvn url handling
//        new org.ops4j.pax.url.mvn.internal.Activator().start(framework.getBundleContext());
        //don't allow mvn urls
        if (systemProperties == null) {
            systemProperties = new HashMap<String, String>();
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.