Spring Integration

org.springframework.integration.file.remote.gateway
Class AbstractRemoteFileOutboundGateway<F>

java.lang.Object
  extended by org.springframework.integration.context.IntegrationObjectSupport
      extended by org.springframework.integration.handler.AbstractMessageHandler
          extended by org.springframework.integration.handler.AbstractReplyProducingMessageHandler
              extended by org.springframework.integration.file.remote.gateway.AbstractRemoteFileOutboundGateway<F>
All Implemented Interfaces:
org.springframework.beans.factory.BeanFactoryAware, org.springframework.beans.factory.BeanNameAware, org.springframework.beans.factory.InitializingBean, org.springframework.core.Ordered, NamedComponent, Orderable, MessageHandler, MessageProducer, TrackableComponent
Direct Known Subclasses:
FtpOutboundGateway, SftpOutboundGateway

public abstract class AbstractRemoteFileOutboundGateway<F>
extends AbstractReplyProducingMessageHandler

Base class for Outbound Gateways that perform remote file operations.

Since:
2.1
Author:
Gary Russell

Field Summary
protected  java.lang.String command
           
static java.lang.String COMMAND_GET
           
static java.lang.String COMMAND_LS
           
static java.lang.String COMMAND_MGET
           
static java.lang.String COMMAND_RM
           
static java.lang.String OPTION_ALL
           
static java.lang.String OPTION_EXCEPTION_WHEN_EMPTY
           
static java.lang.String OPTION_LINKS
           
static java.lang.String OPTION_NAME_ONLY
           
static java.lang.String OPTION_NOSORT
           
static java.lang.String OPTION_PRESERVE_TIMESTAMP
           
static java.lang.String OPTION_SUBDIRS
           
protected  java.util.Set<java.lang.String> options
           
protected  SessionFactory<F> sessionFactory
           
 
Fields inherited from class org.springframework.integration.context.IntegrationObjectSupport
logger
 
Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
 
Constructor Summary
AbstractRemoteFileOutboundGateway(SessionFactory<F> sessionFactory, java.lang.String command, java.lang.String expression)
           
 
Method Summary
protected abstract  java.util.List<AbstractFileInfo<F>> asFileInfoList(java.util.Collection<F> files)
           
protected  java.util.List<F> filterFiles(F[] files)
           
protected  java.io.File get(Session<F> session, java.lang.String remoteFilePath, java.lang.String remoteFilename, boolean lsFirst)
          Copy a remote file to the configured local directory.
protected abstract  java.lang.String getFilename(F file)
           
protected abstract  long getModified(F file)
           
protected  java.lang.String getRemoteFilename(java.lang.String remoteFilePath)
           
protected  java.lang.Object handleRequestMessage(Message<?> requestMessage)
          Subclasses must implement this method to handle the request Message.
protected abstract  boolean isDirectory(F file)
           
protected abstract  boolean isLink(F file)
           
protected  java.util.List<?> ls(Session<F> session, java.lang.String dir)
           
protected  java.util.List<java.io.File> mGet(Session<F> session, java.lang.String remoteDirectory, java.lang.String remoteFilename)
           
protected  void onInit()
          Subclasses may implement this for initialization logic.
protected  void purgeDots(java.util.List<F> lsFiles)
           
protected  void purgeLinks(java.util.List<F> lsFiles)
           
protected  boolean rm(Session<?> session, java.lang.String remoteFilePath)
           
 void setAutoCreateLocalDirectory(boolean autoCreateLocalDirectory)
           
 void setFilter(FileListFilter<F> filter)
           
 void setLocalDirectory(java.io.File localDirectory)
           
 void setOptions(java.lang.String options)
           
 void setRemoteFileSeparator(java.lang.String remoteFileSeparator)
           
 void setTemporaryFileSuffix(java.lang.String temporaryFileSuffix)
           
 
Methods inherited from class org.springframework.integration.handler.AbstractReplyProducingMessageHandler
getMessagingTemplate, handleMessageInternal, setChannelResolver, setOutputChannel, setRequiresReply, setSendTimeout, shouldCopyRequestHeaders
 
Methods inherited from class org.springframework.integration.handler.AbstractMessageHandler
getComponentType, getOrder, handleMessage, setOrder, setShouldTrack
 
Methods inherited from class org.springframework.integration.context.IntegrationObjectSupport
afterPropertiesSet, getBeanFactory, getComponentName, getConversionService, getTaskScheduler, setBeanFactory, setBeanName, setComponentName, setConversionService, setTaskScheduler, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.springframework.integration.context.NamedComponent
getComponentName
 

Field Detail

sessionFactory

protected final SessionFactory<F> sessionFactory

command

protected final java.lang.String command

COMMAND_LS

public static final java.lang.String COMMAND_LS
See Also:
Constant Field Values

COMMAND_GET

public static final java.lang.String COMMAND_GET
See Also:
Constant Field Values

COMMAND_RM

public static final java.lang.String COMMAND_RM
See Also:
Constant Field Values

COMMAND_MGET

public static final java.lang.String COMMAND_MGET
See Also:
Constant Field Values

OPTION_NAME_ONLY

public static final java.lang.String OPTION_NAME_ONLY
See Also:
Constant Field Values

OPTION_ALL

public static final java.lang.String OPTION_ALL
See Also:
Constant Field Values

OPTION_NOSORT

public static final java.lang.String OPTION_NOSORT
See Also:
Constant Field Values

OPTION_SUBDIRS

public static final java.lang.String OPTION_SUBDIRS
See Also:
Constant Field Values

OPTION_LINKS

public static final java.lang.String OPTION_LINKS
See Also:
Constant Field Values

OPTION_PRESERVE_TIMESTAMP

public static final java.lang.String OPTION_PRESERVE_TIMESTAMP
See Also:
Constant Field Values

OPTION_EXCEPTION_WHEN_EMPTY

public static final java.lang.String OPTION_EXCEPTION_WHEN_EMPTY
See Also:
Constant Field Values

options

protected volatile java.util.Set<java.lang.String> options
Constructor Detail

AbstractRemoteFileOutboundGateway

public AbstractRemoteFileOutboundGateway(SessionFactory<F> sessionFactory,
                                         java.lang.String command,
                                         java.lang.String expression)
Method Detail

setOptions

public void setOptions(java.lang.String options)
Parameters:
options - the options to set

setRemoteFileSeparator

public void setRemoteFileSeparator(java.lang.String remoteFileSeparator)
Parameters:
remoteFileSeparator - the remoteFileSeparator to set

setLocalDirectory

public void setLocalDirectory(java.io.File localDirectory)
Parameters:
localDirectory - the localDirectory to set

setAutoCreateLocalDirectory

public void setAutoCreateLocalDirectory(boolean autoCreateLocalDirectory)
Parameters:
autoCreateLocalDirectory - the autoCreateLocalDirectory to set

setTemporaryFileSuffix

public void setTemporaryFileSuffix(java.lang.String temporaryFileSuffix)
Parameters:
temporaryFileSuffix - the temporaryFileSuffix to set

setFilter

public void setFilter(FileListFilter<F> filter)
Parameters:
filter - the filter to set

onInit

protected void onInit()
Description copied from class: IntegrationObjectSupport
Subclasses may implement this for initialization logic.

Overrides:
onInit in class AbstractReplyProducingMessageHandler

handleRequestMessage

protected java.lang.Object handleRequestMessage(Message<?> requestMessage)
Description copied from class: AbstractReplyProducingMessageHandler
Subclasses 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:
handleRequestMessage in class AbstractReplyProducingMessageHandler

ls

protected java.util.List<?> ls(Session<F> session,
                               java.lang.String dir)
                        throws java.io.IOException
Throws:
java.io.IOException

filterFiles

protected final java.util.List<F> filterFiles(F[] files)

purgeLinks

protected void purgeLinks(java.util.List<F> lsFiles)

purgeDots

protected void purgeDots(java.util.List<F> lsFiles)

get

protected java.io.File get(Session<F> session,
                           java.lang.String remoteFilePath,
                           java.lang.String remoteFilename,
                           boolean lsFirst)
                    throws java.io.IOException
Copy a remote file to the configured local directory.

Parameters:
session -
remoteFilePath -
Throws:
java.io.IOException

mGet

protected java.util.List<java.io.File> mGet(Session<F> session,
                                            java.lang.String remoteDirectory,
                                            java.lang.String remoteFilename)
                                     throws java.io.IOException
Throws:
java.io.IOException

getRemoteFilename

protected java.lang.String getRemoteFilename(java.lang.String remoteFilePath)
Parameters:
remoteFilePath -

rm

protected boolean rm(Session<?> session,
                     java.lang.String remoteFilePath)
              throws java.io.IOException
Throws:
java.io.IOException

isDirectory

protected abstract boolean isDirectory(F file)

isLink

protected abstract boolean isLink(F file)

getFilename

protected abstract java.lang.String getFilename(F file)

getModified

protected abstract long getModified(F file)

asFileInfoList

protected abstract java.util.List<AbstractFileInfo<F>> asFileInfoList(java.util.Collection<F> files)

Spring Integration