contract.setCallbackInterface(null);
callbackReference.setInterfaceContract(contract);
} catch (CloneNotSupportedException e) {
// will not happen
}
Service implService = service.getService();
if (implService != null) {
// If the implementation service is a CompositeService, ensure that the Reference that is
// created is a CompositeReference, otherwise create a Reference
Reference implReference;
if (implService instanceof CompositeService) {
CompositeReference implCompReference = assemblyFactory.createCompositeReference();
// Set the promoted component from the promoted component of the composite service
implCompReference.getPromotedComponents().add(((CompositeService)implService)
.getPromotedComponent());
// Get the promoted component reference corresponding to the service with the callback
// fist checking that the promoted service is resolved lest we get a NPE trying to
// retrieve the promoted component. It could be unresolved if the user gets the
// promotes string wrong
// TODO - is there any danger that the callback reference name will clash with other
// reference names. Old code used to qualify it with promoted component name
if (((CompositeService)implService).getPromotedService().isUnresolved() == false){
String referenceName = ((CompositeService)implService).getPromotedService().getName();
ComponentReference promotedReference = ((CompositeService)implService).getPromotedComponent().getReference(referenceName);
if (promotedReference != null){
implCompReference.getPromotedReferences().add(promotedReference);
} else {
Monitor.error(monitor,
this,
Messages.ASSEMBLY_VALIDATION,
"PromotedCallbackReferenceNotFound",
component.getName(),
service.getName(),
((CompositeService)implService).getPromotedComponent().getName(),
referenceName);
}
}
implReference = implCompReference;
// Add the composite reference to the composite implementation artifact
Implementation implementation = component.getImplementation();
if (implementation != null && implementation instanceof Composite) {
((Composite)implementation).getReferences().add(implCompReference);
}
} else {
implReference = assemblyFactory.createReference();
}
implReference.setName(implService.getName());
// MJE: Fixup multiplicity as 0..n for callback references in the component type
implReference.setMultiplicity(Multiplicity.ZERO_N);
try {
InterfaceContract implContract = (InterfaceContract)implService.getInterfaceContract().clone();
implContract.setInterface(implContract.getCallbackInterface());
implContract.setCallbackInterface(null);
implReference.setInterfaceContract(implContract);
} catch (CloneNotSupportedException e) {
// will not happen