public static Version getVersion(Capability cap, String attname) { Object attval = cap.getAttributes().get(attname); if (attval != null && !(attval instanceof Version)) { attval = new Version(attval.toString()); cap.getAttributes().put(attname, attval); } return attval != null ? (Version) attval : Version.emptyVersion; }
@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; }
static CacheKey create(Capability cap) { String namespace = cap.getNamespace(); String nsvalue = (String) cap.getAttributes().get(namespace); return new CacheKey(namespace, nsvalue); }
@Override public Capability getIdentityCapability() { if (identityCapability == null) { 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; }
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; }
@Override public boolean match(Capability cap, Requirement req) { Map<String, Object> reqatts = req.getAttributes(); Map<String, Object> capatts = cap.getAttributes(); reqatts = new HashMap<String, Object>(req.getAttributes()); reqatts.remove(IdentityNamespace.CAPABILITY_VERSION_ATTRIBUTE); capatts = new HashMap<String, Object>(cap.getAttributes()); capatts.remove(IdentityNamespace.CAPABILITY_VERSION_ATTRIBUTE);
public CompositeData getCompositeData(Capability cap) throws OpenDataException { String namespace = cap.getNamespace(); CompositeData[] attsData = new AttributesType().getCompositeData(cap.getAttributes()); CompositeData[] dirsData = new DirectivesType().getCompositeData(cap.getDirectives()); Object[] itemValues = new Object[] { namespace, attsData, dirsData }; return new CompositeDataSupport(compositeType, getItemNames(), itemValues); }
@Override public ResourceBuilder fromResource(Resource res) { for (Capability cap : res.getCapabilities(null)) { addCapability(cap.getNamespace(), cap.getAttributes(), cap.getDirectives()); } for (Requirement req : res.getRequirements(null)) { addRequirement(req.getNamespace(), req.getAttributes(), req.getDirectives()); } return this; }
Map<String, Object> attsD = builderD.addIdentityCapability(residD).getAttributes(); attsD.put(ContentNamespace.CAPABILITY_RUNTIME_NAME_ATTRIBUTE, RESOURCE_D + ".war"); builderD.addContentCapability(deployer.getDeployment(RESOURCE_D));
icapE.getAttributes().put(ContentNamespace.CAPABILITY_RUNTIME_NAME_ATTRIBUTE, RESOURCE_E + ".war"); builderE.addContentCapability(deployer.getDeployment(RESOURCE_E)); builderE.addIdentityRequirement("org.apache.camel.core", new VersionRange("[2.11,3.0)"));
Map<String, Object> attsC = builderC.getMutableResource().getIdentityCapability().getAttributes(); attsC.put(ContentNamespace.CAPABILITY_RUNTIME_NAME_ATTRIBUTE, RESOURCE_C + ".war"); ResourceHandle handleC = provisioner.installResource(builderC.getResource());