Operation operation = chain.getOperation();
TargetInvoker invoker = reference.createTargetInvoker(contract, operation);
chain.setTargetInvoker(invoker);
chain.prepare();
}
OutboundWire outboundWire = reference.getOutboundWire();
// connect the reference's inbound and outbound wires
connect(inboundWire, outboundWire, true);
if (reference instanceof CompositeReference) {
// For a composite reference only, since its outbound wire comes
// from its parent composite,
// the corresponding target would not lie in its parent but
// rather in its parent's parent
parent = parent.getParent();
assert parent != null : "Parent of parent was null";
SCAObject target = parent.getChild(outboundWire.getTargetName().getPartName());
connect((Component)parent, outboundWire, target);
}
} else if (source instanceof Service) {
Service service = (Service) source;
InboundWire inboundWire = service.getInboundWire();
OutboundWire outboundWire = service.getOutboundWire();
// For a composite reference only, since its outbound wire comes from its parent composite,
// the corresponding target would not lie in its parent but rather in its parent's parent
if (source instanceof CompositeReference) {
parent = parent.getParent();
assert parent != null : "Parent of parent was null";
}
SCAObject target;
if (service.isSystem()) {
target = parent.getSystemChild(outboundWire.getTargetName().getPartName());
} else {
target = parent.getChild(outboundWire.getTargetName().getPartName());
}
// connect the outbound service wire to the target
connect(service, outboundWire, target);
// NB: this connect must be done after the outbound service chain is connected to its target above
if (!(source instanceof CompositeService)) {