use of org.osgi.resource.Resource in project aries by apache.
the class ResolveContext method isProcessableAsFragment.
private boolean isProcessableAsFragment(Requirement requirement) {
Resource resource = requirement.getResource();
String namespace = requirement.getNamespace();
return Utils.isFragment(resource) && !(ExecutionEnvironmentNamespace.EXECUTION_ENVIRONMENT_NAMESPACE.equals(namespace) || HostNamespace.HOST_NAMESPACE.equals(namespace));
}
use of org.osgi.resource.Resource in project aries by apache.
the class ResolveContext method installDependenciesOfRequirerIfNecessary.
private void installDependenciesOfRequirerIfNecessary(Requirement requirement) {
if (requirement == null) {
return;
}
Resource requirer = requirement.getResource();
if (resource.equals(requirer)) {
return;
}
Collection<BasicSubsystem> subsystems;
if (requirer instanceof BasicSubsystem) {
BasicSubsystem subsystem = (BasicSubsystem) requirer;
subsystems = Collections.singletonList(subsystem);
} else if (requirer instanceof BundleRevision) {
BundleRevision revision = (BundleRevision) requirer;
BundleConstituent constituent = new BundleConstituent(null, revision);
subsystems = Activator.getInstance().getSubsystems().getSubsystemsByConstituent(constituent);
} else {
return;
}
for (BasicSubsystem subsystem : subsystems) {
if (Utils.isProvisionDependenciesInstall(subsystem) || !State.INSTALLING.equals(subsystem.getState())) {
continue;
}
AccessController.doPrivileged(new StartAction(subsystem, subsystem, subsystem, Restriction.INSTALL_ONLY));
}
}
use of org.osgi.resource.Resource in project aries by apache.
the class ResolveContext method processAsBundle.
private void processAsBundle(Requirement requirement, List<Capability> capabilities) {
String namespace = requirement.getNamespace();
Resource bundle = requirement.getResource();
Wiring wiring = wirings.get(bundle);
List<Wire> wires = wiring.getRequiredResourceWires(namespace);
processWires(wires, requirement, capabilities);
}
use of org.osgi.resource.Resource in project aries by apache.
the class Aries1368Test method testApplicationWithFragmentInArchiveWithSubsystemContentHeaderWithType.
@Test
public void testApplicationWithFragmentInArchiveWithSubsystemContentHeaderWithType() throws Exception {
Subsystem applicationA = installSubsystemFromFile(APPLICATION_A);
try {
assertConstituents(3, applicationA);
startSubsystem(applicationA);
assertBundleState(Bundle.ACTIVE, BUNDLE_A, applicationA);
assertBundleState(Bundle.RESOLVED, FRAGMENT_A, applicationA);
Bundle bundle = context(applicationA).getBundleByName(FRAGMENT_A);
assertNotNull("Bundle not found: " + FRAGMENT_A, bundle);
Resource resource = bundle.adapt(BundleRevision.class);
Capability capability = resource.getCapabilities(IdentityNamespace.IDENTITY_NAMESPACE).get(0);
assertEquals("Wrong type", IdentityNamespace.TYPE_FRAGMENT, capability.getAttributes().get(IdentityNamespace.CAPABILITY_TYPE_ATTRIBUTE));
} finally {
stopAndUninstallSubsystemSilently(applicationA);
}
}
use of org.osgi.resource.Resource in project aries by apache.
the class Aries1368Test method testApplicationWithFragmentInRepositoryWithSubsystemContentHeaderWithType.
@Test
public void testApplicationWithFragmentInRepositoryWithSubsystemContentHeaderWithType() throws Exception {
Subsystem applicationB = installSubsystemFromFile(APPLICATION_B);
try {
assertConstituents(3, applicationB);
startSubsystem(applicationB);
assertBundleState(Bundle.ACTIVE, BUNDLE_A, applicationB);
assertBundleState(Bundle.RESOLVED, FRAGMENT_A, applicationB);
Bundle bundle = context(applicationB).getBundleByName(FRAGMENT_A);
assertNotNull("Bundle not found: " + FRAGMENT_A, bundle);
Resource resource = bundle.adapt(BundleRevision.class);
Capability capability = resource.getCapabilities(IdentityNamespace.IDENTITY_NAMESPACE).get(0);
String type = String.valueOf(capability.getAttributes().get(IdentityNamespace.CAPABILITY_TYPE_ATTRIBUTE));
assertEquals("Wrong type", IdentityNamespace.TYPE_FRAGMENT, type);
} finally {
stopAndUninstallSubsystemSilently(applicationB);
}
}
Aggregations