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 SummaryFields inherited from class org.springframework.integration.dsl.IntegrationComponentSpecPARSER, target
- 
Constructor SummaryConstructors Modifier Constructor Description protectedFileWritingMessageHandlerSpec(File destinationDirectory)protectedFileWritingMessageHandlerSpec(String directoryExpression)protectedFileWritingMessageHandlerSpec(Function<Message<P>,?> directoryFunction)protectedFileWritingMessageHandlerSpec(Expression directoryExpression)
- 
Method SummaryModifier and Type Method Description FileWritingMessageHandlerSpecappendNewLine(boolean appendNewLine)Iftruewill append a new-line after each write.FileWritingMessageHandlerSpecautoCreateDirectory(boolean autoCreateDirectory)Specify whether to create the destination directory automatically if it does not yet exist upon initialization.FileWritingMessageHandlerSpecbufferSize(int bufferSize)Set the buffer size to use while writing to files; default 8192.FileWritingMessageHandlerSpeccharset(String charset)Set the charset to use when converting String payloads to bytes as the content of the file.FileWritingMessageHandlerSpecchmod(int chmod)Set the file permissions after uploading, e.g.FileWritingMessageHandlerSpecdeleteSourceFiles(boolean deleteSourceFiles)Specify whether to delete source Files after writing to the destination directory.FileWritingMessageHandlerSpecfileExistsMode(FileExistsMode fileExistsMode)Set theFileExistsModethat specifies what will happen in case the destination exists.FileWritingMessageHandlerSpecfileNameExpression(String fileNameExpression)Set theDefaultFileNameGeneratorbased on the provided SpEL expression.FileWritingMessageHandlerSpecfileNameGenerator(FileNameGenerator fileNameGenerator)Set the file name generator used to generate the target file name.FileWritingMessageHandlerSpecflushInterval(long flushInterval)Set the frequency to flush buffers whenFileExistsMode.APPEND_NO_FLUSHis being used.FileWritingMessageHandlerSpecflushPredicate(FileWritingMessageHandler.MessageFlushPredicate flushPredicate)Specify aFileWritingMessageHandler.MessageFlushPredicatefor flush task when theFileExistsMode.APPEND_NO_FLUSHis in use.FileWritingMessageHandlerSpecflushWhenIdle(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()FileWritingMessageHandlerSpecpreserveTimestamp(boolean preserveTimestamp)Set to true to preserve the destination file timestamp.FileWritingMessageHandlerSpectaskScheduler(TaskScheduler taskScheduler)Specify aTaskSchedulerfor flush task when theFileExistsMode.APPEND_NO_FLUSHis in use.FileWritingMessageHandlerSpectemporaryFileSuffix(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, stopMethods inherited from class org.springframework.beans.factory.config.AbstractFactoryBeanafterPropertiesSet, destroy, getBeanFactory, getBeanTypeConverter, getEarlySingletonInterfaces, getObject, isSingleton, setBeanClassLoader, setBeanFactory, setSingleton
- 
Constructor Details
- 
Method Details- 
autoCreateDirectorySpecify 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
 
- 
temporaryFileSuffixBy 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
 
- 
fileExistsModeSet theFileExistsModethat specifies what will happen in case the destination exists.- Parameters:
- fileExistsMode- the- FileExistsModeto consult.
- Returns:
- the current Spec
 
- 
fileNameGeneratorSet the file name generator used to generate the target file name. DefaultDefaultFileNameGenerator.- Parameters:
- fileNameGenerator- the file name generator.
- Returns:
- the current Spec
 
- 
fileNameExpressionSet theDefaultFileNameGeneratorbased on the provided SpEL expression.- Parameters:
- fileNameExpression- the SpEL expression for file names generation.
- Returns:
- the current Spec
 
- 
deleteSourceFilesSpecify 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_FILEheader 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
 
- 
charsetSet 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
 
- 
appendNewLineIftruewill 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)
 
- 
bufferSizeSet the buffer size to use while writing to files; default 8192.- Parameters:
- bufferSize- the buffer size.
- Returns:
- the spec.
- See Also:
- FileWritingMessageHandler.setBufferSize(int)
 
- 
flushIntervalSet the frequency to flush buffers whenFileExistsMode.APPEND_NO_FLUSHis being used.- Parameters:
- flushInterval- the interval.
- Returns:
- the spec.
- See Also:
- FileWritingMessageHandler.setBufferSize(int),- flushWhenIdle(boolean)
 
- 
flushWhenIdleSet 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)
 
- 
taskSchedulerSpecify aTaskSchedulerfor flush task when theFileExistsMode.APPEND_NO_FLUSHis in use.- Parameters:
- taskScheduler- the- TaskSchedulerto use.
- Returns:
- the spec.
- See Also:
- IntegrationObjectSupport.setTaskScheduler(TaskScheduler)
 
- 
flushPredicatepublic FileWritingMessageHandlerSpec flushPredicate(FileWritingMessageHandler.MessageFlushPredicate flushPredicate)Specify aFileWritingMessageHandler.MessageFlushPredicatefor flush task when theFileExistsMode.APPEND_NO_FLUSHis in use.- Parameters:
- flushPredicate- the- FileWritingMessageHandler.MessageFlushPredicateto use.
- Returns:
- the spec.
- See Also:
- FileWritingMessageHandler.setFlushPredicate(FileWritingMessageHandler.MessageFlushPredicate)
 
- 
preserveTimestampSet to true to preserve the destination file timestamp. If true and the payload is aFile, the payload'slastModifiedtime will be transferred to the destination file.- Parameters:
- preserveTimestamp- the- booleanflag to use.
- Returns:
- the spec.
- See Also:
- FileWritingMessageHandler.setPreserveTimestamp(boolean)
 
- 
chmodSet 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:
- getComponentsToRegisterin interface- ComponentsRegistration
 
 
-