use of org.apache.aries.subsystem.core.archive.PreferredProviderHeader in project aries by apache.
the class BigApplicationTest method createApplication.
private InputStream createApplication(String symbolicName) throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ZipOutputStream zos = new ZipOutputStream(baos);
addBundles(zos, "preferredbundle", "package", Constants.EXPORT_PACKAGE);
addBundles(zos, "exportbundle", "package", Constants.EXPORT_PACKAGE);
addBundles(zos, "importbundle", "package", Constants.IMPORT_PACKAGE);
zos.putNextEntry(new ZipEntry("OSGI-INF/SUBSYSTEM.MF"));
StringBuilder preferredProviders = new StringBuilder("preferredbundle0;type=osgi.bundle");
for (int i = 1; i < BUNDLE_COUNT; i++) {
preferredProviders.append(",preferredbundle").append(i).append(";type=osgi.bundle");
}
new SubsystemManifest.Builder().symbolicName(symbolicName).type(SubsystemConstants.SUBSYSTEM_TYPE_APPLICATION).header(new PreferredProviderHeader(preferredProviders.toString())).build().write(zos);
zos.closeEntry();
zos.close();
return new ByteArrayInputStream(baos.toByteArray());
}
use of org.apache.aries.subsystem.core.archive.PreferredProviderHeader in project aries by apache.
the class SubsystemResolverHook method filterMatches.
public void filterMatches(BundleRequirement requirement, Collection<BundleCapability> candidates) {
// Filter out candidates that don't come from preferred providers when
// there is at least one preferred provider.
// (1) Find the subsystem(s) containing requirement.getResource() as a
// constituent.
Collection<BasicSubsystem> requirers = subsystems.getSubsystemsReferencing(requirement.getResource());
// (2) For each candidate, ask each subsystem if the candidate or any of
// the candidate's containing subsystems is a preferred provider. If at
// least one preferred provider exists, filter out all other candidates
// that are not also preferred providers.
Collection<BundleCapability> preferredProviders = new ArrayList<BundleCapability>(candidates.size());
for (BundleCapability candidate : candidates) for (BasicSubsystem subsystem : requirers) {
PreferredProviderHeader header = subsystem.getSubsystemManifest().getPreferredProviderHeader();
if (header != null && (header.contains(candidate.getResource()) || isResourceConstituentOfPreferredSubsystem(candidate.getResource(), subsystem)))
preferredProviders.add(candidate);
}
if (!preferredProviders.isEmpty())
candidates.retainAll(preferredProviders);
}
use of org.apache.aries.subsystem.core.archive.PreferredProviderHeader in project aries by apache.
the class ManyFeaturesWithSharedBundlesTest method createApplication.
private InputStream createApplication(String symbolicName) throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ZipOutputStream zos = new ZipOutputStream(baos);
addBundles(zos, "applicationbundle", "package", Constants.IMPORT_PACKAGE);
zos.putNextEntry(new ZipEntry("OSGI-INF/SUBSYSTEM.MF"));
StringBuilder preferredProviders = new StringBuilder("featurebundle0;type=osgi.bundle");
for (int i = 1; i < BUNDLE_COUNT; i++) {
preferredProviders.append(",featurebundle").append(i).append(";type=osgi.bundle");
}
new SubsystemManifest.Builder().symbolicName(symbolicName).type(SubsystemConstants.SUBSYSTEM_TYPE_APPLICATION).header(new PreferredProviderHeader(preferredProviders.toString())).build().write(zos);
zos.closeEntry();
zos.close();
return new ByteArrayInputStream(baos.toByteArray());
}
Aggregations