public class FileSplitter extends AbstractMessageSplitter
AbstractMessageSplitter
implementation to split the File
Message payload to lines.
With iterator = true
(defaults to true
) this class produces an Iterator
to process file lines on demand from Iterator.next()
.
Otherwise a List
of all lines is returned to the to further
AbstractMessageSplitter.handleRequestMessage(org.springframework.messaging.Message<?>)
process.
Can accept String
as file path, File
, Reader
or InputStream
as payload type.
All other types are ignored and returned to the AbstractMessageSplitter
as is.
Modifier and Type | Class and Description |
---|---|
static class |
FileSplitter.FileMarker |
AbstractReplyProducingMessageHandler.RequestHandler
messagingTemplate
EXPRESSION_PARSER, logger
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
Constructor and Description |
---|
FileSplitter()
Construct a splitter where the
splitMessage(Message) method returns
an iterator and the file is read line-by-line during iteration. |
FileSplitter(boolean iterator)
Construct a splitter where the
splitMessage(Message) method returns
an iterator, and the file is read line-by-line during iteration, or a list
of lines from the file. |
FileSplitter(boolean iterator,
boolean markers)
Construct a splitter where the
splitMessage(Message) method returns
an iterator, and the file is read line-by-line during iteration, or a list
of lines from the file. |
FileSplitter(boolean iterator,
boolean markers,
boolean markersJson)
Construct a splitter where the
splitMessage(Message) method returns an
iterator, and the file is read line-by-line during iteration, or a list of lines
from the file. |
Modifier and Type | Method and Description |
---|---|
protected void |
addHeaders(Message<?> message,
Map<String,Object> headers)
Allows subclasses to add extra headers to the output messages.
|
void |
setCharset(Charset charset)
Set the charset to be used when reading the file, when something other than the default
charset is required.
|
protected Object |
splitMessage(Message<?> message)
Subclasses must override this method to split the received Message.
|
protected boolean |
willAddHeaders(Message<?> message)
Return true if the subclass needs to add headers in the resulting splits.
|
getComponentType, handleRequestMessage, produceOutput, setApplySequence, shouldCopyRequestHeaders
doInit, doInvokeAdvisedRequestHandler, getRequiresReply, handleMessageInternal, hasAdviceChain, onInit, setAdviceChain, setBeanClassLoader, setRequiresReply
addNotPropagatedHeaders, createOutputMessage, getNotPropagatedHeaders, getOutputChannel, isAsync, resolveErrorChannel, sendErrorMessage, sendOutput, sendOutputs, setAsync, setNotPropagatedHeaders, setOutputChannel, setOutputChannelName, setSendTimeout, shouldSplitOutput
configureMetrics, getActiveCount, getActiveCountLong, getDuration, getErrorCount, getErrorCountLong, getHandleCount, getHandleCountLong, getManagedName, getManagedType, getMaxDuration, getMeanDuration, getMinDuration, getOrder, getStandardDeviationDuration, handleMessage, isCountsEnabled, isLoggingEnabled, isStatsEnabled, reset, setCountsEnabled, setLoggingEnabled, setManagedName, setManagedType, setOrder, setShouldTrack, setStatsEnabled
afterPropertiesSet, extractTypeIfPossible, getApplicationContext, getApplicationContextId, getBeanFactory, getChannelResolver, getComponentName, getConversionService, getExpression, getIntegrationProperties, getIntegrationProperty, getMessageBuilderFactory, getTaskScheduler, setApplicationContext, setBeanFactory, setBeanName, setChannelResolver, setComponentName, setConversionService, setMessageBuilderFactory, setPrimaryExpression, setTaskScheduler, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getComponentName
public FileSplitter()
splitMessage(Message)
method returns
an iterator and the file is read line-by-line during iteration.public FileSplitter(boolean iterator)
splitMessage(Message)
method returns
an iterator, and the file is read line-by-line during iteration, or a list
of lines from the file.iterator
- true to return an iterator, false to return a list of lines.public FileSplitter(boolean iterator, boolean markers)
splitMessage(Message)
method returns
an iterator, and the file is read line-by-line during iteration, or a list
of lines from the file. When file markers are enabled (START/END)
applySequence
is false by default. If enabled,
the markers are included in the sequence size.iterator
- true to return an iterator, false to return a list of lines.markers
- true to emit start of file/end of file marker messages before/after the data.public FileSplitter(boolean iterator, boolean markers, boolean markersJson)
splitMessage(Message)
method returns an
iterator, and the file is read line-by-line during iteration, or a list of lines
from the file. When file markers are enabled (START/END)
applySequence
is false by default. If enabled,
the markers are included in the sequence size.iterator
- true to return an iterator, false to return a list of lines.markers
- true to emit start of file/end of file marker messages before/after
the data.markersJson
- when true, markers are represented as JSON - requires a
supported JSON implementation on the classpath. See
JsonObjectMapperProvider
for supported implementations.public void setCharset(Charset charset)
charset
- the charset.protected Object splitMessage(Message<?> message)
AbstractMessageSplitter
splitMessage
in class AbstractMessageSplitter
message
- The message.protected boolean willAddHeaders(Message<?> message)
AbstractMessageSplitter
AbstractMessageSplitter.addHeaders(org.springframework.messaging.Message<?>, java.util.Map<java.lang.String, java.lang.Object>)
will be called.willAddHeaders
in class AbstractMessageSplitter
message
- the message.protected void addHeaders(Message<?> message, Map<String,Object> headers)
AbstractMessageSplitter
addHeaders
in class AbstractMessageSplitter
message
- the inbound message.headers
- the headers to add messages to.