Examples of Framework


Examples of org.osgi.framework.launch.Framework

        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

Examples of org.osgi.framework.launch.Framework

    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

Examples of org.osgi.framework.launch.Framework

    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

Examples of org.osgi.framework.launch.Framework


        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

Examples of org.osgi.framework.launch.Framework

         * 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

Examples of org.osgi.framework.launch.Framework

        boot.setBuildDir(outputDirectory);
        boot.setCarFile(getArtifactInRepositoryDir());
        boot.setLocalRepo(repository);
        boot.setPlan(planFile);
        Framework framework = getFramework(",org.apache.geronimo.deployment,org.apache.geronimo.deployment.service");
        BundleContext bundleContext = framework.getBundleContext();
        boot.setBundleContext(bundleContext);

        // Generate expanded so we can use Maven to generate the archive
        boot.setExpanded(true);

        boot.bootstrap();

        framework.stop();
        getLog().debug("Waiting for shutdown (up to 5 minutes)...");
        framework.waitForStop(60 * 5 * 1000);
    }
View Full Code Here

Examples of org.osgi.framework.launch.Framework

        AbstractName deployer = locateDeployer(kernel);
        invokeDeployer(kernel, deployer, targetConfigStoreAName.toString());
        //use a fresh kernel for each module
        kernel.shutdown();
        kernel = null;
        Framework framework = (Framework) bundleContext.getBundle();
        framework.stop();
        getLog().debug("Waiting for shutdown (up to 5 minutes)...");
        framework.waitForStop(60 * 5 * 1000);
        bundleContext = null;
    }
View Full Code Here

Examples of org.osgi.framework.launch.Framework

        Map<String, String> configuration = new HashMap<String, String>();
        configuration.put(Constants.FRAMEWORK_STORAGE, "target/papoose");

        final FrameworkFactory factory = new PapooseFrameworkFactory();
        Framework framework = factory.newFramework(configuration);

        framework.init();

        Bundle systemBundle = framework.getBundleContext().getBundle(0);
        BundleContext context = systemBundle.getBundleContext();

        Bundle testBundle = context.installBundle(location);

        long testBundleId = testBundle.getBundleId();

        assertTrue(testBundleId > 0);

        try
        {
            framework.uninstall();
            fail("Should have thrown an exception");
        }
        catch (BundleException e)
        {
        }

        framework.stop();

        framework = factory.newFramework(configuration);
        framework.init();

        systemBundle = framework.getBundleContext().getBundle(0);
        context = systemBundle.getBundleContext();

        testBundle = context.getBundle(testBundleId);
        assertNotNull(testBundleId);

        framework.start();
        testBundle.start();

        assertEquals(Bundle.ACTIVE, framework.getState());
        assertEquals(Bundle.ACTIVE, testBundle.getState());

        testBundle.uninstall();

        Dictionary headers = testBundle.getHeaders("en");
        Assert.assertEquals("org.papoose.test-support.bundle", headers.get("Bundle-SymbOLicName"));

        headers = testBundle.getHeaders("en");
        Assert.assertEquals("bundle_en", headers.get("L10N-Bundle"));

        headers = testBundle.getHeaders();
        Assert.assertEquals("bundle_en", headers.get("L10N-Bundle"));

        headers = testBundle.getHeaders(null);
        Assert.assertEquals("bundle_en", headers.get("L10N-Bundle"));

        headers = testBundle.getHeaders("en_US");
        Assert.assertEquals("bundle_en", headers.get("L10N-Bundle"));

        headers = testBundle.getHeaders("fr");
        Assert.assertEquals("bundle_fr", headers.get("L10N-Bundle"));

        headers = testBundle.getHeaders("fr_FR");
        Assert.assertEquals("bundle_fr_FR", headers.get("L10N-Bundle"));

        headers = testBundle.getHeaders("");
        Assert.assertEquals("%bundle", headers.get("L10N-Bundle"));

        headers = testBundle.getHeaders("en");
        Assert.assertEquals("no translation for this entry", headers.get("L10N-NoTranslation"));

        try
        {
            testBundle.start();
            fail("Cannot start an uninstalled bundle");
        }
        catch (IllegalStateException e)
        {
        }

        testBundle = context.getBundle(testBundleId);
        assertNull(testBundle);

        framework.stop();

        framework.init();

        systemBundle = framework.getBundleContext().getBundle(0);
        context = systemBundle.getBundleContext();

        testBundle = context.getBundle(testBundleId);
        assertNull(testBundle);

        framework.stop();
    }
View Full Code Here

Examples of org.osgi.framework.launch.Framework

    {
        Map<String, String> configuration = new HashMap<String, String>();
        configuration.put(Constants.FRAMEWORK_STORAGE, "target/papoose");

        FrameworkFactory factory = new PapooseFrameworkFactory();
        final Framework framework = factory.newFramework(configuration);

        FrameworkEvent frameworkEvent = framework.waitForStop(0);

        assertNotNull(frameworkEvent);
        assertEquals(FrameworkEvent.STOPPED, frameworkEvent.getType());
        assertSame(framework, frameworkEvent.getBundle());

        framework.init();

        Bundle systemBundle = framework.getBundleContext().getBundle(0);

        assertEquals(Bundle.STARTING, framework.getState());
        assertEquals(Bundle.STARTING, systemBundle.getState());

        ThreadPoolExecutor pool = new ThreadPoolExecutor(1, 1, 60, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>());

        try
        {
            Future<FrameworkEvent> result = pool.submit(new Callable<FrameworkEvent>()
            {
                public FrameworkEvent call() throws Exception
                {
                    return framework.waitForStop(0);
                }
            });

            framework.stop();

            frameworkEvent = result.get();

            assertNotNull(frameworkEvent);
            assertEquals(FrameworkEvent.STOPPED, frameworkEvent.getType());
            assertSame(systemBundle, frameworkEvent.getBundle());

            framework.waitForStop(0);
        }
        finally
        {
            pool.shutdown();
        }

        try
        {
            framework.waitForStop(-1);
            Assert.fail("Should never accept negative wait timeouts");
        }
        catch (IllegalArgumentException iae)
        {
        }

        frameworkEvent = framework.waitForStop(Long.MAX_VALUE);

        assertNotNull(frameworkEvent);
        assertEquals(FrameworkEvent.STOPPED, frameworkEvent.getType());
        assertSame(systemBundle, frameworkEvent.getBundle());

        framework.start();

        framework.stop();

        Thread.sleep(1);

        frameworkEvent = framework.waitForStop(0);

        assertNotNull(frameworkEvent);
        assertEquals(FrameworkEvent.STOPPED, frameworkEvent.getType());
        assertSame(systemBundle, frameworkEvent.getBundle());
    }
View Full Code Here

Examples of org.osgi.framework.launch.Framework

        else
        {
            papoose = new Papoose(store, executorService, properties);
        }

        Framework framework = new PapooseFramework(papoose);

        LOGGER.exiting(CLASS_NAME, "newFramework", framework);

        return framework;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.