Examples of BundleWiring


Examples of org.osgi.framework.wiring.BundleWiring

        // Install the bundle as module if it has not already happened
        // A bundle that could not get resolved will not have an 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

Examples of org.osgi.framework.wiring.BundleWiring

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

        // Create the {@link URLStreamHandlerTracker}
View Full Code Here

Examples of org.osgi.framework.wiring.BundleWiring

        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

Examples of org.osgi.framework.wiring.BundleWiring

        return 0;
    }

    public BundleWiring getWiring()
    {
        return new BundleWiring()
        {

            public Bundle getBundle()
            {
                return PojoSRBundle.this;
View Full Code Here

Examples of org.osgi.framework.wiring.BundleWiring

            for (Entry<BundleRevision, BundleWiringImpl> entry : wirings.entrySet())
            {
                BundleRevisionImpl revision = (BundleRevisionImpl) entry.getKey();

                // Mark revision as resolved.
                BundleWiring wiring = entry.getValue();
                revision.resolve(entry.getValue());

                // Record dependencies.
                for (BundleWire bw : wiring.getRequiredWires(null))
                {
                    m_felix.getDependencies().addDependent(bw);
                }

                // Reindex the revision's capabilities since its resolved
View Full Code Here

Examples of org.osgi.framework.wiring.BundleWiring

        if (imports == null  || ! imports.contains("org.apache.felix.ipojo.configuration")) {
            // TODO Check dynamic imports to verify if the package is not imported lazily.
            return;
        }

        BundleWiring wiring = bundle.adapt(BundleWiring.class);
        if (wiring == null) {
            // Invalid state.
            m_logger.log(Log.ERROR, "The bundle " + bundle.getBundleId() + " (" + bundle.getSymbolicName() + ") " +
                    "cannot be adapted to BundleWiring, state: " + bundle.getState());
            return;
        }

        // Only lookup for local classes, parent classes will be analyzed on demand.
        Collection<String> resources = wiring.listResources("/", "*.class",
                BundleWiring.FINDENTRIES_RECURSE + BundleWiring.LISTRESOURCES_LOCAL);
        if (resources == null) {
            m_logger.log(Log.ERROR, "The bundle " + bundle.getBundleId() + " (" + bundle.getSymbolicName() + ") " +
                    " does not have any classes to be analyzed");
            return;
        }
        m_logger.log(Log.DEBUG, resources.size() + " classes found");
        handleResources(bundle, resources, wiring.getClassLoader());
    }
View Full Code Here

Examples of org.osgi.framework.wiring.BundleWiring

        Set<Bundle> bundles = tree.flatten();
        Map<String, Set<Bundle>> exports = new HashMap<String, Set<Bundle>>();

        for (Bundle bundle : bundles) {
            for (BundleRevision revision : bundle.adapt(BundleRevisions.class).getRevisions()) {
                BundleWiring wiring = revision.getWiring();
                if (wiring != null) {
                    List<BundleWire> wires = wiring.getProvidedWires(BundleRevision.PACKAGE_NAMESPACE);
                    if (wires != null) {
                        for (BundleWire wire : wires) {
                            String name = wire.getCapability().getAttributes().get(BundleRevision.PACKAGE_NAMESPACE).toString();
                            if (exports.get(name) == null) {
                                exports.put(name, new HashSet<Bundle>());
View Full Code Here

Examples of org.osgi.framework.wiring.BundleWiring

     */
    private void createNodeForImport(Node<Bundle> node, Bundle bundle, Clause i) {
        VersionRange range = VersionRange.parseVersionRange(i.getAttribute(Constants.VERSION_ATTRIBUTE));
        boolean foundMatch = false;
        for (Bundle b : bundleContext.getBundles()) {
            BundleWiring wiring = b.adapt(BundleWiring.class);
            if (wiring != null) {
                List<BundleCapability> caps = wiring.getCapabilities(BundleRevision.PACKAGE_NAMESPACE);
                if (caps != null) {
                    for (BundleCapability cap : caps) {
                        String n = getAttribute(cap, BundleRevision.PACKAGE_NAMESPACE);
                        String v = getAttribute(cap, Constants.VERSION_ATTRIBUTE);
                        if (i.getName().equals(n) && range.contains(VersionTable.getVersion(v))) {
View Full Code Here

Examples of org.osgi.framework.wiring.BundleWiring

    protected void findResource() {
        Bundle[] bundles = getBundleContext().getBundles();
        String filter = "*" + className + "*";
        for (Bundle bundle:bundles){
            BundleWiring wiring = bundle.adapt(BundleWiring.class);
            if (wiring != null){
                Collection<String> resources = wiring.listResources("/", filter, BundleWiring.LISTRESOURCES_RECURSE);
                if (resources.size() > 0){
                    String title = ShellUtil.getBundleName(bundle);
                    System.out.println("\n" + title);
                }
                for (String resource:resources){
View Full Code Here

Examples of org.osgi.framework.wiring.BundleWiring

            {
                System.out.println("");
            }

            // Print out any matching generic capabilities.
            BundleWiring wiring = b.adapt(BundleWiring.class);
            if (wiring != null)
            {
                String title = b + " provides:";
                System.out.println(title);
                System.out.println(ShellUtil.getUnderlineString(title));
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.