ScopeStrategy strategy = new DefaultScopeStrategy();
DefaultWireBuilder wireBuilder = new DefaultWireBuilder();
wireBuilder.addWireBuilder(javaWireBuilder);
Module module = MockFactory.createModule();
EventContext eCtx = new EventContextImpl();
ScopeContext scopeContext = new ModuleScopeContext(eCtx);
scopeContext.start();
scopeContext.onEvent(new ModuleStart(this));
List<Component> components = module.getComponents();
Map<String, Component> compMap = new HashMap<String, Component>(components.size());
for (Component component : components) {
compMap.put(component.getName(), component);
builder.build(component);
ContextFactory contextFactory = (ContextFactory) component.getContextFactory();
Assert.assertNotNull(contextFactory);
}
for (Component component : components) {
ContextFactory<Context> source = (ContextFactory<Context>) component.getContextFactory();
Assert.assertNotNull(source);
for (SourceWireFactory pFactory : source.getSourceWireFactories()) {
WireConfiguration pConfig = pFactory.getConfiguration();
Component target = compMap.get(pConfig.getTargetName().getPartName());
if (target != null) {
ContextFactory targetConfig = (ContextFactory) target.getContextFactory();
boolean downScope = strategy.downScopeReference(source.getScope(), targetConfig.getScope());
wireBuilder.connect(pFactory, targetConfig.getTargetWireFactory(pFactory.getConfiguration().getTargetName()
.getPortName()), targetConfig.getClass(), downScope, scopeContext);
}
pFactory.initialize();
}
scopeContext.registerFactory(source);
}
for (Component component : components) {
ContextFactory config = (ContextFactory) component.getContextFactory();
Context context = config.createContext();
if ("source".equals(component.getName())) {