CompositeComponent composite = (CompositeComponent) target;
InboundWire targetWire = null;
if (source.isSystem()) {
for (Object child : composite.getSystemChildren()) {
if (child instanceof CompositeService) {
CompositeService compServ = (CompositeService) child;
targetWire = compServ.getInboundWire();
assert targetWire != null;
Class<?> sourceInterface = sourceWire.getServiceContract().getInterfaceClass();
Class<?> targetInterface = targetWire.getServiceContract().getInterfaceClass();
if (sourceInterface.isAssignableFrom(targetInterface)) {
target = compServ;
break;
} else {
targetWire = null;
}
}
}
} else {
for (Object child : composite.getChildren()) {
if (child instanceof CompositeService) {
CompositeService compServ = (CompositeService) child;
targetWire = compServ.getInboundWire();
assert targetWire != null;
Class<?> sourceInterface = sourceWire.getServiceContract().getInterfaceClass();
Class<?> targetInterface = targetWire.getServiceContract().getInterfaceClass();
if (sourceInterface.isAssignableFrom(targetInterface)) {
target = compServ;