Plug plug = e.getValue().iterator().next();
ModuleWrapper source = mod2wrap.get(plug.getModule());
if (source == null)
throw new IllegalArgumentException(String.format("Trying to export %s/%s as %s, but there is no module by the name of '%s'", plug.getModule().toString(), plug.getPort(), e.getKey(), plug.getModule().toString()));
OutputStreamSplitter splitter = source.oss.get(plug.getPort());
if (splitter == null)
throw new IllegalArgumentException(String.format("Trying to export %s/%s as %s, but %s has no output stream by the name of '%s'", plug.getModule().toString(), plug.getPort(), e.getKey(), plug.getModule().toString(), plug.getPort()));
splitter.add(pipeline_out);
}
// create data importer threads
if (data_access != null)
for (Map.Entry<String,Collection<Plug>> e : pipeline.getInputPipes().entrySet())
{
Collection<? extends InputStream> pipeline_in = data_access.getInputPipes().get(e.getKey());
if (pipeline_in == null)
continue;
for (InputStream is : pipeline_in)
{
OutputStreamSplitter os = new OutputStreamSplitter(true);
splitters.add(new StreamConnector("data importer", is, os));
for (Plug target : e.getValue())
{
ModuleWrapper target_wrapper = mod2wrap.get(target.getModule());
target_wrapper.connect(target.getPort(), os);
}
}
}
// create module input streams
for (Map.Entry<Plug,Collection<Plug>> e : pipeline.getConnectors().entrySet())
{
Plug source = e.getKey();
ModuleWrapper source_wrapper = mod2wrap.get(source.getModule());
OutputStreamSplitter source_stream = source_wrapper.oss.get(source.getPort());
for (Plug target : e.getValue())
{
ModuleWrapper target_wrapper = mod2wrap.get(target.getModule());
target_wrapper.connect(target.getPort(), source_stream);