Package org.jboss.gravia.resource

Examples of org.jboss.gravia.resource.Capability


                        moduleLoader.loadModule(modid);
                    } catch (ModuleLoadException ex) {
                        return null;
                    }
                    DefaultResourceBuilder builder = new DefaultResourceBuilder();
                    Capability icap = builder.addIdentityCapability(symbolicName, version);
                    icap.getAttributes().put(IdentityNamespace.CAPABILITY_TYPE_ATTRIBUTE, IdentityNamespace.TYPE_ABSTRACT);
                    icap.getAttributes().put(ModuleIdentifier.class.getName(), modid);
                    resource = cachedResources.addResource(builder.getResource());
                }
                return resource;
            }
        }
View Full Code Here


                            moduleLoader.loadModule(modid);
                        } catch (ModuleLoadException ex) {
                            continue;
                        }
                        DefaultResourceBuilder builder = new DefaultResourceBuilder();
                        Capability icap = builder.addIdentityCapability(symbolicName, version);
                        icap.getAttributes().put(IdentityNamespace.CAPABILITY_TYPE_ATTRIBUTE, IdentityNamespace.TYPE_ABSTRACT);
                        icap.getAttributes().put(ModuleIdentifier.class.getName(), modid);
                        Resource resource = cachedResources.addResource(builder.getResource());
                        result.add(resource.getIdentityCapability());
                    }
                }

                // Add the main module
                if (result.isEmpty()) {
                    ModuleIdentifier modid = ModuleIdentifier.fromString(symbolicName);
                    try {
                        moduleLoader.loadModule(modid);
                        DefaultResourceBuilder builder = new DefaultResourceBuilder();
                        Capability icap = builder.addIdentityCapability(symbolicName, Version.emptyVersion);
                        icap.getAttributes().put(IdentityNamespace.CAPABILITY_TYPE_ATTRIBUTE, IdentityNamespace.TYPE_ABSTRACT);
                        icap.getAttributes().put(ModuleIdentifier.class.getName(), modid);
                        Resource resource = cachedResources.addResource(builder.getResource());
                        result.add(resource.getIdentityCapability());
                    } catch (ModuleLoadException ex) {
                        // ignore
                    }
View Full Code Here

        buffer.append("  </resources>");
        buffer.append("  <dependencies>");
        for (Requirement req : res.getRequirements(IdentityNamespace.IDENTITY_NAMESPACE)) {
            Resource depres = mapping.get(req);
            if (depres != null) {
                Capability icap = depres.getIdentityCapability();
                String type = (String) icap.getAttribute(IdentityNamespace.CAPABILITY_TYPE_ATTRIBUTE);
                String modname = depres.getIdentity().getSymbolicName();
                if (!IdentityNamespace.TYPE_MODULE.equals(type)) {
                    modname = "deployment." + modname;
                }
                buffer.append("<module name='" + modname + "'/>");
View Full Code Here

                    return delagate.hasNext();
                }

                @Override
                public Wire next() {
                    Capability cap = delagate.next();
                    return createWire(req, cap);
                }

                @Override
                public void remove() {
View Full Code Here

            List<Capability> icaps = getCapabilities(IdentityNamespace.IDENTITY_NAMESPACE);
            if (icaps.size() > 1)
                throw new IllegalStateException("Multiple identity capabilities");
            if (icaps.size() < 1)
                throw new IllegalStateException("No identity capability");
            Capability icap = icaps.get(0);
            Object version = icap.getAttribute(IdentityNamespace.CAPABILITY_VERSION_ATTRIBUTE);
            if (!(version instanceof Version)) {
                version = version == null ? Version.emptyVersion : Version.parseVersion(version.toString());
                icap.getAttributes().put(IdentityNamespace.CAPABILITY_VERSION_ATTRIBUTE, version);
            }
            identityCapability = icap;
        }
        return identityCapability;
    }
View Full Code Here

    }

    @Override
    public ResourceIdentity getIdentity() {
        if (identity == null) {
            Capability icap = getIdentityCapability();
            String symbolicName = (String) icap.getAttribute(IdentityNamespace.IDENTITY_NAMESPACE);
            Version version = (Version) icap.getAttribute(IdentityNamespace.CAPABILITY_VERSION_ATTRIBUTE);
            identity = ResourceIdentity.create(symbolicName, version);
        }
        return identity;
    }
View Full Code Here

        required.add(wire);
    }

    public void addProvidedWire(Wire wire) {

        Capability cap = wire.getCapability();
        List<Wire> nswires = provided.get(cap.getNamespace());
        if (nswires == null) {
            nswires = new ArrayList<Wire>();
            provided.put(cap.getNamespace(), nswires);
        }

        // Ensures an implementation delivers a bundle wiring's provided wires in
        // the proper order. The ordering rules are as follows.
        //
View Full Code Here

    @Override
    public List<Capability> getResourceCapabilities(String namespace) {
        List<Capability> result = new ArrayList<Capability>();
        for (Wire wire : getProvidedResourceWires(namespace)) {
            Capability req = wire.getCapability();
            result.add(req);
        }
        return Collections.unmodifiableList(result);
    }
View Full Code Here

        return addIdentityCapability(symbolicName, version, null, null);
    }

    @Override
    public Capability addIdentityCapability(String symbolicName, Version version, Map<String, Object> atts, Map<String, String> dirs) {
        Capability icap = addCapability(IdentityNamespace.IDENTITY_NAMESPACE, symbolicName);
        if (version != null) {
            icap.getAttributes().put(IdentityNamespace.CAPABILITY_VERSION_ATTRIBUTE, version);
        }
        if (atts != null) {
            icap.getAttributes().putAll(atts);
        }
        if (dirs != null) {
            icap.getDirectives().putAll(dirs);
        }
        return icap;
    }
View Full Code Here

            List<Capability> icaps = getCapabilities(IdentityNamespace.IDENTITY_NAMESPACE);
            if (icaps.size() > 1)
                throw new IllegalStateException("Multiple identity capabilities");
            if (icaps.size() < 1)
                throw new IllegalStateException("No identity capability");
            Capability icap = icaps.get(0);
            Object version = icap.getAttribute(IdentityNamespace.CAPABILITY_VERSION_ATTRIBUTE);
            if (!(version instanceof Version)) {
                version = version == null ? Version.emptyVersion : Version.parseVersion(version.toString());
                icap.getAttributes().put(IdentityNamespace.CAPABILITY_VERSION_ATTRIBUTE, version);
            }
            identityCapability = icap;
        }
        return identityCapability;
    }
View Full Code Here

TOP

Related Classes of org.jboss.gravia.resource.Capability

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.