for (SourceWireFactory<?> sourceFactory : source.getSourceWireFactories()) {
WireConfiguration wireConfiguration = sourceFactory.getConfiguration();
QualifiedName targetName = wireConfiguration.getTargetName();
ContextFactory<?> target = configurations.get(targetName.getPartName());
if (target == null) {
ContextInitException e = new ContextInitException("Target not found");
e.setIdentifier(targetName.getPartName());
e.addContextName(source.getName());
e.addContextName(name);
throw e;
}
// get the proxy chain for the target
TargetWireFactory targetFactory = target.getTargetWireFactory(targetName.getPortName());
if (targetFactory == null) {
ContextInitException e = new ContextInitException("No proxy factory found for service");
e.setIdentifier(wireConfiguration.getTargetName().getPortName());
e.addContextName(target.getName());
e.addContextName(source.getName());
e.addContextName(name);
throw e;
}
try {
boolean downScope = scopeStrategy.downScopeReference(sourceScope, target.getScope());
configurationContext.connect(sourceFactory, targetFactory, target.getClass(), downScope, scopeContexts
.get(target.getScope()));
} catch (BuilderConfigException e) {
e.addContextName(target.getName());
e.addContextName(source.getName());
e.addContextName(name);
throw e;
}
}
}
// wire invokers when the proxy only contains the target chain
if (source.getTargetWireFactories() != null) {
for (TargetWireFactory targetFactory : source.getTargetWireFactories().values()) {
try {
configurationContext.completeTargetChain(targetFactory, source.getClass(), scopeContexts.get(sourceScope));
} catch (BuilderConfigException e) {
e.addContextName(source.getName());
e.addContextName(name);
throw e;
}
}
}
}