Examples of Framework


Examples of org.osgi.framework.launch.Framework

            + "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();
            Thread.sleep(DELAY);
            deleteDir(cacheDir);
        }
    }
View Full Code Here

Examples of org.osgi.framework.launch.Framework

        ServiceEvent event = new ServiceEvent(ServiceEvent.REGISTERED, sr);

        assertEquals("Precondition failed", 0, fired.size());

        Framework framework = EasyMock.createNiceMock(Framework.class);
        EasyMock.replay(new Object[]
            {
                framework
            });
View Full Code Here

Examples of org.osgi.framework.launch.Framework

        try {

            // initiate startup handler
            final StartupManager startupManager = new StartupManager(props, logger);

            Framework tmpFramework = createFramework(notifiable, logger, props);
            init(tmpFramework);

            final boolean restart = new BootstrapInstaller(tmpFramework.getBundleContext(), logger,
                    resourceProvider, startupManager.getMode()).install();
            startupManager.markInstalled();

            if (restart) {
                restart(tmpFramework);
                tmpFramework = createFramework(notifiable, logger, props);
                init(tmpFramework);
            }

            new DefaultStartupHandler(tmpFramework.getBundleContext(), logger, startupManager);

            // finally start
            tmpFramework.start();

            // only assign field if start succeeds
            this.framework = tmpFramework;
        } catch (final BundleException be) {
            throw be;
View Full Code Here

Examples of org.osgi.framework.launch.Framework

     * delegatee servlet if one is set at all.
     */
    public final void destroy() {
        if (framework != null) {
            // get a private copy of the reference and remove the class ref
            Framework myFramework;
            synchronized (this) {
                myFramework = framework;
                framework = null;
            }

            // shutdown the Felix container
            if (myFramework != null) {
                logger.log(Logger.LOG_INFO, "Shutting down Apache Sling");
                try {

                    myFramework.stop();
                    myFramework.waitForStop(0);

                } catch (BundleException be) {

                    // may be thrown by stop, log but continue
                    logger.log(Logger.LOG_ERROR,
View Full Code Here

Examples of org.osgi.framework.launch.Framework

    for (int i = 0; i < allBundles.length; i++) {
      if (!(allBundles[i] instanceof CompositeBundle))
        continue;
      CompositeBundle composite = (CompositeBundle) allBundles[i];
      try {
        Framework child = composite.getCompositeFramework();
        child.stop();
        // need to wait for each child to stop
        child.waitForStop(30000);
        // TODO need to figure out a way to invalid the child
      } catch (Throwable t) {
        // TODO consider logging
        t.printStackTrace();
      }
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();
        BundleContext bundleContext = framework.getBundleContext();
        boot.setBundleContext(bundleContext);

        // Keep the same behavior with RepositoryConfigurationStore
        boot.setExpanded(false);
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

            + "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

Examples of org.osgi.framework.launch.Framework

        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

Examples of org.osgi.framework.launch.Framework

    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
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.