ScopeContainer targetScopeContainer)
throws NoSuchMethodException {
Map<String, AtomicComponent> contexts = new HashMap<String, AtomicComponent>();
SystemAtomicComponent targetComponent = createAtomicComponent(target, targetScopeContainer, targetClass);
PojoConfiguration sourceConfig = new PojoConfiguration();
sourceConfig.getServiceInterfaces().addAll(sourceInterfaces);
sourceConfig.setScopeContainer(sourceScopeContainer);
sourceConfig.setInstanceFactory(new PojoObjectFactory(sourceClass.getConstructor()));
//create target wire
Method[] sourceMethods = sourceClass.getMethods();
Class[] interfaces = targetClass.getInterfaces();
Method setter = null;
for (Class interfaze : interfaces) {
for (Method method : sourceMethods) {
if (method.getParameterTypes().length == 1) {
if (interfaze.isAssignableFrom(method.getParameterTypes()[0])) {
setter = method;
}
}
Init init;
if ((init = method.getAnnotation(Init.class)) != null) {
sourceConfig.setInitLevel(init.eager() ? 50 : 0);
sourceConfig.setInitInvoker(new MethodEventInvoker<Object>(method));
} else if (method.getAnnotation(Destroy.class) != null) {
sourceConfig.setDestroyInvoker(new MethodEventInvoker<Object>(method));
}
}
}
if (setter == null) {
throw new IllegalArgumentException("No setter found on source for target");
}
sourceConfig.addReferenceSite(setter.getName(), setter);
SystemAtomicComponent sourceCtx = new SystemAtomicComponentImpl(source, sourceConfig);
QualifiedName targetName = new QualifiedName(target);
SystemOutboundWire wire = new SystemOutboundWireImpl(setter.getName(), targetName, targetClass);
InboundWire inboundWire = new SystemInboundWireImpl(targetName.getPortName(), targetClass, targetComponent);
wire.setTargetWire(inboundWire);