Package org.osgi.framework

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


        for (Artifact artifact : getArtifacts()) {
            if (artifact.getBundleId() > 0) {
                Bundle bundle = context.getBundle(artifact.getBundleId());
                if (bundle != null) {
                    if (bundle.getState() != Bundle.STARTING && bundle.getState() != Bundle.ACTIVE
                            && (useStartTransient || bundle.adapt(BundleStartLevel.class).isPersistentlyStarted())
                            && startLevelSvc.getStartLevel() >= bundle.adapt(BundleStartLevel.class).getStartLevel()) {
                        bundles.add(bundle);
                    }
                }
            }
View Full Code Here


            if (artifact.getBundleId() > 0) {
                Bundle bundle = context.getBundle(artifact.getBundleId());
                if (bundle != null) {
                    if (bundle.getState() != Bundle.STARTING && bundle.getState() != Bundle.ACTIVE
                            && (useStartTransient || bundle.adapt(BundleStartLevel.class).isPersistentlyStarted())
                            && startLevelSvc.getStartLevel() >= bundle.adapt(BundleStartLevel.class).getStartLevel()) {
                        bundles.add(bundle);
                    }
                }
            }
        }
View Full Code Here

        // Install the bundle as module if it has not already happened
        // A bundle that could not get resolved will have no associated module
        Runtime runtime = RuntimeLocator.getRequiredRuntime();
        Module module = runtime.getModule(identity);
        BundleWiring wiring = bundle.adapt(BundleWiring.class);
        if (module == null && wiring != null) {
            try {
                ClassLoader classLoader = wiring.getClassLoader();
                module = runtime.installModule(classLoader, resource, null);
            } catch (ModuleException ex) {
View Full Code Here

  public Object execute(CommandLine commandLine)
    throws Exception
  {
    Bundle system = Platform.getBundle("system.bundle");
    FrameworkWiring framework =
      (FrameworkWiring)system.adapt(FrameworkWiring.class);

    ArrayList<Bundle> bundles = new ArrayList<Bundle>();
    bundles.add(Platform.getBundle("org.eclim.core"));
    framework.refreshBundles(bundles, new FrameworkListener[0]);
View Full Code Here

                Deployment andep = method.getAnnotation(Deployment.class);
                if (andep.managed() && andep.testable() && method.isAnnotationPresent(StartLevelAware.class)) {
                    int bundleStartLevel = method.getAnnotation(StartLevelAware.class).startLevel();
                    Bundle bundle = getBundle(testCase);
                    log.fine("Setting bundle start level of " + bundle + " to: " + bundleStartLevel);
                    BundleStartLevel startLevel = bundle.adapt(BundleStartLevel.class);
                    startLevel.setStartLevel(bundleStartLevel);
                }
            }
        }
    }
View Full Code Here

        // skip first bundle
        iterator.next();
        // attempt to load the class from the remaining bundles
        while (iterator.hasNext()) {
            Bundle bundle = iterator.next();
            BundleWiring wiring = bundle.adapt(BundleWiring.class);
            if (wiring != null) {
                List<BundleCapability> capabilities = wiring.getCapabilities(BundleRevision.PACKAGE_NAMESPACE);
                if (capabilities != null && !capabilities.isEmpty()) {
                    for (BundleCapability capability : capabilities) {
                        Map<String, Object> attributes = capability.getAttributes();
View Full Code Here

                if (andep.managed() && andep.testable() && method.isAnnotationPresent(StartLevelAware.class)) {
                    StartLevelAware startLevelAware = method.getAnnotation(StartLevelAware.class);
                    int bundleStartLevel = startLevelAware.startLevel();
                    Bundle bundle = getBundle(testCase);
                    log.fine("Setting bundle start level of " + bundle + " to: " + bundleStartLevel);
                    BundleStartLevel startLevel = bundle.adapt(BundleStartLevel.class);
                    startLevel.setStartLevel(bundleStartLevel);
                    if (startLevelAware.autostart()) {
                        try {
                            bundle.start();
                        } catch (BundleException ex) {
View Full Code Here

      Bundle provider = persistenceProvider.getBundle();
      String suffix = ";" + Constants.BUNDLE_SYMBOLICNAME_ATTRIBUTE + "=" +
      provider.getSymbolicName() + ";" + Constants.BUNDLE_VERSION_ATTRIBUTE
      + "=" + provider.getVersion();

      BundleRevision br = provider.adapt(BundleWiring.class).getRevision();
      for(BundleCapability bc : br.getDeclaredCapabilities(BundleRevision.PACKAGE_NAMESPACE)) {
        packageImportsToAdd.add(bc.getAttributes().get(BundleRevision.PACKAGE_NAMESPACE) + suffix);
      }
    }
  }
View Full Code Here

    }

    public void setBundleStartLevel(long bundleId, int startLevel) throws RemoteException,
        BundleException {
        Bundle bundle = bundleContext.getBundle(bundleId);
        bundle.adapt(BundleStartLevel.class).setStartLevel(startLevel);
    }

    public void waitForState(final long bundleId, final int state, final RelativeTimeout timeout) {
        Bundle bundle = bundleContext.getBundle(bundleId);
        if (bundle == null || (timeout.isNoWait() && (bundle == null || bundle.getState() < state))) {
View Full Code Here

                if (bi != null) {
                    int sl = bi.getStartLevel() > 0 ? bi.getStartLevel() : dstate.initialBundleStartLevel;
                    startLevels.put(resource, sl);
                    Bundle bundle = deployment.resToBnd.get(resource);
                    if (bundle != null) {
                        int curSl = bundle.adapt(BundleStartLevel.class).getStartLevel();
                        if (sl != curSl) {
                            toUpdateStartLevel.put(bundle, sl);
                            if (sl > dstate.currentStartLevel) {
                                toStop.add(bundle);
                            }
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.