Search in sources :

Example 1 with Attribute

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();
}
Also used : SubsystemContentHeader(org.apache.aries.subsystem.core.archive.SubsystemContentHeader) Capability(org.osgi.resource.Capability) Attribute(org.apache.aries.subsystem.core.archive.Attribute) HashMap(java.util.HashMap) Clause(org.apache.aries.subsystem.core.archive.SubsystemContentHeader.Clause)

Example 2 with Attribute

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));
}
Also used : Attribute(org.apache.aries.subsystem.core.archive.Attribute) Bundle(org.osgi.framework.Bundle)

Example 3 with Attribute

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();
}
Also used : Capability(org.osgi.resource.Capability) Attribute(org.apache.aries.subsystem.core.archive.Attribute) BundleRevision(org.osgi.framework.wiring.BundleRevision)

Aggregations

Attribute (org.apache.aries.subsystem.core.archive.Attribute)3 Capability (org.osgi.resource.Capability)2 HashMap (java.util.HashMap)1 SubsystemContentHeader (org.apache.aries.subsystem.core.archive.SubsystemContentHeader)1 Clause (org.apache.aries.subsystem.core.archive.SubsystemContentHeader.Clause)1 Bundle (org.osgi.framework.Bundle)1 BundleRevision (org.osgi.framework.wiring.BundleRevision)1