Relationships relCap = (Relationships)resource.getCapability(MuwsConstants.RELATIONSHIPS_URI);
if(relCap == null) return;
BundleContribution provider = contribution.getServiceProvider();
if(provider != null){
WsResource targetResource = (WsResource)resourceForContribution.get(provider);
if(targetResource != null){
Participant[] participants = new Participant[2];
QName typeNames[] = {new QName("http://resource.management.osgi/Service","ServiceProvider","osgi")};
RelationshipType type = new SimpleRelationshipType(typeNames);
participants[0] = new SimpleParticipant(resource, "service");
participants[1] = new SimpleParticipant(targetResource, "provider");
relCap.addRelationship("ServiceConsumer", type, participants);
//Now add reciprocal relationship to the bundle resource
relCap = (Relationships)targetResource.getCapability(MuwsConstants.RELATIONSHIPS_URI);
participants = new Participant[2];
QName serviceTypeNames[] = {new QName("http://resource.management.osgi/Bundle","RegisteredService","osgi")};
type = new SimpleRelationshipType(serviceTypeNames);
participants[0] = new SimpleParticipant(resource, "service");
participants[1] = new SimpleParticipant(targetResource, "provider");
relCap.addRelationship("RegisteredService", type, participants);
}
}
BundleContribution[] consumers = contribution.getServiceConsumers();
if(consumers == null) return;
for(int i=0;i<consumers.length;i++){
BundleContribution dependency = consumers[i];
WsResource targetResource = (WsResource)resourceForContribution.get(dependency);
if(targetResource == null){
continue;
}
Participant[] participants = new Participant[2];
QName typeNames[] = {new QName("http://resource.management.osgi/Service","ServiceConsumer")};