Class CharacterStreamReadingMessageSource
java.lang.Object
org.springframework.integration.util.AbstractExpressionEvaluator
org.springframework.integration.endpoint.AbstractMessageSource<java.lang.String>
org.springframework.integration.stream.CharacterStreamReadingMessageSource
- All Implemented Interfaces:
org.springframework.beans.factory.Aware,org.springframework.beans.factory.BeanFactoryAware,org.springframework.beans.factory.BeanNameAware,org.springframework.beans.factory.DisposableBean,org.springframework.beans.factory.InitializingBean,org.springframework.context.ApplicationEventPublisherAware,org.springframework.integration.core.MessageSource<java.lang.String>,org.springframework.integration.IntegrationPattern,org.springframework.integration.support.context.NamedComponent,org.springframework.integration.support.management.IntegrationInboundManagement,org.springframework.integration.support.management.IntegrationManagement
public class CharacterStreamReadingMessageSource
extends org.springframework.integration.endpoint.AbstractMessageSource<java.lang.String>
implements org.springframework.context.ApplicationEventPublisherAware
A pollable source for
Readers.-
Nested Class Summary
-
Field Summary
-
Constructor Summary
Constructors Constructor Description CharacterStreamReadingMessageSource(java.io.Reader reader)Construct an instance with the provider reader.CharacterStreamReadingMessageSource(java.io.Reader reader, int bufferSize)Construct an instance with the provider reader and buffer size.CharacterStreamReadingMessageSource(java.io.Reader reader, int bufferSize, boolean blockToDetectEOF)Construct an instance with the provided reader and buffer size. -
Method Summary
Modifier and Type Method Description java.lang.StringdoReceive()java.lang.StringgetComponentType()voidsetApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher applicationEventPublisher)static CharacterStreamReadingMessageSourcestdin()Create a source that reads fromSystem.in.static CharacterStreamReadingMessageSourcestdin(java.lang.String charsetName)Create a source that reads fromSystem.in.static CharacterStreamReadingMessageSourcestdinPipe()Create a source that reads fromSystem.in.static CharacterStreamReadingMessageSourcestdinPipe(java.lang.String charsetName)Create a source that reads fromSystem.in.Methods inherited from class org.springframework.integration.endpoint.AbstractMessageSource
buildMessage, destroy, getBeanName, getComponentName, getManagedName, getManagedType, getOverrides, isLoggingEnabled, receive, registerMetricsCaptor, setBeanName, setHeaderExpressions, setLoggingEnabled, setManagedName, setManagedTypeMethods inherited from class org.springframework.integration.util.AbstractExpressionEvaluator
afterPropertiesSet, evaluateExpression, evaluateExpression, evaluateExpression, evaluateExpression, evaluateExpression, evaluateExpression, evaluateExpression, getBeanFactory, getEvaluationContext, getEvaluationContext, getMessageBuilderFactory, onInit, setBeanFactory, setConversionServiceMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
CharacterStreamReadingMessageSource
public CharacterStreamReadingMessageSource(java.io.Reader reader)Construct an instance with the provider reader.AbstractMessageSource.receive()will returnnullwhen the reader is not ready.- Parameters:
reader- the reader.
-
CharacterStreamReadingMessageSource
public CharacterStreamReadingMessageSource(java.io.Reader reader, int bufferSize)Construct an instance with the provider reader and buffer size.AbstractMessageSource.receive()will returnnullwhen the reader is not ready.- Parameters:
reader- the reader.bufferSize- the buffer size.
-
CharacterStreamReadingMessageSource
public CharacterStreamReadingMessageSource(java.io.Reader reader, int bufferSize, boolean blockToDetectEOF)Construct an instance with the provided reader and buffer size. WhenblockToDetectEOFisfalse,AbstractMessageSource.receive()will returnnullwhen the reader is not ready. When it istrue, the thread will block until data is available; when the underlying stream is closed, aStreamClosedEventis published to inform the application via anApplicationListener. This can be useful, for example, when piping stdincat foo.txt | java -jar my.jarorjava -jar my.jar < foo.txt- Parameters:
reader- the reader.bufferSize- the buffer size; if negative use the default inBufferedReader.blockToDetectEOF- true to block the thread until data is available and publish aStreamClosedEventat EOF.- Since:
- 5.0
-
-
Method Details
-
setApplicationEventPublisher
public void setApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher applicationEventPublisher)- Specified by:
setApplicationEventPublisherin interfaceorg.springframework.context.ApplicationEventPublisherAware
-
getComponentType
public java.lang.String getComponentType()- Specified by:
getComponentTypein interfaceorg.springframework.integration.support.context.NamedComponent
-
doReceive
public java.lang.String doReceive()- Specified by:
doReceivein classorg.springframework.integration.endpoint.AbstractMessageSource<java.lang.String>
-
stdin
Create a source that reads fromSystem.in. EOF will not be detected.- Returns:
- the stream.
-
stdin
Create a source that reads fromSystem.in. EOF will not be detected.- Parameters:
charsetName- the charset to use when converting bytes to String.- Returns:
- the stream.
-
stdinPipe
Create a source that reads fromSystem.in. EOF will be detected and the application context closed.- Returns:
- the stream.
- Since:
- 5.0
- See Also:
CharacterStreamReadingMessageSource(Reader, int, boolean)
-
stdinPipe
Create a source that reads fromSystem.in. EOF will be detected and the application context closed.- Parameters:
charsetName- the charset to use when converting bytes to String.- Returns:
- the stream.
- Since:
- 5.0
- See Also:
CharacterStreamReadingMessageSource(Reader, int, boolean)
-