Package org.jboss.gravia.resource

Examples of org.jboss.gravia.resource.Capability


    }

    protected String getRuntimeName(Resource resource) {

        // #1 Try to get the runtime name from the identity capability
        Capability icap = resource.getIdentityCapability();
        String runtimeName = (String) icap.getAttribute(ContentNamespace.CAPABILITY_RUNTIME_NAME_ATTRIBUTE);

        // #2 Try to get the runtime name from the content cpability
        if (runtimeName == null) {
            List<ContentCapability> ccaps = getRelevantContentCapabilities(resource);
            if (ccaps.size() == 1) {
View Full Code Here


            Resource auxres = entry.getKey();
            Resource envres = environment.getResource(auxres.getIdentity());
            DefaultWiring envwiring = new DefaultWiring(envres, null, null);
            Wiring auxwiring = entry.getValue();
            for (Wire auxwire : auxwiring.getProvidedResourceWires(null)) {
                Capability auxcap = auxwire.getCapability();
                Capability envcap = findTargetCapability(auxcap);
                Requirement auxreq = auxwire.getRequirement();
                Requirement envreq = findTargetRequirement(auxreq);
                envwiring.addProvidedWire(new DefaultWire(envreq, envcap));
            }
            for (Wire auxwire : auxwiring.getRequiredResourceWires(null)) {
                Capability auxcap = auxwire.getCapability();
                Capability envcap = findTargetCapability(auxcap);
                Requirement auxreq = auxwire.getRequirement();
                Requirement envreq = findTargetRequirement(auxreq);
                envwiring.addRequiredWire(new DefaultWire(envreq, envcap));
            }
            AbstractEnvironment absenv = AbstractEnvironment.assertAbstractEnvironment(environment);
View Full Code Here

            if (!env.findProviders(req).isEmpty()) {
                continue;
            }

            // Continue if we cannot find a provider for a given requirement
            Capability cap = findProviderInRepository(req);
            if (cap == null) {
                continue;
            }

            installable.add(cap.getResource());
        }

        // Install the resources that match the unsatisfied reqs
        for (Resource res : installable) {
            if (!resources.contains(res)) {
View Full Code Here

        // Remove abstract resources
        if (providers.size() > 1) {
            providers = new ArrayList<Capability>(providers);
            Iterator<Capability> itcap = providers.iterator();
            while (itcap.hasNext()) {
                Capability cap = itcap.next();
                if (isAbstract(cap.getResource())) {
                    itcap.remove();
                }
            }
        }

        Capability cap = null;
        if (providers.size() == 1) {
            cap = providers.iterator().next();
            LOGGER.debug(" Found one: {}", cap);
        } else if (providers.size() > 1) {
            List<Capability> sorted = new ArrayList<Capability>(providers);
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

        IllegalArgumentAssertion.assertNotNull(symbolicName, "symbolicName");
        return addIdentityCapability(symbolicName, version, null, null);
    }

    public Capability addIdentityCapability(MavenCoordinates mavenid) {
        Capability icap = addIdentityCapability(MavenUtils.getSymbolicName(mavenid), MavenUtils.getVersion(mavenid), null, null);
        icap.getAttributes().put(ContentNamespace.CAPABILITY_MAVEN_IDENTITY_ATTRIBUTE, mavenid);
        return icap;
    }
View Full Code Here

    }

    @Override
    public Capability addIdentityCapability(String symbolicName, Version version, Map<String, Object> atts, Map<String, String> dirs) {
        IllegalArgumentAssertion.assertNotNull(symbolicName, "symbolicName");
        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

                    ModuleClassLoader modcl = (ModuleClassLoader) module.adapt(ClassLoader.class);
                    modid = modcl.getModule().getIdentifier();
                }
                // #2 Check the attached ModuleIdentifier
                if (modid == null) {
                    Capability icap = depres.getIdentityCapability();
                    modid = (ModuleIdentifier) icap.getAttribute(ModuleIdentifier.class.getName());
                }
                IllegalStateAssertion.assertNotNull(modid, "Cannot obtain module identifier from: " + depres);
               
                buffer.append("<module name='" + modid.getName() + "' slot='" + modid.getSlot() + "'/>");
                LOGGER.info("  {}", modid);
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.