Package org.osgi.framework.wiring

Examples of org.osgi.framework.wiring.BundleWiring


    public Map<String, Bundle> getWiredBundles(Bundle bundle) {
        // the set of bundles from which the bundle imports packages
        Map<String, Bundle> exporters = new HashMap<String, Bundle>();

        for (BundleRevision revision : bundle.adapt(BundleRevisions.class).getRevisions()) {
            BundleWiring wiring = revision.getWiring();
            if (wiring != null) {
                List<BundleWire> wires = wiring.getRequiredWires(BundleRevision.PACKAGE_NAMESPACE);
                if (wires != null) {
                    for (BundleWire wire : wires) {
                        if (wire.getProviderWiring().getBundle().getBundleId() != 0) {
                            exporters.put(wire.getCapability().getAttributes().get(BundleRevision.PACKAGE_NAMESPACE).toString(),
                                          wire.getProviderWiring().getBundle());
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) {
                throw new ProvisionException(ex);
            }
        }
View Full Code Here

    // when system is shutting down we disable eviction of bundles to keep things stable
    return super.evictBundle(bundle) && (systemBundle.getState() & Bundle.STOPPING) == 0;
  }

  private void prepareDependencies(final Bundle bundle) {
    final BundleWiring wiring = bundle.adapt(BundleWiring.class);
    final List<BundleWire> wires = wiring.getRequiredWires(BundleRevision.PACKAGE_NAMESPACE);
    if (wires != null) {
      for (BundleWire wire : wires) {
        try {
          final Bundle dependency = wire.getProviderWiring().getBundle();
          if (visited.add(dependency.getSymbolicName()) && hasComponents(dependency)) {
View Full Code Here

    @Override
    public ClassLoader getClassLoader(Bundle bundle) {
        if (bundle == null) {
            return null;
        }
        BundleWiring wiring = bundle.adapt(BundleWiring.class);
        if (wiring == null) {
            return null;
        }
        return wiring.getClassLoader();
    }
View Full Code Here

  protected void verifyBundleWiring() {
    Bundle bundle = Mockito.verify(_bundle);

    bundle.adapt(BundleWiring.class);

    BundleWiring bundleWiring = Mockito.verify(_bundleWiring);

    bundleWiring.getClassLoader();
  }
View Full Code Here

  public ClassLoader getClassLoader() {
    ClassLoader classLoader = (ClassLoader)_contextAttributes.get(
      PluginContextListener.PLUGIN_CLASS_LOADER);

    if (classLoader == null) {
      BundleWiring bundleWiring = _bundle.adapt(BundleWiring.class);

      classLoader = bundleWiring.getClassLoader();

      _contextAttributes.put(
        PluginContextListener.PLUGIN_CLASS_LOADER, classLoader);
    }
View Full Code Here

            throw new IllegalArgumentException("Not the system bundle: " + syscontext.getBundle());

        // Install system module
        try {
            Resource resource = new DefaultResourceBuilder().addIdentityCapability(getSystemIdentity()).getResource();
            BundleWiring wiring = syscontext.getBundle().adapt(BundleWiring.class);
            installModule(wiring.getClassLoader(), resource, null, null);
        } catch (ModuleException ex) {
            throw new IllegalStateException("Cannot install system module", ex);
        }

        installListener = new SynchronousBundleListener() {
View Full Code Here

        Module module = getModule(bundle.getBundleId());
        if (module != null)
            return module;

        BundleWiring wiring = bundle.adapt(BundleWiring.class);
        ClassLoader classLoader = wiring != null ? wiring.getClassLoader() : null;
        if (classLoader == null)
            return null;

        Resource resource = ThreadResourceAssociation.getResource();
        Dictionary<String, String> headers = bundle.getHeaders();
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) {
                throw new ProvisionException(ex);
            }
        }
View Full Code Here

        }
    }

    private void loadImplementationsInBundle(final Test test, final String packageName) {
        //Do not remove the cast on the next line as removing it will cause a compile error on Java 7.
        final BundleWiring wiring = (BundleWiring) FrameworkUtil.getBundle(
                ResolverUtil.class).adapt(BundleWiring.class);
        final Collection<String> list = wiring.listResources(packageName, "*.class",
            BundleWiring.LISTRESOURCES_RECURSE);
        for (final String name : list) {
            addIfMatching(test, name);
        }
    }
View Full Code Here

TOP

Related Classes of org.osgi.framework.wiring.BundleWiring

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.