ScopeContainer sourceScope,
String targetName, Class<?> targetService,
Class<?> targetClass,
Map<String, Member> members,
ScopeContainer targetScope) throws Exception {
JavaAtomicComponent targetContext =
createJavaComponent(targetName, targetScope, targetClass);
String serviceName = targetService.getName().substring(targetService.getName().lastIndexOf('.') + 1);
InboundWire inboundWire = createServiceWire(serviceName, targetService, null);
targetContext.addInboundWire(inboundWire);
PojoConfiguration configuration = new PojoConfiguration();
configuration.setScopeContainer(sourceScope);
configuration.setInstanceFactory(new PojoObjectFactory(sourceClass.getConstructor()));
configuration.addServiceInterface(sourceClass);
configuration.setWireService(WIRE_SERVICE);
for (Map.Entry<String, Member> entry : members.entrySet()) {
configuration.addReferenceSite(entry.getKey(), entry.getValue());
}
JavaAtomicComponent sourceContext = new JavaAtomicComponent(sourceName, configuration, null);
OutboundWire outboundWire = createReferenceWire(targetName, sourceReferenceClass, null);
List<OutboundWire> factories = new ArrayList<OutboundWire>();
factories.add(outboundWire);
sourceContext.addOutboundWires(sourceReferenceClass, factories);
targetScope.register(targetContext);
sourceScope.register(sourceContext);
connect(outboundWire, inboundWire, targetContext, false);
Map<String, AtomicComponent> contexts = new HashMap<String, AtomicComponent>();
contexts.put(sourceName, sourceContext);