/** * This method is the input port of the filter receiving incoming objects. Every * object will be printed into a stream (based on the configuration) before the * filter sends it to the output port. * * @param object * The new object. */ @InputPort(name = INPUT_PORT_NAME_EVENTS, description = "Receives incoming objects to be logged and forwarded", eventTypes = { Object.class }) public final void inputEvent(final Object object) { if (this.active) { final StringBuilder sb = new StringBuilder(128); sb.append(this.getName()).append('(').append(object.getClass().getSimpleName()).append(") ") .append(object.toString()); final String record = sb.toString(); if (this.printStream != null) { this.printStream.println(record); } else { this.logger.info(record); } } super.deliver(OUTPUT_PORT_NAME_RELAYED_EVENTS, object); } }
private void executeAnalysis(final File tempFile, final boolean append, final List<Integer> objectsToWrite) throws IllegalStateException, AnalysisConfigurationException { final Configuration configuration = new Configuration(); configuration.setProperty(TeeFilter.CONFIG_PROPERTY_NAME_APPEND, Boolean.toString(append)); configuration.setProperty(TeeFilter.CONFIG_PROPERTY_NAME_STREAM, tempFile.getAbsolutePath()); final IAnalysisController analysisController = new AnalysisController(); final TeeFilter teeFilter = new TeeFilter(configuration, analysisController); final ListReader<Integer> simpleListReader = new ListReader<Integer>(new Configuration(), analysisController); analysisController.connect(simpleListReader, ListReader.OUTPUT_PORT_NAME, teeFilter, TeeFilter.INPUT_PORT_NAME_EVENTS); simpleListReader.addAllObjects(objectsToWrite); analysisController.run(); }
confTeeFilter1.setProperty(TeeFilter.CONFIG_PROPERTY_NAME_STREAM, TeeFilter.CONFIG_PROPERTY_VALUE_STREAM_STDOUT); confTeeFilter1.setProperty(TeeFilter.CONFIG_PROPERTY_NAME_STREAM, TeeFilter.CONFIG_PROPERTY_VALUE_STREAM_NULL); final TeeFilter teeFilter1 = new TeeFilter(confTeeFilter1, analysisController); confTeeFilter1.setProperty(TeeFilter.CONFIG_PROPERTY_NAME_STREAM, TeeFilter.CONFIG_PROPERTY_VALUE_STREAM_STDOUT); final TeeFilter teeFilter2 = new TeeFilter(confTeeFilter2, analysisController);
confTeeFilter1.setProperty(TeeFilter.CONFIG_PROPERTY_NAME_STREAM, TeeFilter.CONFIG_PROPERTY_VALUE_STREAM_STDOUT); final TeeFilter teeFilter1 = new TeeFilter(confTeeFilter1, analysisController); confTeeFilter2.setProperty(TeeFilter.CONFIG_PROPERTY_NAME_STREAM, TeeFilter.CONFIG_PROPERTY_VALUE_STREAM_NULL); confTeeFilter2.setProperty(AbstractAnalysisComponent.CONFIG_NAME, "CountBegin"); final TeeFilter teeFilter2 = new TeeFilter(confTeeFilter2, analysisController); confTeeFilter3.setProperty(TeeFilter.CONFIG_PROPERTY_NAME_STREAM, TeeFilter.CONFIG_PROPERTY_VALUE_STREAM_NULL); confTeeFilter3.setProperty(AbstractAnalysisComponent.CONFIG_NAME, "CountAfter"); final TeeFilter teeFilter3 = new TeeFilter(confTeeFilter3, analysisController);
/** * This method is the input port of the filter receiving incoming objects. Every object will be printed into a stream (based on the configuration) before the * filter sends it to the output port. * * @param object * The new object. */ @InputPort(name = INPUT_PORT_NAME_EVENTS, description = "Receives incoming objects to be logged and forwarded", eventTypes = { Object.class }) public final void inputEvent(final Object object) { if (this.active) { final StringBuilder sb = new StringBuilder(128); sb.append(this.getName()); sb.append('(').append(object.getClass().getSimpleName()).append(") ").append(object.toString()); final String record = sb.toString(); if (this.printStream != null) { this.printStream.println(record); } else { this.log.info(record); } } super.deliver(OUTPUT_PORT_NAME_RELAYED_EVENTS, object); } }