use of org.apache.aries.subsystem.core.archive.Attribute in project aries by apache.
the class RawSubsystemResource method computeFileCapabilities.
private List<Capability> computeFileCapabilities(FileResource resource, IFile file, SubsystemManifest manifest) {
SubsystemContentHeader ssch = manifest.getSubsystemContentHeader();
if (ssch == null)
return Collections.emptyList();
for (Clause c : ssch.getClauses()) {
Attribute er = c.getAttribute(ContentHandler.EMBEDDED_RESOURCE_ATTRIBUTE);
if (er != null) {
if (file.getName().equals(er.getValue())) {
Map<String, Object> attrs = new HashMap<String, Object>();
attrs.put(ContentHandler.EMBEDDED_RESOURCE_ATTRIBUTE, er.getValue());
return Collections.<Capability>singletonList(new OsgiIdentityCapability(resource, c.getSymbolicName(), c.getVersionRange().getLeft(), c.getType(), attrs));
}
}
}
return Collections.emptyList();
}
use of org.apache.aries.subsystem.core.archive.Attribute in project aries by apache.
the class SubsystemResource method findContent.
private Resource findContent(DeployedContentHeader.Clause clause) throws BundleException, IOException, InvalidSyntaxException, URISyntaxException {
Attribute attribute = clause.getAttribute(DeployedContentHeader.Clause.ATTRIBUTE_RESOURCEID);
long resourceId = attribute == null ? -1 : Long.parseLong(String.valueOf(attribute.getValue()));
if (resourceId != -1) {
String type = clause.getType();
if (IdentityNamespace.TYPE_BUNDLE.equals(type) || IdentityNamespace.TYPE_FRAGMENT.equals(type)) {
Bundle resource = Activator.getInstance().getBundleContext().getBundle(0).getBundleContext().getBundle(resourceId);
if (resource == null)
return null;
return resource.adapt(BundleRevision.class);
} else
return Activator.getInstance().getSubsystems().getSubsystemById(resourceId);
}
return findContent(clause.toRequirement(this));
}
use of org.apache.aries.subsystem.core.archive.Attribute in project aries by apache.
the class SubsystemResource method findDependency.
private Resource findDependency(ProvisionResourceHeader.Clause clause) {
Attribute attribute = clause.getAttribute(DeployedContentHeader.Clause.ATTRIBUTE_RESOURCEID);
long resourceId = attribute == null ? -1 : Long.parseLong(String.valueOf(attribute.getValue()));
if (resourceId != -1) {
String type = clause.getType();
if (IdentityNamespace.TYPE_BUNDLE.equals(type) || IdentityNamespace.TYPE_FRAGMENT.equals(type))
return Activator.getInstance().getBundleContext().getBundle(0).getBundleContext().getBundle(resourceId).adapt(BundleRevision.class);
else
return Activator.getInstance().getSubsystems().getSubsystemById(resourceId);
}
OsgiIdentityRequirement requirement = new OsgiIdentityRequirement(clause.getPath(), clause.getDeployedVersion(), clause.getType(), true);
List<Capability> capabilities = createResolveContext().findProviders(requirement);
if (capabilities.isEmpty())
return null;
return capabilities.get(0).getResource();
}
Aggregations