Class FileWritingMessageHandlerSpec
java.lang.Object
org.springframework.integration.dsl.IntegrationComponentSpec<S,H>
org.springframework.integration.dsl.MessageHandlerSpec<FileWritingMessageHandlerSpec,FileWritingMessageHandler>
org.springframework.integration.file.dsl.FileWritingMessageHandlerSpec
- All Implemented Interfaces:
DisposableBean
,FactoryBean<FileWritingMessageHandler>
,InitializingBean
,Lifecycle
,Phased
,SmartLifecycle
,ComponentsRegistration
public class FileWritingMessageHandlerSpec
extends MessageHandlerSpec<FileWritingMessageHandlerSpec,FileWritingMessageHandler>
implements ComponentsRegistration
The
MessageHandlerSpec
for the FileWritingMessageHandler
.- Since:
- 5.0
- Author:
- Artem Bilan, Gary Russell
-
Field Summary
Fields inherited from class org.springframework.integration.dsl.IntegrationComponentSpec
logger, PARSER, target
Fields inherited from interface org.springframework.beans.factory.FactoryBean
OBJECT_TYPE_ATTRIBUTE
Fields inherited from interface org.springframework.context.SmartLifecycle
DEFAULT_PHASE
-
Constructor Summary
ModifierConstructorDescriptionprotected
FileWritingMessageHandlerSpec
(File destinationDirectory) protected
FileWritingMessageHandlerSpec
(String directoryExpression) protected
FileWritingMessageHandlerSpec
(Function<Message<P>, ?> directoryFunction) protected
FileWritingMessageHandlerSpec
(Expression directoryExpression) -
Method Summary
Modifier and TypeMethodDescriptionappendNewLine
(boolean appendNewLine) Iftrue
will append a new-line after each write.autoCreateDirectory
(boolean autoCreateDirectory) Specify whether to create the destination directory automatically if it does not yet exist upon initialization.bufferSize
(int bufferSize) Set the buffer size to use while writing to files; default 8192.Set the charset to use when converting String payloads to bytes as the content of the file.chmod
(int chmod) Set the file permissions after uploading, e.g.deleteSourceFiles
(boolean deleteSourceFiles) Specify whether to delete source Files after writing to the destination directory.fileExistsMode
(FileExistsMode fileExistsMode) Set theFileExistsMode
that specifies what will happen in case the destination exists.fileNameExpression
(String fileNameExpression) Set theDefaultFileNameGenerator
based on the provided SpEL expression.fileNameGenerator
(FileNameGenerator fileNameGenerator) Set the file name generator used to generate the target file name.flushInterval
(long flushInterval) Set the frequency to flush buffers whenFileExistsMode.APPEND_NO_FLUSH
is being used.flushPredicate
(FileWritingMessageHandler.MessageFlushPredicate flushPredicate) Specify aFileWritingMessageHandler.MessageFlushPredicate
for flush task when theFileExistsMode.APPEND_NO_FLUSH
is in use.flushWhenIdle
(boolean flushWhenIdle) Set the flush when idle flag to false if you wish the interval to apply to when the file was opened rather than when the file was last written.preserveTimestamp
(boolean preserveTimestamp) Set to true to preserve the destination file timestamp.taskScheduler
(TaskScheduler taskScheduler) Specify aTaskScheduler
for flush task when theFileExistsMode.APPEND_NO_FLUSH
is in use.temporaryFileSuffix
(String temporaryFileSuffix) By default, every file that is in the process of being transferred will appear in the file system with an additional suffix, which by default is.writing
.Methods inherited from class org.springframework.integration.dsl.IntegrationComponentSpec
_this, afterPropertiesSet, destroy, doGet, get, getId, getObject, getObjectType, getPhase, id, isAutoStartup, isRunning, start, stop, stop
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.beans.factory.FactoryBean
isSingleton
-
Constructor Details
-
FileWritingMessageHandlerSpec
-
FileWritingMessageHandlerSpec
-
FileWritingMessageHandlerSpec
-
FileWritingMessageHandlerSpec
-
-
Method Details
-
autoCreateDirectory
Specify whether to create the destination directory automatically if it does not yet exist upon initialization. By default, this value is true. If set to false and the destination directory does not exist, an Exception will be thrown upon initialization.- Parameters:
autoCreateDirectory
- true to create the directory if needed.- Returns:
- the current Spec
-
temporaryFileSuffix
By default, every file that is in the process of being transferred will appear in the file system with an additional suffix, which by default is.writing
.- Parameters:
temporaryFileSuffix
- The temporary file suffix.- Returns:
- the current Spec
-
fileExistsMode
Set theFileExistsMode
that specifies what will happen in case the destination exists.- Parameters:
fileExistsMode
- theFileExistsMode
to consult.- Returns:
- the current Spec
-
fileNameGenerator
Set the file name generator used to generate the target file name. DefaultDefaultFileNameGenerator
.- Parameters:
fileNameGenerator
- the file name generator.- Returns:
- the current Spec
-
fileNameExpression
Set theDefaultFileNameGenerator
based on the provided SpEL expression.- Parameters:
fileNameExpression
- the SpEL expression for file names generation.- Returns:
- the current Spec
-
deleteSourceFiles
Specify whether to delete source Files after writing to the destination directory. The default is false. When set to true, it will only have an effect if the inbound Message has a File payload or aFileHeaders.ORIGINAL_FILE
header value containing either a File instance or a String representing the original file path.- Parameters:
deleteSourceFiles
- true to delete the source files.- Returns:
- the current Spec
-
charset
Set the charset to use when converting String payloads to bytes as the content of the file. DefaultUTF-8
.- Parameters:
charset
- the charset.- Returns:
- the current Spec
-
appendNewLine
Iftrue
will append a new-line after each write. Defaults tofalse
.- Parameters:
appendNewLine
- true if a new-line should be written to the file after payload is written.- Returns:
- the spec.
- See Also:
-
bufferSize
Set the buffer size to use while writing to files; default 8192.- Parameters:
bufferSize
- the buffer size.- Returns:
- the spec.
- See Also:
-
flushInterval
Set the frequency to flush buffers whenFileExistsMode.APPEND_NO_FLUSH
is being used.- Parameters:
flushInterval
- the interval.- Returns:
- the spec.
- See Also:
-
flushWhenIdle
Set the flush when idle flag to false if you wish the interval to apply to when the file was opened rather than when the file was last written.- Parameters:
flushWhenIdle
- false to flush if the interval since the file was opened has elapsed.- Returns:
- the spec.
- See Also:
-
taskScheduler
Specify aTaskScheduler
for flush task when theFileExistsMode.APPEND_NO_FLUSH
is in use.- Parameters:
taskScheduler
- theTaskScheduler
to use.- Returns:
- the spec.
- See Also:
-
flushPredicate
public FileWritingMessageHandlerSpec flushPredicate(FileWritingMessageHandler.MessageFlushPredicate flushPredicate) Specify aFileWritingMessageHandler.MessageFlushPredicate
for flush task when theFileExistsMode.APPEND_NO_FLUSH
is in use.- Parameters:
flushPredicate
- theFileWritingMessageHandler.MessageFlushPredicate
to use.- Returns:
- the spec.
- See Also:
-
preserveTimestamp
Set to true to preserve the destination file timestamp. If true and the payload is aFile
, the payload'slastModified
time will be transferred to the destination file.- Parameters:
preserveTimestamp
- theboolean
flag to use.- Returns:
- the spec.
- See Also:
-
chmod
Set the file permissions after uploading, e.g. 0600 for owner read/write. Only applies to file systems that support posix file permissions.- Parameters:
chmod
- the permissions.- Returns:
- the spec.
- Throws:
IllegalArgumentException
- if the value is higher than 0777.- See Also:
-
getComponentsToRegister
- Specified by:
getComponentsToRegister
in interfaceComponentsRegistration
-