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 Summary
Nested classes/interfaces inherited from interface org.jgrapes.core.Channel
Channel.Default -
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionInputStreamMonitor(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 Summary
Modifier 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.Component
channel, component, defaultCriterion, isEligibleFor, setNameMethods inherited from class org.jgrapes.core.internal.ComponentVertex
activeEventPipeline, addHandler, attach, channelReplacements, children, componentPath, componentVertex, detach, fire, initComponentsHandlers, iterator, name, newEventPipeline, newEventPipeline, parent, registerAsGenerator, root, toString, unregisterAsGeneratorMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
InputStreamMonitor
Creates 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 channelinput- the input streamdataChannel- the data channel
-
InputStreamMonitor
Creates 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 channelinput- the input
-
-
Method Details
-
setBufferSize
Sets the buffer size.- Parameters:
bufferSize- the buffer size- Returns:
- the input stream monitor for easy chaining
-
getBufferSize
Returns the buffer size.- Returns:
- the buffer size
-
onConfigurationUpdate
The 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
-
onStart
Starts a thread that continuously reads available data from the input stream.- Parameters:
event- the event
-
onStop
Stops 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
-