use of org.osgi.framework.Version in project aries by apache.
the class DeployedContentHeader method appendResource.
private static StringBuilder appendResource(Resource resource, StringBuilder builder, boolean referenced) {
String symbolicName = ResourceHelper.getSymbolicNameAttribute(resource);
Version version = ResourceHelper.getVersionAttribute(resource);
String type = ResourceHelper.getTypeAttribute(resource);
builder.append(symbolicName).append(';').append(Clause.ATTRIBUTE_DEPLOYEDVERSION).append('=').append(version.toString()).append(';').append(Clause.ATTRIBUTE_TYPE).append('=').append(type).append(';').append(Clause.ATTRIBUTE_RESOURCEID).append('=').append(Utils.getId(resource)).append(';').append(Clause.DIRECTIVE_REFERENCE).append(":=").append(referenced);
return builder;
}
use of org.osgi.framework.Version in project aries by apache.
the class RawSubsystemResource method createFakeResource.
private static Resource createFakeResource(SubsystemManifest manifest) {
Header<?> importServiceHeader = manifest.getHeaders().get(APPLICATION_IMPORT_SERVICE_HEADER);
if (importServiceHeader == null) {
return null;
}
List<Capability> modifiableCaps = new ArrayList<Capability>();
final List<Capability> fakeCapabilities = Collections.unmodifiableList(modifiableCaps);
Resource fakeResource = new Resource() {
@Override
public List<Capability> getCapabilities(String namespace) {
if (namespace == null) {
return fakeCapabilities;
}
List<Capability> results = new ArrayList<Capability>();
for (Capability capability : fakeCapabilities) {
if (namespace.equals(capability.getNamespace())) {
results.add(capability);
}
}
return results;
}
@Override
public List<Requirement> getRequirements(String namespace) {
return Collections.emptyList();
}
};
modifiableCaps.add(new OsgiIdentityCapability(fakeResource, Constants.ResourceTypeSynthesized, new Version(1, 0, 0), Constants.ResourceTypeSynthesized));
Map<String, Map<String, String>> serviceImports = ManifestHeaderProcessor.parseImportString(importServiceHeader.getValue());
for (Entry<String, Map<String, String>> serviceImport : serviceImports.entrySet()) {
Collection<String> objectClasses = new ArrayList<String>(Arrays.asList(serviceImport.getKey()));
String filter = serviceImport.getValue().get(IdentityNamespace.REQUIREMENT_FILTER_DIRECTIVE);
BasicCapability.Builder capBuilder = new BasicCapability.Builder();
capBuilder.namespace(ServiceNamespace.SERVICE_NAMESPACE);
capBuilder.attribute(ServiceNamespace.CAPABILITY_OBJECTCLASS_ATTRIBUTE, objectClasses);
if (filter != null)
capBuilder.attributes(new HashMap<String, Object>(SimpleFilter.attributes(filter)));
capBuilder.attribute("service.imported", "");
capBuilder.resource(fakeResource);
modifiableCaps.add(capBuilder.build());
}
return fakeResource;
}
use of org.osgi.framework.Version in project aries by apache.
the class ClientWeavingHookGenericCapabilityTest method mockConsumerBundle.
private Bundle mockConsumerBundle(Dictionary<String, String> headers, BundleRevision rev, Bundle... otherBundles) {
// Create a mock object for the client bundle which holds the code that uses ServiceLoader.load()
// or another SPI invocation.
BundleContext bc = EasyMock.createMock(BundleContext.class);
Bundle consumerBundle = EasyMock.createMock(Bundle.class);
EasyMock.expect(consumerBundle.getSymbolicName()).andReturn("testConsumer").anyTimes();
EasyMock.expect(consumerBundle.getVersion()).andReturn(new Version(1, 2, 3)).anyTimes();
EasyMock.expect(consumerBundle.getHeaders()).andReturn(headers).anyTimes();
EasyMock.expect(consumerBundle.getBundleContext()).andReturn(bc).anyTimes();
EasyMock.expect(consumerBundle.getBundleId()).andReturn(Long.MAX_VALUE).anyTimes();
EasyMock.expect(consumerBundle.adapt(BundleRevision.class)).andReturn(rev).anyTimes();
EasyMock.replay(consumerBundle);
List<Bundle> allBundles = new ArrayList<Bundle>(Arrays.asList(otherBundles));
allBundles.add(consumerBundle);
EasyMock.expect(bc.getBundles()).andReturn(allBundles.toArray(new Bundle[] {})).anyTimes();
EasyMock.replay(bc);
return consumerBundle;
}
use of org.osgi.framework.Version in project aries by apache.
the class AbstractHeader method appendResource.
// TODO This is specific to deployment manifests and shouldn't be at this level.
protected static void appendResource(Resource resource, StringBuilder builder) {
Map<String, Object> attributes = resource.getCapabilities(IdentityNamespace.IDENTITY_NAMESPACE).get(0).getAttributes();
String symbolicName = (String) attributes.get(IdentityNamespace.IDENTITY_NAMESPACE);
Version version = (Version) attributes.get(IdentityNamespace.CAPABILITY_VERSION_ATTRIBUTE);
String namespace = (String) attributes.get(IdentityNamespace.CAPABILITY_TYPE_ATTRIBUTE);
builder.append(symbolicName).append(';').append(DeployedVersionAttribute.NAME).append('=').append(version.toString()).append(';').append(TypeAttribute.NAME).append('=').append(namespace);
}
use of org.osgi.framework.Version in project aries by apache.
the class AriesSubsystemParentsHeader method getClause.
public Clause getClause(BasicSubsystem subsystem) {
String symbolicName = subsystem.getSymbolicName();
Version version = subsystem.getVersion();
String type = subsystem.getType();
for (Clause clause : clauses) {
if (symbolicName.equals(clause.getPath()) && clause.getVersion().equals(version) && type.equals(clause.getType()))
return clause;
}
return null;
}
Aggregations