Package org.osgi.service.framework

Examples of org.osgi.service.framework.CompositeBundle


    }
   
    @Test
    public void testCompositeLifeCycle() {
        makeSUT();
        CompositeBundle  cb = composite("test.composite", "1.0.0");
        assertNoTrackers();
       
        // full lifecycle
       
        sut.addingBundle(cb, new BundleEvent(BundleEvent.INSTALLED, cb));
View Full Code Here


       
        sut.open();
    }
   
    private CompositeBundle composite(String symbolicName, String version) {
        CompositeBundle cb = Skeleton.newMock(CompositeBundle.class);
        Skeleton cbSkel = Skeleton.getSkeleton(cb);
        cbSkel.setReturnValue(new MethodCall(CompositeBundle.class, "getSymbolicName"), symbolicName);
        cbSkel.setReturnValue(new MethodCall(CompositeBundle.class, "getVersion"), new Version(version));
        return cb;
    }
View Full Code Here

  }

  protected void customizedProcessBundle(BundleTrackerCustomizer btc, Bundle b, BundleEvent event, boolean removing)
  {
    if (b instanceof CompositeBundle) {
      CompositeBundle cb = (CompositeBundle) b;
      // check if the compositeBundle is already tracked in the
      // BundleTrackerFactory
      String bundleScope = cb.getSymbolicName() + "_" + cb.getVersion().toString();
      List<BundleTracker> btList = BundleTrackerFactory.getBundleTrackerList(bundleScope);

      // bundle is already active and there is no event associated
      // this can happen when bundle is first time added to the tracker
      // or when the tracker is being closed.
      if (event == null && !!!removing) {
        if (cb.getState() == Bundle.INSTALLED || cb.getState() == Bundle.RESOLVED || cb.getState() == Bundle.STARTING || cb.getState() == Bundle.ACTIVE) {
          openTracker(btc, cb, bundleScope, mask);
        }
      } else {
        // if we are removing, or the event is of the right type then we need to shutdown.
        if (removing || event.getType() == BundleEvent.STOPPED || event.getType() == BundleEvent.UNRESOLVED || event.getType() == BundleEvent.UNINSTALLED) {
View Full Code Here

    CompositeHelper.validateCompositeManifest(compositeManifest);

    try {
      // get an in memory input stream to jar content of the composite we want to install
      InputStream content = CompositeHelper.getCompositeInput(frameworkConfig, compositeManifest);
      CompositeBundle result = (CompositeBundle) systemContext.installBundle(location, content);
      // set the permissions
      CompositeHelper.setCompositePermissions(location, systemContext);
      return result;
    } catch (IOException e) {
      throw new BundleException("Error creating composite bundle", e); //$NON-NLS-1$
View Full Code Here

    Bundle[] allBundles = systemContext.getBundles();
    // stop each child 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) {
View Full Code Here

        }
    }

    private void openTracker(BundleTrackerCustomizer btc, Bundle b, String bundleScope, int stateMask) {
         // let's process each of the bundle in the CompositeBundle
         CompositeBundle cb = (CompositeBundle) b;
         BundleContext compositeBundleContext = cb
                 .getCompositeFramework().getBundleContext();
   
         // let's track each of the bundle in the CompositeBundle
         BundleTracker bt = new BundleTracker(compositeBundleContext, stateMask, btc);
         bt.open();
View Full Code Here

            compositeManifest.put(Constants.IMPORT_PACKAGE, "org.osgi.service.blueprint;version=\"[1.0.0,2.0.0)\", org.osgi.service.blueprint.container;version=1.0");
            // this export-package is used by pax junit runner as it needs to see the blueprint sample package
            // for the test after the blueprint sample is started.
            compositeManifest.put(Constants.EXPORT_PACKAGE, "org.apache.aries.blueprint.sample");
           
            CompositeBundle cb = cbf.installCompositeBundle(frameworkConfig, "test-composite", compositeManifest);

            BundleContext compositeBundleContext = cb.getCompositeFramework().getBundleContext();
            // install the blueprint sample onto the framework associated with the composite bundle
            MavenArtifactProvisionOption mapo = mavenBundleInTest(getClass().getClassLoader(), "org.apache.aries.blueprint", "org.apache.aries.blueprint.sample");
            // let's use input stream to avoid invoking mvn url handler which isn't avail in the child framework.
            InputStream is = new URL(mapo.getURL()).openStream();
            Bundle bundle = compositeBundleContext.installBundle(mapo.getURL(), is);
            assertNotNull(bundle);
           
            // start the composite bundle then the blueprint sample
            cb.start();
            bundle.start();
           
            // start the blueprint bundle and it should detect the previously started blueprint sample
            Bundle blueprintBundle = context().getBundleByName("org.apache.aries.blueprint");
            blueprintBundle.start();
View Full Code Here

            compositeManifest.put(Constants.IMPORT_PACKAGE, "org.osgi.service.blueprint;version=\"[1.0.0,2.0.0)\", org.osgi.service.blueprint.container;version=1.0");
            // this export-package is used by pax junit runner as it needs to see the blueprint sample package
            // for the test after the blueprint sample is started.
            compositeManifest.put(Constants.EXPORT_PACKAGE, "org.apache.aries.blueprint.sample");
           
            CompositeBundle cb = cbf.installCompositeBundle(frameworkConfig, "test-composite", compositeManifest);

            BundleContext compositeBundleContext = cb.getCompositeFramework().getBundleContext();
            // install the blueprint sample onto the framework associated with the composite bundle
            MavenArtifactProvisionOption mapo = mavenBundleInTest(getClass().getClassLoader(), "org.apache.aries.blueprint", "org.apache.aries.blueprint.sample");
            // let's use input stream to avoid invoking mvn url handler which isn't avail in the child framework.
            InputStream is = new URL(mapo.getURL()).openStream();
            Bundle bundle = compositeBundleContext.installBundle(mapo.getURL(), is);
            assertNotNull(bundle);
           
            // start the composite bundle then the blueprint sample
            cb.start();
            bundle.start();

            // do the test
            Helper.testBlueprintContainer(new RichBundleContext(compositeBundleContext), bundle);
           
View Full Code Here

            compositeManifest.put(Constants.IMPORT_PACKAGE, "org.osgi.service.blueprint;version=\"[1.0.0,2.0.0)\", org.osgi.service.blueprint.container;version=1.0");
            // this export-package is used by pax junit runner as it needs to see the blueprint sample package
            // for the test after the blueprint sample is started.
            compositeManifest.put(Constants.EXPORT_PACKAGE, "org.apache.aries.blueprint.sample");
           
            CompositeBundle cb = cbf.installCompositeBundle(frameworkConfig, "test-composite", compositeManifest);

            BundleContext compositeBundleContext = cb.getCompositeFramework().getBundleContext();
            // install the blueprint sample onto the framework associated with the composite bundle
            MavenArtifactProvisionOption mapo = mavenBundleInTest("org.apache.aries.blueprint", "org.apache.aries.blueprint.sample");
            // let's use input stream to avoid invoking mvn url handler which isn't avail in the child framework.
            InputStream is = new URL(mapo.getURL()).openStream();
            Bundle bundle = compositeBundleContext.installBundle(mapo.getURL(), is);
            assertNotNull(bundle);
           
            // start the composite bundle then the blueprint sample
            cb.start();
            bundle.start();
           
            // start the blueprint bundle and it should detect the previously started blueprint sample
            Bundle blueprintBundle = getInstalledBundle("org.apache.aries.blueprint");
            blueprintBundle.start();
View Full Code Here

            compositeManifest.put(Constants.IMPORT_PACKAGE, "org.osgi.service.blueprint;version=\"[1.0.0,2.0.0)\", org.osgi.service.blueprint.container;version=1.0");
            // this export-package is used by pax junit runner as it needs to see the blueprint sample package
            // for the test after the blueprint sample is started.
            compositeManifest.put(Constants.EXPORT_PACKAGE, "org.apache.aries.blueprint.sample");
           
            CompositeBundle cb = cbf.installCompositeBundle(frameworkConfig, "test-composite", compositeManifest);

            BundleContext compositeBundleContext = cb.getCompositeFramework().getBundleContext();
            // install the blueprint sample onto the framework associated with the composite bundle
            MavenArtifactProvisionOption mapo = mavenBundleInTest("org.apache.aries.blueprint", "org.apache.aries.blueprint.sample");
            // let's use input stream to avoid invoking mvn url handler which isn't avail in the child framework.
            InputStream is = new URL(mapo.getURL()).openStream();
            Bundle bundle = compositeBundleContext.installBundle(mapo.getURL(), is);
            assertNotNull(bundle);
           
            // start the composite bundle then the blueprint sample
            cb.start();
            bundle.start();

            // do the test
            testBlueprintContainer(compositeBundleContext, bundle);
           
View Full Code Here

TOP

Related Classes of org.osgi.service.framework.CompositeBundle

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.