Class AbstractRemoteFileOutboundGateway<F>
java.lang.Object
org.springframework.integration.context.IntegrationObjectSupport
org.springframework.integration.handler.MessageHandlerSupport
org.springframework.integration.handler.AbstractMessageHandler
org.springframework.integration.handler.AbstractMessageProducingHandler
org.springframework.integration.handler.AbstractReplyProducingMessageHandler
org.springframework.integration.file.remote.gateway.AbstractRemoteFileOutboundGateway<F>
- Type Parameters:
- F- the file type.
- All Implemented Interfaces:
- org.reactivestreams.Subscriber<Message<?>>,- Aware,- BeanClassLoaderAware,- BeanFactoryAware,- BeanNameAware,- DisposableBean,- InitializingBean,- ApplicationContextAware,- Ordered,- ComponentSourceAware,- ExpressionCapable,- Orderable,- MessageProducer,- HeaderPropagationAware,- IntegrationPattern,- NamedComponent,- IntegrationManagement,- TrackableComponent,- MessageHandler,- reactor.core.CoreSubscriber<Message<?>>
- Direct Known Subclasses:
- FtpOutboundGateway,- SftpOutboundGateway,- SmbOutboundGateway
public abstract class AbstractRemoteFileOutboundGateway<F>
extends AbstractReplyProducingMessageHandler
Base class for Outbound Gateways that perform remote file operations.
- Since:
- 2.1
- Author:
- Gary Russell, Artem Bilan, Mauro Molinari
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionstatic enumEnumeration of commands supported by the gateways.static enumEnumeration of options supported by various commands.Nested classes/interfaces inherited from class org.springframework.integration.handler.AbstractReplyProducingMessageHandlerAbstractReplyProducingMessageHandler.RequestHandlerNested classes/interfaces inherited from interface org.springframework.integration.support.management.IntegrationManagementIntegrationManagement.ManagementOverrides
- 
Field SummaryFields inherited from class org.springframework.integration.handler.AbstractMessageProducingHandlermessagingTemplateFields inherited from class org.springframework.integration.context.IntegrationObjectSupportEXPRESSION_PARSER, loggerFields inherited from interface org.springframework.integration.support.management.IntegrationManagementMETER_PREFIX, RECEIVE_COUNTER_NAME, SEND_TIMER_NAMEFields inherited from interface org.springframework.core.OrderedHIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
- 
Constructor SummaryConstructorsConstructorDescriptionAbstractRemoteFileOutboundGateway(RemoteFileTemplate<F> remoteFileTemplate, String command, String expression) Construct an instance with the supplied remote file template, a command ('ls', 'get' etc.), and an expression to determine the remote path (file or directory).AbstractRemoteFileOutboundGateway(RemoteFileTemplate<F> remoteFileTemplate, AbstractRemoteFileOutboundGateway.Command command, String expressionArg) Construct an instance with the supplied remote file template, a command ('ls', 'get' etc.), and an expression to determine the remote path (file or directory).AbstractRemoteFileOutboundGateway(RemoteFileTemplate<F> remoteFileTemplate, MessageSessionCallback<F, ?> messageSessionCallback) Construct an instance with the supplied remote file template and callback for performing operations on the session.AbstractRemoteFileOutboundGateway(SessionFactory<F> sessionFactory, String command, String expression) Construct an instance with the supplied session factory, a command ('ls', 'get' etc.), and an expression to determine the remote path (file or directory).AbstractRemoteFileOutboundGateway(SessionFactory<F> sessionFactory, AbstractRemoteFileOutboundGateway.Command command, String expression) Construct an instance with the supplied session factory, a command ('ls', 'get' etc.), and an expression to determine the remote path (file or directory).AbstractRemoteFileOutboundGateway(SessionFactory<F> sessionFactory, MessageSessionCallback<F, ?> messageSessionCallback) Construct an instance using the provided session factory and callback for performing operations on the session.
- 
Method SummaryModifier and TypeMethodDescriptionprotected abstract List<AbstractFileInfo<F>>asFileInfoList(Collection<F> files) protected voidassertRemoteFileTemplateMutability(String propertyName) protected voiddoChmod(RemoteFileOperations<F> remoteFileOperations, String path, int chmodToSet) Set the mode on the remote file after transfer; the default implementation does nothing.protected voiddoInit()protected abstract FenhanceNameWithSubDirectory(F file, String directory) protected final FfilterFile(F file) filterFiles(F[] files) filterMputFiles(File[] files) protected Fileget(Message<?> message, Session<F> session, String remoteDir, String remoteFilePath, String remoteFilename, F fileInfoParam) Copy a remote file to the configured local directory.protected abstract StringgetFilename(F file) protected abstract StringgetFilename(AbstractFileInfo<F> file) protected StringgetFullFileName(String remoteDirectory, F remoteFile) By default, this method contacts the remote directory with the remote file name to build a full remote file path.protected abstract longgetModified(F file) protected StringgetRemoteFilename(String remoteFilePath) protected final RemoteFileTemplate<F>protected ObjecthandleRequestMessage(Message<?> requestMessage) Subclasses must implement this method to handle the request Message.booleanprotected abstract booleanisDirectory(F file) protected abstract booleanprotected List<?>List remote files to local representation.Put files from the provided directory to the remote server recursively.protected booleanMove one remote path to another.List remote files names for the provided directory.protected voidprotected voidpurgeLinks(List<F> lsFiles) protected StringPut the file based on the message to the remote server.protected final voidremoteFileTemplateExplicitlySet(boolean remoteFileTemplateExplicitlySet) protected booleanPerform remote delete for the provided path.voidsetAutoCreateDirectory(boolean autoCreateDirectory) Determine whether the remote directory should automatically be created when sending files to the remote system.voidsetAutoCreateLocalDirectory(boolean autoCreateLocalDirectory) Abooleanflag to identify if local directory should be created automatically.voidsetCharset(String charset) Set the charset to use when converting String payloads to bytes as the content of the remote file.voidsetChmod(int chmod) Set the file permissions after uploading, e.g.voidsetChmodOctal(String chmod) String setter for Spring XML convenience.voidsetFileExistsMode(FileExistsMode fileExistsMode) Determine the action to take when using GET and MGET operations when the file already exists locally, or PUT and MPUT when the file exists on the remote system.voidsetFileNameExpression(Expression fileNameExpression) Set the file name expression to determine the full path to the remote file.voidsetFileNameGenerator(FileNameGenerator fileNameGenerator) Set the file name generator used to generate the remote filename to be used when transferring files to the remote system.voidsetFilter(FileListFilter<F> filter) Set aFileListFilterto filter remote files.voidsetLocalDirectory(File localDirectory) Specify a directory path where remote files will be transferred to.voidsetLocalDirectoryExpression(Expression localDirectoryExpression) Specify a SpEL expression to evaluate the directory path to which remote files will be transferred.voidsetLocalDirectoryExpressionString(String localDirectoryExpression) Specify a SpEL expression to evaluate the directory path to which remote files will be transferred.voidsetLocalFilenameGeneratorExpression(Expression localFilenameGeneratorExpression) Specify a SpEL expression for local files renaming after downloading.voidsetLocalFilenameGeneratorExpressionString(String localFilenameGeneratorExpression) Specify a SpEL expression for local files renaming after downloading.voidsetMputFilter(FileListFilter<File> filter) AFileListFilterthat runs against the local file system view when usingMPUTcommand.voidsetOption(AbstractRemoteFileOutboundGateway.Option... options) Specify the array of options for various gateway commands.voidsetOptions(String options) Specify the options for various gateway commands as a space-delimited string.voidsetRemoteDirectoryExpression(Expression remoteDirectoryExpression) Set the remote directory expression used to determine the remote directory to which files will be sent.voidsetRemoteFileSeparator(String remoteFileSeparator) Set the file separator when dealing with remote files; default '/'.voidsetRenameExpression(Expression renameExpression) Specify a SpEL expression for files renaming during transfer.voidsetRenameExpressionString(String renameExpression) Specify a SpEL expression for files renaming during transfer.voidsetTemporaryFileSuffix(String temporaryFileSuffix) Set the temporary suffix to use when transferring files to the remote system.voidsetTemporaryRemoteDirectoryExpression(Expression temporaryRemoteDirectoryExpression) Set a temporary remote directory expression; used when transferring files to the remote system.voidsetUseTemporaryFileName(boolean useTemporaryFileName) Set whether a temporary file name is used when sending files to the remote system.Methods inherited from class org.springframework.integration.handler.AbstractReplyProducingMessageHandlerdoInvokeAdvisedRequestHandler, getBeanClassLoader, getIntegrationPatternType, getRequiresReply, handleMessageInternal, hasAdviceChain, onInit, setAdviceChain, setBeanClassLoader, setRequiresReplyMethods inherited from class org.springframework.integration.handler.AbstractMessageProducingHandleraddNotPropagatedHeaders, createOutputMessage, getNotPropagatedHeaders, getOutputChannel, isAsync, messageBuilderForReply, produceOutput, resolveErrorChannel, sendErrorMessage, sendOutput, sendOutputs, setAsync, setNotPropagatedHeaders, setOutputChannel, setOutputChannelName, setSendTimeout, setupMessageProcessor, shouldCopyRequestHeaders, shouldSplitOutput, updateNotPropagatedHeadersMethods inherited from class org.springframework.integration.handler.AbstractMessageHandlerhandleMessage, onComplete, onError, onNext, onSubscribe, setObservationConventionMethods inherited from class org.springframework.integration.handler.MessageHandlerSupportbuildSendTimer, destroy, getComponentType, getManagedName, getManagedType, getMetricsCaptor, getObservationRegistry, getOrder, getOverrides, isLoggingEnabled, isObserved, registerMetricsCaptor, registerObservationRegistry, sendTimer, setLoggingEnabled, setManagedName, setManagedType, setOrder, setShouldTrack, shouldTrackMethods inherited from class org.springframework.integration.context.IntegrationObjectSupportafterPropertiesSet, extractTypeIfPossible, generateId, getApplicationContext, getApplicationContextId, getBeanDescription, getBeanFactory, getBeanName, getChannelResolver, getComponentDescription, getComponentName, getComponentSource, getConversionService, getExpression, getIntegrationProperties, getMessageBuilderFactory, getTaskScheduler, isInitialized, setApplicationContext, setBeanFactory, setBeanName, setChannelResolver, setComponentDescription, setComponentName, setComponentSource, setConversionService, setMessageBuilderFactory, setPrimaryExpression, setTaskScheduler, toStringMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface reactor.core.CoreSubscribercurrentContextMethods inherited from interface org.springframework.integration.support.management.IntegrationManagementgetThisAsMethods inherited from interface org.springframework.integration.support.context.NamedComponentgetBeanName, getComponentName
- 
Constructor Details- 
AbstractRemoteFileOutboundGatewaypublic AbstractRemoteFileOutboundGateway(SessionFactory<F> sessionFactory, MessageSessionCallback<F, ?> messageSessionCallback) Construct an instance using the provided session factory and callback for performing operations on the session.- Parameters:
- sessionFactory- the session factory.
- messageSessionCallback- the callback.
 
- 
AbstractRemoteFileOutboundGatewaypublic AbstractRemoteFileOutboundGateway(RemoteFileTemplate<F> remoteFileTemplate, MessageSessionCallback<F, ?> messageSessionCallback) Construct an instance with the supplied remote file template and callback for performing operations on the session.- Parameters:
- remoteFileTemplate- the remote file template.
- messageSessionCallback- the callback.
 
- 
AbstractRemoteFileOutboundGatewaypublic AbstractRemoteFileOutboundGateway(SessionFactory<F> sessionFactory, String command, @Nullable String expression) Construct an instance with the supplied session factory, a command ('ls', 'get' etc.), and an expression to determine the remote path (file or directory). The expression is treated as a remote directory forlsandnlstcommands and can benullif remote file protocol supports it with a meaning of root directory (or use home). Theputandmputcommands ignore this expression and fully rely on the payload. If expression is not provided, it falls back to thepayload.- Parameters:
- sessionFactory- the session factory.
- command- the command.
- expression- the remote path.
 
- 
AbstractRemoteFileOutboundGatewaypublic AbstractRemoteFileOutboundGateway(SessionFactory<F> sessionFactory, AbstractRemoteFileOutboundGateway.Command command, @Nullable String expression) Construct an instance with the supplied session factory, a command ('ls', 'get' etc.), and an expression to determine the remote path (file or directory). The expression is treated as a remote directory forlsandnlstcommands and can benullif remote file protocol supports it with a meaning of root directory (or use home). Theputandmputcommands ignore this expression and fully rely on the payload. If expression is not provided, it falls back to thepayload.- Parameters:
- sessionFactory- the session factory.
- command- the command.
- expression- the remote path.
 
- 
AbstractRemoteFileOutboundGatewaypublic AbstractRemoteFileOutboundGateway(RemoteFileTemplate<F> remoteFileTemplate, String command, @Nullable String expression) Construct an instance with the supplied remote file template, a command ('ls', 'get' etc.), and an expression to determine the remote path (file or directory). The expression is treated as a remote directory forlsandnlstcommands and can benullif remote file protocol supports it with a meaning of root directory (or use home). Theputandmputcommands ignore this expression and fully rely on the payload. If expression is not provided, it falls back to thepayload.- Parameters:
- remoteFileTemplate- the remote file template.
- command- the command.
- expression- the remote path.
 
- 
AbstractRemoteFileOutboundGatewaypublic AbstractRemoteFileOutboundGateway(RemoteFileTemplate<F> remoteFileTemplate, AbstractRemoteFileOutboundGateway.Command command, @Nullable String expressionArg) Construct an instance with the supplied remote file template, a command ('ls', 'get' etc.), and an expression to determine the remote path (file or directory). The expression is treated as a remote directory forlsandnlstcommands and can benullif remote file protocol supports it with a meaning of root directory (or use home). Theputandmputcommands ignore this expression and fully rely on the payload. If expression is not provided, it falls back to thepayload.- Parameters:
- remoteFileTemplate- the remote file template.
- command- the command.
- expressionArg- the remote path.
 
 
- 
- 
Method Details- 
remoteFileTemplateExplicitlySetprotected final void remoteFileTemplateExplicitlySet(boolean remoteFileTemplateExplicitlySet) 
- 
assertRemoteFileTemplateMutability
- 
setOptionsSpecify the options for various gateway commands as a space-delimited string.- Parameters:
- options- the options to set
- See Also:
 
- 
setOptionSpecify the array of options for various gateway commands.- Parameters:
- options- the- AbstractRemoteFileOutboundGateway.Optionarray to use.
- Since:
- 5.0
- See Also:
 
- 
setRemoteFileSeparatorSet the file separator when dealing with remote files; default '/'.- Parameters:
- remoteFileSeparator- the separator.
- See Also:
 
- 
setLocalDirectorySpecify a directory path where remote files will be transferred to.- Parameters:
- localDirectory- the localDirectory to set
 
- 
setLocalDirectoryExpressionSpecify a SpEL expression to evaluate the directory path to which remote files will be transferred.- Parameters:
- localDirectoryExpression- the SpEL to determine the local directory.
 
- 
setLocalDirectoryExpressionStringSpecify a SpEL expression to evaluate the directory path to which remote files will be transferred.- Parameters:
- localDirectoryExpression- the SpEL to determine the local directory.
- Since:
- 5.0
 
- 
setAutoCreateLocalDirectorypublic void setAutoCreateLocalDirectory(boolean autoCreateLocalDirectory) Abooleanflag to identify if local directory should be created automatically. Defaults totrue.- Parameters:
- autoCreateLocalDirectory- the autoCreateLocalDirectory to set
 
- 
setTemporaryFileSuffixSet the temporary suffix to use when transferring files to the remote system. Default.writing.- Parameters:
- temporaryFileSuffix- the temporaryFileSuffix to set
- See Also:
 
- 
setAutoCreateDirectorypublic void setAutoCreateDirectory(boolean autoCreateDirectory) Determine whether the remote directory should automatically be created when sending files to the remote system.- Parameters:
- autoCreateDirectory- true to create the directory.
- Since:
- 5.2
- See Also:
 
- 
setRemoteDirectoryExpressionSet the remote directory expression used to determine the remote directory to which files will be sent.- Parameters:
- remoteDirectoryExpression- the remote directory expression.
- Since:
- 5.2
- See Also:
 
- 
setTemporaryRemoteDirectoryExpressionSet a temporary remote directory expression; used when transferring files to the remote system. After a successful transfer the file is renamed using theremoteDirectoryExpression.- Parameters:
- temporaryRemoteDirectoryExpression- the temporary remote directory expression.
- Since:
- 5.2
- See Also:
 
- 
setFileNameExpressionSet the file name expression to determine the full path to the remote file.- Parameters:
- fileNameExpression- the file name expression.
- Since:
- 5.2
- See Also:
 
- 
setUseTemporaryFileNamepublic void setUseTemporaryFileName(boolean useTemporaryFileName) Set whether a temporary file name is used when sending files to the remote system.- Parameters:
- useTemporaryFileName- true to use a temporary file name.
- Since:
- 5.2
- See Also:
 
- 
setFileNameGeneratorSet the file name generator used to generate the remote filename to be used when transferring files to the remote system.- Parameters:
- fileNameGenerator- the file name generator.
- Since:
- 5.2
- See Also:
 
- 
setCharsetSet the charset to use when converting String payloads to bytes as the content of the remote file. DefaultUTF-8.- Parameters:
- charset- the charset.
- Since:
- 5.2
- See Also:
 
- 
setFilterSet aFileListFilterto filter remote files.- Parameters:
- filter- the filter to set
 
- 
setMputFilterAFileListFilterthat runs against the local file system view when usingMPUTcommand.- Parameters:
- filter- the filter to set
 
- 
setRenameExpressionSpecify a SpEL expression for files renaming during transfer.- Parameters:
- renameExpression- the expression to use.
- Since:
- 4.3
 
- 
setRenameExpressionStringSpecify a SpEL expression for files renaming during transfer.- Parameters:
- renameExpression- the String in SpEL syntax.
- Since:
- 4.3
 
- 
setLocalFilenameGeneratorExpressionSpecify a SpEL expression for local files renaming after downloading.- Parameters:
- localFilenameGeneratorExpression- the expression to use.
- Since:
- 3.0
 
- 
setLocalFilenameGeneratorExpressionStringSpecify a SpEL expression for local files renaming after downloading.- Parameters:
- localFilenameGeneratorExpression- the String in SpEL syntax.
- Since:
- 4.3
 
- 
setFileExistsModeDetermine the action to take when using GET and MGET operations when the file already exists locally, or PUT and MPUT when the file exists on the remote system.- Parameters:
- fileExistsMode- the fileExistsMode to set.
- Since:
- 4.2
 
- 
setChmodOctalString setter for Spring XML convenience.- Parameters:
- chmod- permissions as an octal string e.g "600";
- Since:
- 4.3
- See Also:
 
- 
setChmodpublic void setChmod(int chmod) Set the file permissions after uploading, e.g. 0600 for owner read/write.- Parameters:
- chmod- the permissions.
- Since:
- 4.3
 
- 
isChmodCapablepublic boolean isChmodCapable()
- 
getRemoteFileTemplate
- 
doInitprotected void doInit()- Overrides:
- doInitin class- AbstractReplyProducingMessageHandler
 
- 
handleRequestMessageDescription copied from class:AbstractReplyProducingMessageHandlerSubclasses must implement this method to handle the request Message. The return value may be a Message, a MessageBuilder, or any plain Object. The base class will handle the final creation of a reply Message from any of those starting points. If the return value is null, the Message flow will end here.- Specified by:
- handleRequestMessagein class- AbstractReplyProducingMessageHandler
- Parameters:
- requestMessage- The request message.
- Returns:
- The result of handling the message, or null.
 
- 
nlstList remote files names for the provided directory. The message can be consulted for some context related to the current request; isn't used in the default implementation.- Parameters:
- message- the message related to the current request
- session- the session to perform list file names command
- dir- the remote directory to list file names
- Returns:
- the list of file/directory names in the provided dir
- Throws:
- IOException- the IO exception during performing remote command
- Since:
- 5.0
 
- 
rmprotected boolean rm(Message<?> message, Session<F> session, String remoteFilePath) throws IOException Perform remote delete for the provided path. The message can be consulted to determine some context; isn't used in the default implementation.- Parameters:
- message- the request message related to the path to remove
- session- the remote protocol session to perform remove command
- remoteFilePath- the remote path to remove
- Returns:
- true or false as a result of the remote removal
- Throws:
- IOException- the IO exception during performing remote command
- Since:
- 5.0
 
- 
mvprotected boolean mv(Message<?> message, Session<F> session, String remoteFilePath, String remoteFileNewPath) throws IOException Move one remote path to another. The message can be consulted to determine some context; isn't used in the default implementation.- Parameters:
- message- the request message related to this move command
- session- the remote protocol session to perform move command
- remoteFilePath- the source remote path
- remoteFileNewPath- the target remote path
- Returns:
- true or false as a result of the operation
- Throws:
- IOException- the IO exception during performing remote command
- Since:
- 5.0
 
- 
putPut the file based on the message to the remote server. The message can be consulted to determine some context. The session argument isn't used in the default implementation.- Parameters:
- message- the request message related to this put command
- session- the remote protocol session related to this invocation context
- subDirectory- the target sub-directory to put
- Returns:
- The remote path, or null if no local file was found.
- Since:
- 5.0
 
- 
doChmodSet the mode on the remote file after transfer; the default implementation does nothing.- Parameters:
- remoteFileOperations- the remote file template.
- path- the path.
- chmodToSet- the chmod to set.
- Since:
- 4.3
 
- 
mPutPut files from the provided directory to the remote server recursively. The message can be consulted to determine some context. The session argument isn't used in the default implementation.- Parameters:
- message- the request message related to this mPut command
- session- the remote protocol session for this invocation context
- localDir- the local directory to mput to the server
- Returns:
- The list of remote paths for sent files
- Since:
- 5.0
 
- 
lsList remote files to local representation. The message can be consulted for some context for the current request; isn't used in the default implementation.- Parameters:
- message- the message related to the list request
- session- the session to perform list command
- dir- the remote directory to list content
- Returns:
- the list of remote files
- Throws:
- IOException- the IO exception during performing remote command
 
- 
filterFiles
- 
filterFile
- 
filterMputFiles
- 
purgeLinks
- 
purgeDots
- 
getprotected File get(Message<?> message, Session<F> session, String remoteDir, String remoteFilePath, String remoteFilename, F fileInfoParam) throws IOException Copy a remote file to the configured local directory.- Parameters:
- message- the message.
- session- the session.
- remoteDir- the remote directory.
- remoteFilePath- the remote file path.
- remoteFilename- the remote file name.
- fileInfoParam- the remote file info; if null we will execute an 'ls' command first.
- Returns:
- The file.
- Throws:
- IOException- Any IOException.
 
- 
mGetprotected List<File> mGet(Message<?> message, Session<F> session, String remoteDirectory, String remoteFilename) throws IOException - Throws:
- IOException
 
- 
getFullFileNameBy default, this method contacts the remote directory with the remote file name to build a full remote file path. The remote file protocol-specific implementation may override this method for other approach.- Parameters:
- remoteDirectory- the directory remote file belongs.
- remoteFile- the remote file to take a name and adjust its path according provided remote directory.
- Returns:
- the full path for the remote file
 
- 
getRemoteFilename- Parameters:
- remoteFilePath- The remote file path.
- Returns:
- The remote file name.
 
- 
isDirectory
- 
isLink
- 
getFilename
- 
getFilename
- 
getModified
- 
asFileInfoList
- 
enhanceNameWithSubDirectory
 
-