inboundWire.setContainer(component);
if (componentType instanceof CompositeComponentType<?, ?, ?>) {
// If this is the case, then it means that component has already been returned
// by CompositeBuilder and thus its children, in particular composite services,
// have been registered
CompositeComponent compositeComponent = (CompositeComponent) component;
Service serviceChild = (Service) compositeComponent.getChild(service.getName());
assert serviceChild != null;
if (serviceChild instanceof CompositeService) {
serviceChild.setInboundWire(inboundWire);
// Notice that now the more immediate container of the wire is the composite service
inboundWire.setContainer(serviceChild);
}
}
component.addInboundWire(inboundWire);
}
for (ReferenceTarget referenceTarget : definition.getReferenceTargets().values()) {
Map<String, ? extends ReferenceDefinition> references = componentType.getReferences();
ReferenceDefinition mappedReference = references.get(referenceTarget.getReferenceName());
if (mappedReference == null) {
String refName = referenceTarget.getReferenceName();
ReferenceNotFoundException e = new ReferenceNotFoundException(refName);
e.addContextName(refName);
e.addContextName(definition.getName());
throw e;
}
OutboundWire wire = createWire(referenceTarget, mappedReference);
wire.setContainer(component);
component.addOutboundWire(wire);
if (componentType instanceof CompositeComponentType<?, ?, ?>) {
// If this is the case, then it means that component has already been returned
// by CompositeBuilder and thus its children, in particular composite references,
// have been registered
CompositeComponent compositeComponent = (CompositeComponent) component;
Reference reference = (Reference) compositeComponent.getChild(referenceTarget.getReferenceName());
assert reference != null;
if (reference instanceof CompositeReference) {
reference.setOutboundWire(wire);
// Notice that now the more immediate container of the wire is the composite reference
wire.setContainer(reference);