Class FtpOutboundGateway
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<org.apache.commons.net.ftp.FTPFile>
org.springframework.integration.ftp.gateway.FtpOutboundGateway
- All Implemented Interfaces:
- org.reactivestreams.Subscriber<Message<?>>,- Aware,- BeanClassLoaderAware,- BeanFactoryAware,- BeanNameAware,- DisposableBean,- InitializingBean,- ApplicationContextAware,- Ordered,- ExpressionCapable,- Orderable,- MessageProducer,- HeaderPropagationAware,- IntegrationPattern,- NamedComponent,- IntegrationManagement,- TrackableComponent,- MessageHandler,- reactor.core.CoreSubscriber<Message<?>>
public class FtpOutboundGateway
extends AbstractRemoteFileOutboundGateway<org.apache.commons.net.ftp.FTPFile>
Outbound Gateway for performing remote file operations via FTP/FTPS.
- Since:
- 2.1
- Author:
- Gary Russell, Artem Bilan
- 
Nested Class SummaryNested classes/interfaces inherited from class org.springframework.integration.file.remote.gateway.AbstractRemoteFileOutboundGatewayAbstractRemoteFileOutboundGateway.Command, AbstractRemoteFileOutboundGateway.OptionNested 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 SummaryConstructorsConstructorDescriptionFtpOutboundGateway(RemoteFileTemplate<org.apache.commons.net.ftp.FTPFile> remoteFileTemplate, String command) Construct an instance with the supplied remote file template and command ('ls', 'nlst', 'put' or 'mput').FtpOutboundGateway(RemoteFileTemplate<org.apache.commons.net.ftp.FTPFile> 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 filename.FtpOutboundGateway(RemoteFileTemplate<org.apache.commons.net.ftp.FTPFile> remoteFileTemplate, MessageSessionCallback<org.apache.commons.net.ftp.FTPFile, ?> messageSessionCallback) Construct an instance with the supplied remote file template and callback for performing operations on the session.FtpOutboundGateway(SessionFactory<org.apache.commons.net.ftp.FTPFile> sessionFactory, String command) Construct an instance with the supplied session factory and command ('ls', 'nlst', 'put' or 'mput').FtpOutboundGateway(SessionFactory<org.apache.commons.net.ftp.FTPFile> sessionFactory, String command, String expression) Construct an instance with the supplied session factory, a command ('ls', 'get' etc), and an expression to determine the filename.FtpOutboundGateway(SessionFactory<org.apache.commons.net.ftp.FTPFile> sessionFactory, MessageSessionCallback<org.apache.commons.net.ftp.FTPFile, ?> messageSessionCallback) Construct an instance using the provided session factory and callback for performing operations on the session.
- 
Method SummaryModifier and TypeMethodDescriptionprotected List<AbstractFileInfo<org.apache.commons.net.ftp.FTPFile>>asFileInfoList(Collection<org.apache.commons.net.ftp.FTPFile> files) protected voiddoChmod(RemoteFileOperations<org.apache.commons.net.ftp.FTPFile> remoteFileOperations, String path, int chmod) Set the mode on the remote file after transfer; the default implementation does nothing.protected voiddoInit()protected org.apache.commons.net.ftp.FTPFileenhanceNameWithSubDirectory(org.apache.commons.net.ftp.FTPFile file, String directory) protected Fileget(Message<?> message, Session<org.apache.commons.net.ftp.FTPFile> session, String remoteDir, String remoteFilePath, String remoteFilename, org.apache.commons.net.ftp.FTPFile fileInfoParam) Copy a remote file to the configured local directory.Subclasses may implement this method to provide component type information.protected StringgetFilename(org.apache.commons.net.ftp.FTPFile file) protected StringgetFilename(AbstractFileInfo<org.apache.commons.net.ftp.FTPFile> file) protected longgetModified(org.apache.commons.net.ftp.FTPFile file) booleanprotected booleanisDirectory(org.apache.commons.net.ftp.FTPFile file) protected booleanisLink(org.apache.commons.net.ftp.FTPFile file) protected List<?>List remote files to local representation.mGet(Message<?> message, Session<org.apache.commons.net.ftp.FTPFile> session, String remoteDirectory, String remoteFilename) Put files from the provided directory to the remote server recursively.protected booleanmv(Message<?> message, Session<org.apache.commons.net.ftp.FTPFile> session, String remoteFilePath, String remoteFileNewPath) Move one remote path to another.List remote files names for the provided directory.protected StringPut the file based on the message to the remote server.protected booleanPerform remote delete for the provided path.voidsetWorkingDirExpression(Expression workingDirExpression) Specify anExpressionto evaluate FTP client working directory against request message.voidsetWorkingDirExpressionString(String workingDirExpression) Specify a SpELExpressionto evaluate FTP client working directory against request message.Methods inherited from class org.springframework.integration.file.remote.gateway.AbstractRemoteFileOutboundGatewayassertRemoteFileTemplateMutability, filterFile, filterFiles, filterMputFiles, getFullFileName, getRemoteFilename, getRemoteFileTemplate, handleRequestMessage, purgeDots, purgeLinks, remoteFileTemplateExplicitlySet, setAutoCreateDirectory, setAutoCreateLocalDirectory, setCharset, setChmod, setChmodOctal, setFileExistsMode, setFileNameExpression, setFileNameGenerator, setFilter, setLocalDirectory, setLocalDirectoryExpression, setLocalDirectoryExpressionString, setLocalFilenameGeneratorExpression, setLocalFilenameGeneratorExpressionString, setMputFilter, setOption, setOptions, setRemoteDirectoryExpression, setRemoteFileSeparator, setRenameExpression, setRenameExpressionString, setTemporaryFileSuffix, setTemporaryRemoteDirectoryExpression, setUseTemporaryFileNameMethods 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, 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, getComponentName, getConversionService, getExpression, getIntegrationProperties, getMessageBuilderFactory, getTaskScheduler, isInitialized, setApplicationContext, setBeanFactory, setBeanName, setChannelResolver, setComponentName, 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- 
FtpOutboundGatewaypublic FtpOutboundGateway(SessionFactory<org.apache.commons.net.ftp.FTPFile> sessionFactory, MessageSessionCallback<org.apache.commons.net.ftp.FTPFile, ?> 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.
 
- 
FtpOutboundGatewaypublic FtpOutboundGateway(RemoteFileTemplate<org.apache.commons.net.ftp.FTPFile> remoteFileTemplate, MessageSessionCallback<org.apache.commons.net.ftp.FTPFile, ?> 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.
 
- 
FtpOutboundGatewaypublic FtpOutboundGateway(SessionFactory<org.apache.commons.net.ftp.FTPFile> sessionFactory, String command, String expression) Construct an instance with the supplied session factory, a command ('ls', 'get' etc), and an expression to determine the filename.- Parameters:
- sessionFactory- the session factory.
- command- the command.
- expression- the filename expression.
 
- 
FtpOutboundGatewaypublic FtpOutboundGateway(RemoteFileTemplate<org.apache.commons.net.ftp.FTPFile> 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 filename.- Parameters:
- remoteFileTemplate- the remote file template.
- command- the command.
- expression- the filename expression.
 
- 
FtpOutboundGatewaypublic FtpOutboundGateway(SessionFactory<org.apache.commons.net.ftp.FTPFile> sessionFactory, String command) Construct an instance with the supplied session factory and command ('ls', 'nlst', 'put' or 'mput').The remoteDirectoryexpression isnullassuming to use theworkingDirectoryfrom the FTP Client.- Parameters:
- sessionFactory- the session factory.
- command- the command.
- Since:
- 4.3
 
- 
FtpOutboundGatewaypublic FtpOutboundGateway(RemoteFileTemplate<org.apache.commons.net.ftp.FTPFile> remoteFileTemplate, String command) Construct an instance with the supplied remote file template and command ('ls', 'nlst', 'put' or 'mput').The remoteDirectoryexpression isnullassuming to use theworkingDirectoryfrom the FTP Client.- Parameters:
- remoteFileTemplate- the remote file template.
- command- the command.
- Since:
- 4.3
 
 
- 
- 
Method Details- 
setWorkingDirExpressionSpecify anExpressionto evaluate FTP client working directory against request message.- Parameters:
- workingDirExpression- the expression to evaluate working directory
- Since:
- 5.0
 
- 
setWorkingDirExpressionStringSpecify a SpELExpressionto evaluate FTP client working directory against request message.- Parameters:
- workingDirExpression- the SpEL expression to evaluate working directory
- Since:
- 5.0
 
- 
getComponentTypeDescription copied from class:IntegrationObjectSupportSubclasses may implement this method to provide component type information.- Specified by:
- getComponentTypein interface- NamedComponent
- Overrides:
- getComponentTypein class- MessageHandlerSupport
 
- 
isDirectoryprotected boolean isDirectory(org.apache.commons.net.ftp.FTPFile file) - Specified by:
- isDirectoryin class- AbstractRemoteFileOutboundGateway<org.apache.commons.net.ftp.FTPFile>
 
- 
isLinkprotected boolean isLink(org.apache.commons.net.ftp.FTPFile file) - Specified by:
- isLinkin class- AbstractRemoteFileOutboundGateway<org.apache.commons.net.ftp.FTPFile>
 
- 
getFilename- Specified by:
- getFilenamein class- AbstractRemoteFileOutboundGateway<org.apache.commons.net.ftp.FTPFile>
 
- 
getFilename- Specified by:
- getFilenamein class- AbstractRemoteFileOutboundGateway<org.apache.commons.net.ftp.FTPFile>
 
- 
getModifiedprotected long getModified(org.apache.commons.net.ftp.FTPFile file) - Specified by:
- getModifiedin class- AbstractRemoteFileOutboundGateway<org.apache.commons.net.ftp.FTPFile>
 
- 
asFileInfoListprotected List<AbstractFileInfo<org.apache.commons.net.ftp.FTPFile>> asFileInfoList(Collection<org.apache.commons.net.ftp.FTPFile> files) - Specified by:
- asFileInfoListin class- AbstractRemoteFileOutboundGateway<org.apache.commons.net.ftp.FTPFile>
 
- 
doInitprotected void doInit()- Overrides:
- doInitin class- AbstractRemoteFileOutboundGateway<org.apache.commons.net.ftp.FTPFile>
 
- 
enhanceNameWithSubDirectoryprotected org.apache.commons.net.ftp.FTPFile enhanceNameWithSubDirectory(org.apache.commons.net.ftp.FTPFile file, String directory) - Specified by:
- enhanceNameWithSubDirectoryin class- AbstractRemoteFileOutboundGateway<org.apache.commons.net.ftp.FTPFile>
 
- 
lsprotected List<?> ls(Message<?> message, Session<org.apache.commons.net.ftp.FTPFile> session, String dir) throws IOException Description copied from class:AbstractRemoteFileOutboundGatewayList remote files to local representation. The message can be consulted for some context for the current request; isn't used in the default implementation.- Overrides:
- lsin class- AbstractRemoteFileOutboundGateway<org.apache.commons.net.ftp.FTPFile>
- 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
 
- 
nlstprotected List<String> nlst(Message<?> message, Session<org.apache.commons.net.ftp.FTPFile> session, String dir) throws IOException Description copied from class:AbstractRemoteFileOutboundGatewayList 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.- Overrides:
- nlstin class- AbstractRemoteFileOutboundGateway<org.apache.commons.net.ftp.FTPFile>
- 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
 
- 
getprotected File get(Message<?> message, Session<org.apache.commons.net.ftp.FTPFile> session, String remoteDir, String remoteFilePath, String remoteFilename, org.apache.commons.net.ftp.FTPFile fileInfoParam) throws IOException Description copied from class:AbstractRemoteFileOutboundGatewayCopy a remote file to the configured local directory.- Overrides:
- getin class- AbstractRemoteFileOutboundGateway<org.apache.commons.net.ftp.FTPFile>
- 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<org.apache.commons.net.ftp.FTPFile> session, String remoteDirectory, String remoteFilename) throws IOException - Overrides:
- mGetin class- AbstractRemoteFileOutboundGateway<org.apache.commons.net.ftp.FTPFile>
- Throws:
- IOException
 
- 
rmprotected boolean rm(Message<?> message, Session<org.apache.commons.net.ftp.FTPFile> session, String remoteFilePath) throws IOException Description copied from class:AbstractRemoteFileOutboundGatewayPerform remote delete for the provided path. The message can be consulted to determine some context; isn't used in the default implementation.- Overrides:
- rmin class- AbstractRemoteFileOutboundGateway<org.apache.commons.net.ftp.FTPFile>
- 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
 
- 
mvprotected boolean mv(Message<?> message, Session<org.apache.commons.net.ftp.FTPFile> session, String remoteFilePath, String remoteFileNewPath) throws IOException Description copied from class:AbstractRemoteFileOutboundGatewayMove one remote path to another. The message can be consulted to determine some context; isn't used in the default implementation.- Overrides:
- mvin class- AbstractRemoteFileOutboundGateway<org.apache.commons.net.ftp.FTPFile>
- 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
 
- 
putprotected String put(Message<?> message, Session<org.apache.commons.net.ftp.FTPFile> session, String subDirectory) Description copied from class:AbstractRemoteFileOutboundGatewayPut 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.- Overrides:
- putin class- AbstractRemoteFileOutboundGateway<org.apache.commons.net.ftp.FTPFile>
- 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.
 
- 
mPutprotected List<String> mPut(Message<?> message, Session<org.apache.commons.net.ftp.FTPFile> session, File localDir) Description copied from class:AbstractRemoteFileOutboundGatewayPut 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.- Overrides:
- mPutin class- AbstractRemoteFileOutboundGateway<org.apache.commons.net.ftp.FTPFile>
- 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
 
- 
isChmodCapablepublic boolean isChmodCapable()- Overrides:
- isChmodCapablein class- AbstractRemoteFileOutboundGateway<org.apache.commons.net.ftp.FTPFile>
 
- 
doChmodprotected void doChmod(RemoteFileOperations<org.apache.commons.net.ftp.FTPFile> remoteFileOperations, String path, int chmod) Description copied from class:AbstractRemoteFileOutboundGatewaySet the mode on the remote file after transfer; the default implementation does nothing.- Overrides:
- doChmodin class- AbstractRemoteFileOutboundGateway<org.apache.commons.net.ftp.FTPFile>
- Parameters:
- remoteFileOperations- the remote file template.
- path- the path.
- chmod- the chmod to set.
 
 
-