Search in sources :

Example 6 with SubsystemManifest

use of org.apache.aries.subsystem.core.archive.SubsystemManifest in project aries by apache.

the class ResolveContext method isValid.

private boolean isValid(Capability capability, Requirement requirement) throws BundleException, IOException, InvalidSyntaxException, URISyntaxException {
    if (IdentityNamespace.IDENTITY_NAMESPACE.equals(capability.getNamespace()))
        return true;
    Resource provider = capability.getResource();
    Resource requirer = requirement.getResource();
    SubsystemManifest manifest = resource.getSubsystemManifest();
    SubsystemContentHeader header = manifest.getSubsystemContentHeader();
    if (header.contains(provider) && header.contains(requirer)) {
        // are in the same region and the capability will be visible.
        return true;
    }
    Region from = findRegionForCapabilityValidation(provider);
    Region to = findRegionForCapabilityValidation(requirer);
    return new SharingPolicyValidator(from, to).isValid(capability);
}
Also used : SubsystemContentHeader(org.apache.aries.subsystem.core.archive.SubsystemContentHeader) SubsystemManifest(org.apache.aries.subsystem.core.archive.SubsystemManifest) Resource(org.osgi.resource.Resource) Region(org.eclipse.equinox.region.Region)

Example 7 with SubsystemManifest

use of org.apache.aries.subsystem.core.archive.SubsystemManifest in project aries by apache.

the class RawSubsystemResource method computeTranslations.

private Collection<TranslationFile> computeTranslations(IDirectory directory) throws IOException {
    SubsystemManifest manifest = getSubsystemManifest();
    SubsystemLocalizationHeader header = manifest.getSubsystemLocalizationHeader();
    String directoryName = header.getDirectoryName();
    // TODO Assumes the ZIP file includes directory entries. Issues?
    IFile file = directoryName == null ? directory : directory.getFile(directoryName);
    if (file == null || !file.isDirectory())
        return Collections.emptyList();
    List<IFile> files = file.convert().listFiles();
    if (files == null || files.isEmpty())
        return Collections.emptyList();
    ArrayList<TranslationFile> result = new ArrayList<TranslationFile>(files.size());
    for (IFile f : files) {
        Properties properties = new Properties();
        InputStream is = f.open();
        try {
            properties.load(is);
            result.add(new TranslationFile(f.getName(), properties));
        } finally {
            is.close();
        }
    }
    result.trimToSize();
    return result;
}
Also used : IFile(org.apache.aries.util.filesystem.IFile) SubsystemManifest(org.apache.aries.subsystem.core.archive.SubsystemManifest) InputStream(java.io.InputStream) ArrayList(java.util.ArrayList) SubsystemLocalizationHeader(org.apache.aries.subsystem.core.archive.SubsystemLocalizationHeader) Properties(java.util.Properties)

Example 8 with SubsystemManifest

use of org.apache.aries.subsystem.core.archive.SubsystemManifest in project aries by apache.

the class RawSubsystemResource method computeSubsystemTypeHeader.

private SubsystemTypeHeader computeSubsystemTypeHeader(SubsystemManifest manifest) {
    SubsystemTypeHeader header = manifest.getSubsystemTypeHeader();
    AriesProvisionDependenciesDirective directive = header.getAriesProvisionDependenciesDirective();
    if (directive != null) {
        // manifest. Validation of the value occurs later.
        return header;
    }
    // The directive was not specified in the original manifest. The value 
    // of the parent directive becomes the default.
    SubsystemManifest parentManifest = ((BasicSubsystem) parentSubsystem).getSubsystemManifest();
    SubsystemTypeHeader parentHeader = parentManifest.getSubsystemTypeHeader();
    directive = parentHeader.getAriesProvisionDependenciesDirective();
    header = new SubsystemTypeHeader(header.getValue() + ';' + directive);
    return header;
}
Also used : SubsystemManifest(org.apache.aries.subsystem.core.archive.SubsystemManifest) AriesProvisionDependenciesDirective(org.apache.aries.subsystem.core.archive.AriesProvisionDependenciesDirective) SubsystemTypeHeader(org.apache.aries.subsystem.core.archive.SubsystemTypeHeader)

Example 9 with SubsystemManifest

use of org.apache.aries.subsystem.core.archive.SubsystemManifest in project aries by apache.

the class Utils method isContent.

/*
	 * The Deployed-Content header in the deployment manifest is used to store
	 * information about explicitly installed resources and provisioned
	 * dependencies in addition to content for persistence purposes. This method
	 * returns true only if the resource is "true" content of the subsystem and,
	 * therefore, uses the Subsystem-Content header from the subsystem manifest.
	 */
public static boolean isContent(BasicSubsystem subsystem, Resource resource) {
    SubsystemManifest subsystemManifest = subsystem.getSubsystemManifest();
    if (subsystemManifest == null)
        return false;
    SubsystemContentHeader subsystemContentHeader = subsystemManifest.getSubsystemContentHeader();
    if (subsystemContentHeader == null)
        return false;
    return subsystemContentHeader.contains(resource);
}
Also used : SubsystemContentHeader(org.apache.aries.subsystem.core.archive.SubsystemContentHeader) SubsystemManifest(org.apache.aries.subsystem.core.archive.SubsystemManifest)

Aggregations

SubsystemManifest (org.apache.aries.subsystem.core.archive.SubsystemManifest)9 SubsystemContentHeader (org.apache.aries.subsystem.core.archive.SubsystemContentHeader)4 SubsystemTypeHeader (org.apache.aries.subsystem.core.archive.SubsystemTypeHeader)3 Resource (org.osgi.resource.Resource)3 Iterator (java.util.Iterator)2 AriesProvisionDependenciesDirective (org.apache.aries.subsystem.core.archive.AriesProvisionDependenciesDirective)2 InputStream (java.io.InputStream)1 ArrayList (java.util.ArrayList)1 Properties (java.util.Properties)1 GenericHeader (org.apache.aries.subsystem.core.archive.GenericHeader)1 ProvisionPolicyDirective (org.apache.aries.subsystem.core.archive.ProvisionPolicyDirective)1 SubsystemLocalizationHeader (org.apache.aries.subsystem.core.archive.SubsystemLocalizationHeader)1 IFile (org.apache.aries.util.filesystem.IFile)1 Region (org.eclipse.equinox.region.Region)1 Capability (org.osgi.resource.Capability)1 Requirement (org.osgi.resource.Requirement)1