Class FileWritingMessageHandlerSpec
java.lang.Object
org.springframework.beans.factory.config.AbstractFactoryBean<T>
org.springframework.integration.dsl.IntegrationComponentSpec<S,H>
org.springframework.integration.dsl.MessageHandlerSpec<FileWritingMessageHandlerSpec,FileWritingMessageHandler>
org.springframework.integration.file.dsl.FileWritingMessageHandlerSpec
- All Implemented Interfaces:
Aware
,BeanClassLoaderAware
,BeanFactoryAware
,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
PARSER, target
-
Constructor Summary
Constructors Modifier Constructor Description protected
FileWritingMessageHandlerSpec(File destinationDirectory)
protected
FileWritingMessageHandlerSpec(String directoryExpression)
protected
FileWritingMessageHandlerSpec(Function<Message<P>,?> directoryFunction)
protected
FileWritingMessageHandlerSpec(Expression directoryExpression)
-
Method Summary
Modifier and Type Method Description FileWritingMessageHandlerSpec
appendNewLine(boolean appendNewLine)
Iftrue
will append a new-line after each write.FileWritingMessageHandlerSpec
autoCreateDirectory(boolean autoCreateDirectory)
Specify whether to create the destination directory automatically if it does not yet exist upon initialization.FileWritingMessageHandlerSpec
bufferSize(int bufferSize)
Set the buffer size to use while writing to files; default 8192.FileWritingMessageHandlerSpec
charset(String charset)
Set the charset to use when converting String payloads to bytes as the content of the file.FileWritingMessageHandlerSpec
chmod(int chmod)
Set the file permissions after uploading, e.g.FileWritingMessageHandlerSpec
deleteSourceFiles(boolean deleteSourceFiles)
Specify whether to delete source Files after writing to the destination directory.FileWritingMessageHandlerSpec
fileExistsMode(FileExistsMode fileExistsMode)
Set theFileExistsMode
that specifies what will happen in case the destination exists.FileWritingMessageHandlerSpec
fileNameExpression(String fileNameExpression)
Set theDefaultFileNameGenerator
based on the provided SpEL expression.FileWritingMessageHandlerSpec
fileNameGenerator(FileNameGenerator fileNameGenerator)
Set the file name generator used to generate the target file name.FileWritingMessageHandlerSpec
flushInterval(long flushInterval)
Set the frequency to flush buffers whenFileExistsMode.APPEND_NO_FLUSH
is being used.FileWritingMessageHandlerSpec
flushPredicate(FileWritingMessageHandler.MessageFlushPredicate flushPredicate)
Specify aFileWritingMessageHandler.MessageFlushPredicate
for flush task when theFileExistsMode.APPEND_NO_FLUSH
is in use.FileWritingMessageHandlerSpec
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.Map<Object,String>
getComponentsToRegister()
FileWritingMessageHandlerSpec
preserveTimestamp(boolean preserveTimestamp)
Set to true to preserve the destination file timestamp.FileWritingMessageHandlerSpec
taskScheduler(TaskScheduler taskScheduler)
Specify aTaskScheduler
for flush task when theFileExistsMode.APPEND_NO_FLUSH
is in use.FileWritingMessageHandlerSpec
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, createInstance, destroyInstance, doGet, get, getId, getObjectType, getPhase, id, isAutoStartup, isRunning, start, stop, stop
Methods inherited from class org.springframework.beans.factory.config.AbstractFactoryBean
afterPropertiesSet, destroy, getBeanFactory, getBeanTypeConverter, getEarlySingletonInterfaces, getObject, isSingleton, setBeanClassLoader, setBeanFactory, setSingleton
-
Constructor Details
-
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:
FileWritingMessageHandler.setAppendNewLine(boolean)
-
bufferSize
Set the buffer size to use while writing to files; default 8192.- Parameters:
bufferSize
- the buffer size.- Returns:
- the spec.
- See Also:
FileWritingMessageHandler.setBufferSize(int)
-
flushInterval
Set the frequency to flush buffers whenFileExistsMode.APPEND_NO_FLUSH
is being used.- Parameters:
flushInterval
- the interval.- Returns:
- the spec.
- See Also:
FileWritingMessageHandler.setBufferSize(int)
,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.- Parameters:
flushWhenIdle
- false to flush if the interval since the file was opened has elapsed.- Returns:
- the spec.
- See Also:
FileWritingMessageHandler.setFlushWhenIdle(boolean)
,flushInterval(long)
-
taskScheduler
Specify aTaskScheduler
for flush task when theFileExistsMode.APPEND_NO_FLUSH
is in use.- Parameters:
taskScheduler
- theTaskScheduler
to use.- Returns:
- the spec.
- See Also:
IntegrationObjectSupport.setTaskScheduler(TaskScheduler)
-
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:
FileWritingMessageHandler.setFlushPredicate(FileWritingMessageHandler.MessageFlushPredicate)
-
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:
FileWritingMessageHandler.setPreserveTimestamp(boolean)
-
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:
FileWritingMessageHandler.setChmod(int)
-
getComponentsToRegister
- Specified by:
getComponentsToRegister
in interfaceComponentsRegistration
-