contract.setCallbackInterface(null);
callbackService.setInterfaceContract(contract);
} catch (CloneNotSupportedException e) {
// will not happen
}
Reference implReference = reference.getReference();
if (implReference != null) {
// If the implementation reference is a CompositeReference, ensure that the Service that is
// created is a CompositeService, otherwise create a Service
Service implService;
if (implReference instanceof CompositeReference) {
CompositeService implCompService = assemblyFactory.createCompositeService();
// TODO The reality here is that the composite reference which has the callback COULD promote more than
// one component reference - and there must be a separate composite callback service for each of these component
// references
// Set the promoted component from the promoted component of the composite reference
implCompService.setPromotedComponent(((CompositeReference)implReference).getPromotedComponents().get(0));
implCompService.setForCallback(true);
// Get the promoted component service corresponding to the reference with the callback
// fist checking that the promoted reference 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
if (((CompositeReference)implReference).getPromotedReferences().get(0).isUnresolved() == false){
String serviceName = ((CompositeReference)implReference).getPromotedReferences().get(0).getName();
ComponentService promotedService = ((CompositeReference)implReference).getPromotedComponents().get(0).getService(serviceName);
if (promotedService != null){
implCompService.setPromotedService(promotedService);
} else {
Monitor.error(monitor,
this,
Messages.ASSEMBLY_VALIDATION,
"PromotedCallbackServiceNotFound",
component.getName(),
reference.getName(),
((CompositeReference)implReference).getPromotedComponents().get(0).getName(),
serviceName);
}
}
implService = implCompService;
// Add the composite service to the composite implementation artifact
Implementation implementation = component.getImplementation();
if (implementation != null && implementation instanceof Composite) {
((Composite)implementation).getServices().add(implCompService);
} // end if
//
} else {
implService = assemblyFactory.createService();
} // end if
//
implService.setName(implReference.getName());
try {
InterfaceContract implContract = (InterfaceContract)implReference.getInterfaceContract().clone();
implContract.setInterface(implContract.getCallbackInterface());
implContract.setCallbackInterface(null);
implService.setInterfaceContract(implContract);
} catch (CloneNotSupportedException e) {
// will not happen