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.outbound.FtpOutboundGateway
- 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
public class FtpOutboundGateway
extends AbstractRemoteFileOutboundGateway<org.apache.commons.net.ftp.FTPFile>
Outbound Gateway for performing remote file operations via FTP/FTPS.
- Since:
- 7.0
- Author:
- Gary Russell, Artem Bilan
-
Nested Class Summary
Nested classes/interfaces inherited from class org.springframework.integration.file.remote.gateway.AbstractRemoteFileOutboundGateway
AbstractRemoteFileOutboundGateway.Command, AbstractRemoteFileOutboundGateway.OptionNested classes/interfaces inherited from class org.springframework.integration.handler.AbstractReplyProducingMessageHandler
AbstractReplyProducingMessageHandler.RequestHandlerNested classes/interfaces inherited from interface org.springframework.integration.support.management.IntegrationManagement
IntegrationManagement.ManagementOverrides -
Field Summary
Fields inherited from class org.springframework.integration.handler.AbstractMessageProducingHandler
messagingTemplateFields inherited from class org.springframework.integration.context.IntegrationObjectSupport
EXPRESSION_PARSER, loggerFields inherited from interface org.springframework.integration.support.management.IntegrationManagement
METER_PREFIX, RECEIVE_COUNTER_NAME, SEND_TIMER_NAMEFields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE -
Constructor Summary
ConstructorsConstructorDescriptionFtpOutboundGateway(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, @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.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, @Nullable String expression) Construct an instance with the supplied session factory, a command ('ls', 'get' etc.), and an expression to determine the remote path.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 Summary
Modifier 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, @Nullable String remoteDir, String remoteFilePath, String remoteFilename, @Nullable org.apache.commons.net.ftp.FTPFile fileInfoParam) Copy a remote file to the configured local directory.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(Message<?> message, Session<org.apache.commons.net.ftp.FTPFile> session, @Nullable String subDirectory) Put 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.AbstractRemoteFileOutboundGateway
assertRemoteFileTemplateMutability, filterFile, filterFiles, filterMputFiles, getFullFileName, getRemoteFilename, getRemoteFileTemplate, handleRequestMessage, purgeDots, purgeLinks, remoteFileTemplateExplicitlySet, setAutoCreateDirectory, setAutoCreateLocalDirectory, setCharset, setChmod, setChmodOctal, setFileExistsMode, setFileExistsModeExpression, setFileExistsModeExpressionString, 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.AbstractReplyProducingMessageHandler
doInvokeAdvisedRequestHandler, getBeanClassLoader, getIntegrationPatternType, getRequiresReply, handleMessageInternal, hasAdviceChain, onInit, setAdviceChain, setBeanClassLoader, setRequiresReplyMethods inherited from class org.springframework.integration.handler.AbstractMessageProducingHandler
addNotPropagatedHeaders, 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.AbstractMessageHandler
handleMessage, onComplete, onError, onNext, onSubscribe, setObservationConventionMethods inherited from class org.springframework.integration.handler.MessageHandlerSupport
buildSendTimer, 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.IntegrationObjectSupport
afterPropertiesSet, 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.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface reactor.core.CoreSubscriber
currentContextMethods inherited from interface org.springframework.integration.support.management.IntegrationManagement
getThisAsMethods inherited from interface org.springframework.integration.support.context.NamedComponent
getBeanName, getComponentName
-
Constructor Details
-
FtpOutboundGateway
public 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.
-
FtpOutboundGateway
public 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.
-
FtpOutboundGateway
public FtpOutboundGateway(SessionFactory<org.apache.commons.net.ftp.FTPFile> 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.- Parameters:
sessionFactory- the session factory.command- the command.expression- the remote path expression.
-
FtpOutboundGateway
public FtpOutboundGateway(RemoteFileTemplate<org.apache.commons.net.ftp.FTPFile> 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.- Parameters:
remoteFileTemplate- the remote file template.command- the command.expression- the remote path expression.
-
FtpOutboundGateway
public 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.
-
FtpOutboundGateway
public 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.
-
-
Method Details
-
setWorkingDirExpression
Specify anExpressionto evaluate FTP client working directory against request message.- Parameters:
workingDirExpression- the expression to evaluate working directory
-
setWorkingDirExpressionString
Specify a SpELExpressionto evaluate FTP client working directory against request message.- Parameters:
workingDirExpression- the SpEL expression to evaluate working directory
-
getComponentType
- Specified by:
getComponentTypein interfaceNamedComponent- Overrides:
getComponentTypein classMessageHandlerSupport
-
isDirectory
protected boolean isDirectory(org.apache.commons.net.ftp.FTPFile file) - Specified by:
isDirectoryin classAbstractRemoteFileOutboundGateway<org.apache.commons.net.ftp.FTPFile>
-
isLink
protected boolean isLink(org.apache.commons.net.ftp.FTPFile file) - Specified by:
isLinkin classAbstractRemoteFileOutboundGateway<org.apache.commons.net.ftp.FTPFile>
-
getFilename
- Specified by:
getFilenamein classAbstractRemoteFileOutboundGateway<org.apache.commons.net.ftp.FTPFile>
-
getFilename
- Specified by:
getFilenamein classAbstractRemoteFileOutboundGateway<org.apache.commons.net.ftp.FTPFile>
-
getModified
protected long getModified(org.apache.commons.net.ftp.FTPFile file) - Specified by:
getModifiedin classAbstractRemoteFileOutboundGateway<org.apache.commons.net.ftp.FTPFile>
-
asFileInfoList
protected List<AbstractFileInfo<org.apache.commons.net.ftp.FTPFile>> asFileInfoList(Collection<org.apache.commons.net.ftp.FTPFile> files) - Specified by:
asFileInfoListin classAbstractRemoteFileOutboundGateway<org.apache.commons.net.ftp.FTPFile>
-
doInit
protected void doInit()- Overrides:
doInitin classAbstractRemoteFileOutboundGateway<org.apache.commons.net.ftp.FTPFile>
-
enhanceNameWithSubDirectory
protected org.apache.commons.net.ftp.FTPFile enhanceNameWithSubDirectory(org.apache.commons.net.ftp.FTPFile file, String directory) - Specified by:
enhanceNameWithSubDirectoryin classAbstractRemoteFileOutboundGateway<org.apache.commons.net.ftp.FTPFile>
-
ls
protected List<?> ls(Message<?> message, Session<org.apache.commons.net.ftp.FTPFile> session, @Nullable 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 classAbstractRemoteFileOutboundGateway<org.apache.commons.net.ftp.FTPFile>- Parameters:
message- the message related to the list requestsession- the session to perform list commanddir- the remote directory to list content- Returns:
- the list of remote files
- Throws:
IOException- the IO exception during performing remote command
-
nlst
protected List<String> nlst(Message<?> message, Session<org.apache.commons.net.ftp.FTPFile> session, @Nullable 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 classAbstractRemoteFileOutboundGateway<org.apache.commons.net.ftp.FTPFile>- Parameters:
message- the message related to the current requestsession- the session to perform list file names commanddir- 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
-
get
protected File get(Message<?> message, Session<org.apache.commons.net.ftp.FTPFile> session, @Nullable String remoteDir, String remoteFilePath, String remoteFilename, @Nullable org.apache.commons.net.ftp.FTPFile fileInfoParam) throws IOException Description copied from class:AbstractRemoteFileOutboundGatewayCopy a remote file to the configured local directory.- Overrides:
getin classAbstractRemoteFileOutboundGateway<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.
-
mGet
protected List<File> mGet(Message<?> message, Session<org.apache.commons.net.ftp.FTPFile> session, String remoteDirectory, String remoteFilename) throws IOException - Overrides:
mGetin classAbstractRemoteFileOutboundGateway<org.apache.commons.net.ftp.FTPFile>- Throws:
IOException
-
rm
protected 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 classAbstractRemoteFileOutboundGateway<org.apache.commons.net.ftp.FTPFile>- Parameters:
message- the request message related to the path to removesession- the remote protocol session to perform remove commandremoteFilePath- 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
-
mv
protected 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 classAbstractRemoteFileOutboundGateway<org.apache.commons.net.ftp.FTPFile>- Parameters:
message- the request message related to this move commandsession- the remote protocol session to perform move commandremoteFilePath- the source remote pathremoteFileNewPath- the target remote path- Returns:
- true or false as a result of the operation
- Throws:
IOException- the IO exception during performing remote command
-
put
protected String put(Message<?> message, Session<org.apache.commons.net.ftp.FTPFile> session, @Nullable 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 classAbstractRemoteFileOutboundGateway<org.apache.commons.net.ftp.FTPFile>- Parameters:
message- the request message related to this put commandsession- the remote protocol session related to this invocation contextsubDirectory- the target sub-directory to put- Returns:
- The remote path, or null if no local file was found.
-
mPut
protected 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 classAbstractRemoteFileOutboundGateway<org.apache.commons.net.ftp.FTPFile>- Parameters:
message- the request message related to this mPut commandsession- the remote protocol session for this invocation contextlocalDir- the local directory to mput to the server- Returns:
- The list of remote paths for sent files
-
isChmodCapable
public boolean isChmodCapable()- Overrides:
isChmodCapablein classAbstractRemoteFileOutboundGateway<org.apache.commons.net.ftp.FTPFile>
-
doChmod
protected 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 classAbstractRemoteFileOutboundGateway<org.apache.commons.net.ftp.FTPFile>- Parameters:
remoteFileOperations- the remote file template.path- the path.chmod- the chmod to set.
-