Package org.jgrapes.io
Class InputStreamMonitor
java.lang.Object
org.jgrapes.core.internal.ComponentVertex
org.jgrapes.core.Component
org.jgrapes.io.InputStreamMonitor
- All Implemented Interfaces:
- Iterable<ComponentType>,- Runnable,- Channel,- ComponentType,- Eligible,- Manager
A component that watches for new input on an
InputStream.If new input becomes
available, it is fired as Input event.
This component should only be used to monitor an
input stream that is available during the complete
lifetime of the application. A typical usage is
to make data from System.in available as events.
- 
Nested Class SummaryNested classes/interfaces inherited from interface org.jgrapes.core.ChannelChannel.Default
- 
Field Summary
- 
Constructor SummaryConstructorsConstructorDescriptionInputStreamMonitor(Channel componentChannel, InputStream input) Creates a new input stream monitor with its channel set to the given channel.InputStreamMonitor(Channel componentChannel, InputStream input, Channel dataChannel) Creates a new input stream monitor with its channel set to the given channel.
- 
Method SummaryModifier and TypeMethodDescriptionintReturns the buffer size.voidThe component can be configured with events that include a path (see @linkConfigurationUpdate.paths()) that matches this components path (seeManager.componentPath()).voidStarts a thread that continuously reads available data from the input stream.voidStops the thread that reads data from the input stream.voidrun()setBufferSize(int bufferSize) Sets the buffer size.Methods inherited from class org.jgrapes.core.Componentchannel, component, defaultCriterion, isEligibleFor, setNameMethods inherited from class org.jgrapes.core.internal.ComponentVertexactiveEventPipeline, addHandler, attach, channelReplacements, children, componentPath, componentVertex, detach, fire, initComponentsHandlers, iterator, name, newEventPipeline, newEventPipeline, parent, registerAsGenerator, root, toString, unregisterAsGeneratorMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.IterableforEach, spliterator
- 
Constructor Details- 
InputStreamMonitorCreates a new input stream monitor with its channel set to the given channel.The channel is also used for firing the Inputevents.- Parameters:
- componentChannel- the component channel
- input- the input stream
- dataChannel- the data channel
 
- 
InputStreamMonitorCreates a new input stream monitor with its channel set to the given channel.The channel is also used for firing the Inputevents.- Parameters:
- componentChannel- the component channel
- input- the input
 
 
- 
- 
Method Details- 
setBufferSizeSets the buffer size.- Parameters:
- bufferSize- the buffer size
- Returns:
- the input stream monitor for easy chaining
 
- 
getBufferSizeReturns the buffer size.- Returns:
- the buffer size
 
- 
onConfigurationUpdateThe component can be configured with events that include a path (see @linkConfigurationUpdate.paths()) that matches this components path (seeManager.componentPath()).The following properties are recognized: - bufferSize
- See setBufferSize(int).
 - Parameters:
- event- the event
 
- 
onStartStarts a thread that continuously reads available data from the input stream.- Parameters:
- event- the event
 
- 
onStopStops the thread that reads data from the input stream.Note that the input stream is not closed. - Parameters:
- event- the event
- Throws:
- InterruptedException- the interrupted exception
 
- 
run
 
-