Package org.osgi.service.framework

Examples of org.osgi.service.framework.CompositeBundle


  }

  protected void customizedProcessBundle(BundleTrackerCustomizer btc, Bundle b, BundleEvent event)
  {
    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
      if (event == null) {
        if (cb.getState() == Bundle.INSTALLED || cb.getState() == Bundle.RESOLVED || cb.getState() == Bundle.STARTING || cb.getState() == Bundle.ACTIVE) {
          openTracker(btc, cb, bundleScope, mask);
        }
      } else {
        if (event.getType() == BundleEvent.STOPPED || event.getType() == BundleEvent.UNRESOLVED || event.getType() == BundleEvent.UNINSTALLED) {
          // if CompositeBundle is being stopped, let's remove the bundle
View Full Code Here


    }
   
    @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

            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 = CoreOptions.mavenBundle().groupId("org.apache.aries.blueprint").artifactId("org.apache.aries.blueprint.sample").version( "0.1-incubating-SNAPSHOT");
            // 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

    ServiceReference sr = bc.getServiceReference(CompositeBundleFactory.class.getName());

    if (sr != null) {
      CompositeBundleFactory cbf = (CompositeBundleFactory) bc.getService(sr);

      CompositeBundle compositeBundle = cbf.installCompositeBundle(
          config.getFrameworkProperties(),
          config.getFrameworkID(),
          config.getFrameworkManifest());

      framework = new BundleFrameworkImpl(compositeBundle);
View Full Code Here

  }

  protected void customizedProcessBundle(BundleTrackerCustomizer btc, Bundle b, BundleEvent event)
  {
    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
      if (event == null) {
        if (cb.getState() == Bundle.INSTALLED || cb.getState() == Bundle.RESOLVED || cb.getState() == Bundle.STARTING || cb.getState() == Bundle.ACTIVE) {
          openTracker(btc, cb, bundleScope, mask);
        }
      } else {
        if (event.getType() == BundleEvent.STOPPED) {
          // if CompositeBundle is being stopped, let's remove the bundle
View Full Code Here

        InternalRecursiveBundleTracker sut = new InternalRecursiveBundleTracker(context,
                Bundle.INSTALLED | Bundle.STARTING | Bundle.ACTIVE | Bundle.STOPPING, customizer);
       
        sut.open();
       
        CompositeBundle cb = Skeleton.newMock(CompositeBundle.class);
        Skeleton cbSkel = Skeleton.getSkeleton(cb);
        cbSkel.setReturnValue(new MethodCall(CompositeBundle.class, "getSymbolicName"), "test.composite");
        cbSkel.setReturnValue(new MethodCall(CompositeBundle.class, "getVersion"), new Version("1.0.0"));
       
        assertTrue(BundleTrackerFactory.getAllBundleTracker().isEmpty());
View Full Code Here

            // frameworkConfig.put("osgi.console", "10000");
           
            // construct composite bundle information
            Map<String, String> compositeManifest = getCompositeManifest();
           
            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);
            // install and start the cfg admin bundle in the isolated framework
            Bundle cfgAdminBundle = installConfigurationAdmin(compositeBundleContext);
            assertNotNull(cfgAdminBundle);           
           
            // start the composite bundle, the config admin then the blueprint sample
            cb.start();
            cfgAdminBundle.start();        
            // create a config to check the property placeholder
            applyCommonConfiguration(compositeBundleContext);
            bundle.start();
           
View Full Code Here

            // frameworkConfig.put("osgi.console", "10000");
           
            // construct composite bundle information
            Map<String, String> compositeManifest = getCompositeManifest();
           
            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);
            Bundle configAdminBundle = installConfigurationAdmin(compositeBundleContext);
            assertNotNull(configAdminBundle);
           
            // start the composite bundle, config admin then the blueprint sample
            cb.start();
            configAdminBundle.start();
            applyCommonConfiguration(compositeBundleContext);
            bundle.start();

            // do the test
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.