Package org.osgi.framework

Examples of org.osgi.framework.Bundle.adapt()


  }

  @Override
  public List<String> getImports(long bundleId) {
    Bundle bundle = bundleContext.getBundle(bundleId);
        BundleRevision rev = bundle.adapt(BundleRevision.class);
        List<BundleRequirement> reqs = rev.getDeclaredRequirements(BundleRevision.PACKAGE_NAMESPACE);
        List<String> imports = new ArrayList<String>();
        for (BundleRequirement req : reqs) {
            Map<String, String> attr = req.getDirectives();
            String filter = attr.get("filter");
View Full Code Here


            LOGGER.debug("Installing bundle " + bundleLocation);
            Bundle b = bundleContext.installBundle(bundleLocation, is);

            if (startLevel > 0) {
                b.adapt(BundleStartLevel.class).setStartLevel(startLevel);
            }

            return new BundleInstallerResult(b, true);
        } finally {
            is.close();
View Full Code Here

                        try {
                            // TODO: Workaround for PAXURL-278
                            String[] parts = location.contains("pax-url-aether") ? convertToMavenUrlsIfNeeded(location, false)
                                :  convertToMavenUrlsIfNeeded(location, convertToMavenUrls);
                            Bundle b = context.installBundle(parts[0], new URL(parts[1]).openStream());
                            b.adapt(BundleStartLevel.class).setStartLevel(startLevel);
                            bundles.add(b);
                        }
                        catch (Exception ex) {
                            System.err.println("Error installing bundle  " + location + ": " + ex);
                        }
View Full Code Here

        expect(bundleContext.getDataFile(EasyMock.<String>anyObject())).andReturn(dataFile).anyTimes();

        // refresh
        expect(bundleContext.getBundle(0)).andStubReturn(sysBundle);
        expect(sysBundle.adapt(FrameworkWiring.class)).andStubReturn(frameworkWiring);

        final Capture<FrameworkListener> listeners =  new Capture<FrameworkListener>();
        frameworkWiring.refreshBundles(EasyMock.<Collection<Bundle>>eq(null), capture(listeners));
        expectLastCall().andStubAnswer(new IAnswer<Object>() {
            public Object answer() throws Throwable {
View Full Code Here

        properties.save();
    }

    public void setStartLevel(int startLevel) {
        Bundle b = getBundleContext().getBundle(0);
        FrameworkStartLevel fsl = (FrameworkStartLevel) b.adapt(FrameworkStartLevel.class);
        fsl.setStartLevel(startLevel, null);
    }

    public int getStartLevel() {
        Bundle b = getBundleContext().getBundle(0);
View Full Code Here

        fsl.setStartLevel(startLevel, null);
    }

    public int getStartLevel() {
        Bundle b = getBundleContext().getBundle(0);
        FrameworkStartLevel fsl = (FrameworkStartLevel) b.adapt(FrameworkStartLevel.class);
        return fsl.getStartLevel();
    }

    /* for backward compatibility */

 
View Full Code Here

      LOGGER.debug("Installing bundle " + bundleLocation);
      Bundle b = bundleContext.installBundle(bundleLocation, is);

      if (startLevel > 0) {
        b.adapt(BundleStartLevel.class).setStartLevel(startLevel);
      }

      return new BundleInstallerResult(b, true);
    } finally {
      is.close();
View Full Code Here

    }

    try {
      // 刷新Bundle
      Bundle systemBundle = bundleContext.getBundle(0);
      FrameworkWiring frameworkWiring = systemBundle
          .adapt(FrameworkWiring.class);

      for (Bundle bundle : frameworkWiring.getRemovalPendingBundles()) {
        log.debug("RemovalPendingBundle:" + bundle.getSymbolicName());
      }
View Full Code Here

    }

    try {
      // 刷新Bundle
      Bundle systemBundle = bundleContext.getBundle(0);
      FrameworkWiring frameworkWiring = systemBundle
          .adapt(FrameworkWiring.class);

      for (Bundle bundle : frameworkWiring.getRemovalPendingBundles()) {
        logger.config("RemovalPendingBundle:"
            + bundle.getSymbolicName());
View Full Code Here

    /* (non-Javadoc)
     * @see org.osgi.jmx.framework.BundleRevisionsStateMBean#getCurrentRevisionDeclaredRequirements(long, java.lang.String)
     */
    public CompositeData[] getCurrentRevisionDeclaredRequirements(long bundleId, String namespace) throws IOException {
        Bundle bundle = FrameworkUtils.resolveBundle(bundleContext, bundleId);
        BundleRevision revision = bundle.adapt(BundleRevision.class);

        return BundleWiringData.getRequirementsCompositeData(revision.getDeclaredRequirements(namespace));
    }

    /* (non-Javadoc)
 
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.