use of org.talend.sdk.component.runtime.di.OutputsHandler in project component-runtime by Talend.
the class DIBatchSimulationTest method doDi.
private void doDi(final ComponentManager manager, final Collection<Object> sourceData, final Collection<Object> processorData, final Optional<Processor> proc, final Optional<Mapper> mapper) {
final Map<String, Object> globalMap = new HashMap<>();
try {
final Processor processor = proc.orElseThrow(() -> new IllegalStateException("scanning failed"));
JobStateAware.init(processor, globalMap);
final Jsonb jsonbProcessor = Jsonb.class.cast(manager.findPlugin(processor.plugin()).get().get(ComponentManager.AllServices.class).getServices().get(Jsonb.class));
final AutoChunkProcessor processorProcessor = new AutoChunkProcessor(100, processor);
processorProcessor.start();
globalMap.put("processorProcessor", processorProcessor);
final InputsHandler inputsHandlerProcessor = new InputsHandler(jsonbProcessor);
inputsHandlerProcessor.addConnection("FLOW", row1Struct.class);
final OutputsHandler outputHandlerProcessor = new OutputsHandler(jsonbProcessor);
final InputFactory inputsProcessor = inputsHandlerProcessor.asInputFactory();
final OutputFactory outputsProcessor = outputHandlerProcessor.asOutputFactory();
final Mapper tempMapperMapper = mapper.orElseThrow(() -> new IllegalStateException("scanning failed"));
JobStateAware.init(tempMapperMapper, globalMap);
doRun(manager, sourceData, processorData, globalMap, processorProcessor, inputsHandlerProcessor, outputHandlerProcessor, inputsProcessor, outputsProcessor, tempMapperMapper);
} finally {
doClose(globalMap);
}
}
Aggregations