org.mule.transport.sftp
Class SftpConnector

java.lang.Object
  extended by org.mule.transport.AbstractConnector
      extended by org.mule.transport.sftp.SftpConnector
All Implemented Interfaces:
EventListener, javax.resource.spi.work.WorkListener, Disposable, Initialisable, Lifecycle, LifecycleStateEnabled, Startable, Stoppable, NameableObject, NamedObject, Connectable, Connector

public class SftpConnector
extends AbstractConnector

SftpConnector sends and receives file messages over sftp using jsch library Improves on SFTP with VFS Connector in the following ways: 1. Streams files instead of reading them into memory. The SftpMessageReceiver is a "non-materializing stream receiver" which does not read the file to memory. The SftpMessageDispatcher also never materializes the stream and delegates the jsch library for materialization. 3. Uses jsch library directly instead of using VFS as middle-man. 3. More explicit connection lifefecyle management. 4. Leverages sftp stat to determine if a file size changes (simpler and also less memory intensive)


Field Summary
static int DEFAULT_POLLING_FREQUENCY
           
protected static Log logger
          logger used by this class
static String PROPERTY_ARCHIVE_DIR
           
static String PROPERTY_ARCHIVE_TEMP_RECEIVING_DIR
           
static String PROPERTY_ARCHIVE_TEMP_SENDING_DIR
           
static String PROPERTY_DIRECTORY
           
static String PROPERTY_DUPLICATE_HANDLING
           
static String PROPERTY_DUPLICATE_HANDLING_ASS_SEQ_NO
           
static String PROPERTY_DUPLICATE_HANDLING_OVERWRITE
           
static String PROPERTY_DUPLICATE_HANDLING_THROW_EXCEPTION
           
static String PROPERTY_FILE_AGE
           
static String PROPERTY_FILE_EXTENSION
           
static String PROPERTY_FILENAME
           
static String PROPERTY_IDENTITY_FILE
           
static String PROPERTY_INCLUDE_SUBFOLDERS
           
static String PROPERTY_KEEP_FILE_ON_ERROR
           
static String PROPERTY_MAX_CONNECTION_POOL_SIZE
           
static String PROPERTY_ORIGINAL_FILENAME
           
static String PROPERTY_OUTPUT_PATTERN
           
static String PROPERTY_PASS_PHRASE
           
static String PROPERTY_POLLING_FREQUENCY
           
static String PROPERTY_SELECT_EXPRESSION
           
static String PROPERTY_SIZE_CHECK_WAIT_TIME
           
static String PROPERTY_TEMP_DIR
           
static String PROPERTY_USE_TEMP_FILE_TIMESTAMP_SUFFIX
           
 
Fields inherited from class org.mule.transport.AbstractConnector
createMultipleTransactedReceivers, DEFAULT_NUM_CONCURRENT_TX_RECEIVERS, dispatcherFactory, dispatcherPoolFactory, dispatchers, initialStateStopped, lifecycleManager, muleContext, muleMessageFactory, name, numberOfConcurrentTransactedReceivers, receivers, requesterFactory, requesters, serviceDescriptor, serviceOverrides, sessionHandler, startOnConnect
 
Fields inherited from interface org.mule.api.transport.Connector
INT_VALUE_NOT_SET
 
Fields inherited from interface org.mule.api.lifecycle.Disposable
PHASE_NAME
 
Constructor Summary
SftpConnector(MuleContext context)
           
 
Method Summary
 MessageReceiver createReceiver(FlowConstruct flow, InboundEndpoint endpoint)
          Create a Message receiver for this connector
 SftpClient createSftpClient(ImmutableEndpoint endpoint)
           
 SftpClient createSftpClient(ImmutableEndpoint endpoint, SftpNotifier notifier)
           
 void destroyClient(ImmutableEndpoint endpoint, SftpClient client)
           
protected  void doConnect()
          Template method where any connections should be made for the connector
protected  void doDisconnect()
          Template method where any connected resources used by the connector should be disconnected
protected  void doDispose()
          Template method to perform any work when destroying the connectoe
protected  void doInitialise()
           
protected  void doStart()
          Template method to perform any work when starting the connectoe
protected  void doStop()
          Template method to perform any work when stopping the connectoe
 String getArchiveDir()
           
 String getArchiveTempReceivingDir()
           
 String getArchiveTempSendingDir()
           
 boolean getCheckFileAge()
           
protected  ObjectPool getClientPool(ImmutableEndpoint endpoint)
           
 String getDuplicateHandling()
           
 long getFileAge()
          Returns the file age.
 FilenameParser getFilenameParser()
           
 String getIdentityFile()
           
 int getMaxConnectionPoolSize()
           
 String getOutputPattern()
           
 String getPassphrase()
           
 long getPollingFrequency()
           
 String getProtocol()
           
 Long getSizeCheckWaitTime()
           
 String getTempDirInbound()
           
 String getTempDirOutbound()
           
 boolean isAutoDelete()
           
 boolean isEnableMessageEvents()
           
 Boolean isKeepFileOnError()
           
 Boolean isUseTempFileTimestampSuffix()
           
 void releaseClient(ImmutableEndpoint endpoint, SftpClient client)
           
 void setArchiveDir(String archiveDir)
           
 void setArchiveTempReceivingDir(String archiveTempReceivingDir)
           
 void setArchiveTempSendingDir(String archiveTempSendingDir)
           
 void setAutoDelete(boolean autoDelete)
           
 void setDuplicateHandling(String duplicateHandling)
           
 void setFileAge(long fileAge)
          Sets the file age.
 void setFilenameParser(FilenameParser filenameParser)
           
 void setIdentityFile(String identityFile)
           
 void setKeepFileOnError(Boolean pKeepFileOnError)
           
 void setMaxConnectionPoolSize(int maxConnectionPoolSize)
           
 void setOutputPattern(String outputPattern)
           
 void setPassphrase(String passphrase)
           
 void setPollingFrequency(long pollingFrequency)
           
 void setSizeCheckWaitTime(Long sizeCheckWaitTime)
           
 void setTempDirInbound(String pTempDirInbound)
           
 void setTempDirOutbound(String pTempDirOutbound)
           
 void setUseTempFileTimestampSuffix(Boolean useTempFileTimestampSuffix)
           
 boolean useConnectionPool()
           
 
Methods inherited from class org.mule.transport.AbstractConnector
clearDispatchers, clearRequesters, configureDispatcherPool, connect, createDefaultRedeliveryPolicy, createDispatcherMessageProcessor, createMuleMessageFactory, createOperationResource, createScheduler, destroyReceiver, disconnect, dispose, disposeReceivers, disposeWorkManagers, doUnregisterListener, fireNotification, getConnectEventId, getConnectionDescription, getDefaultExchangePattern, getDefaultInboundTransformers, getDefaultOutboundTransformers, getDefaultResponseTransformers, getDispatcherFactory, getDispatcherPoolFactory, getDispatcherThreadingProfile, getDispatcherWorkManager, getInboundExchangePatterns, getLifecycleState, getMaxDispatchersActive, getMaxRequestersActive, getMaxTotalDispatchers, getMuleContext, getMuleMessageFactory, getName, getNumberOfConcurrentTransactedReceivers, getOperationResourceFactory, getOutboundExchangePatterns, getOutputStream, getReceiver, getReceiverKey, getReceivers, getReceivers, getReceiverThreadingProfile, getReceiverWorkManager, getReplyToHandler, getRequesterFactory, getRequesterThreadingProfile, getRequesterWorkManager, getRetryPolicyTemplate, getScheduler, getServiceDescriptor, getServiceOverrides, getSessionHandler, getSupportedProtocols, getTransactionalResource, handleWorkException, initFromServiceDescriptor, initialise, initialiseFromUrl, initWorkManagers, isConnected, isConnecting, isCreateMultipleTransactedReceivers, isDisposed, isInitialised, isInitialStateStopped, isResponseEnabled, isStarted, isStarting, isStopped, isStopping, isValidateConnections, lookupReceiver, registerListener, registerSupportedMetaProtocol, registerSupportedProtocol, registerSupportedProtocolWithoutPrefix, request, request, setConnected, setConnecting, setCreateMultipleTransactedReceivers, setDispatcherFactory, setDispatcherPoolFactory, setDispatcherPoolMaxWait, setDispatcherPoolWhenExhaustedAction, setDispatcherThreadingProfile, setDynamicNotification, setInitialStateStopped, setMaxDispatchersActive, setMaxRequestersActive, setName, setNumberOfConcurrentTransactedReceivers, setReceiverThreadingProfile, setRequesterFactory, setRequesterPoolMaxWait, setRequesterPoolWhenExhaustedAction, setRequesterThreadingProfile, setRetryPolicyTemplate, setServiceOverrides, setSessionHandler, setSupportedProtocols, setupDispatchReturn, setupRequestReturn, setValidateConnections, shutdownScheduler, start, startAfterConnect, stop, supportsProtocol, toString, unregisterListener, unregisterSupportedProtocol, updateCachedNotificationHandler, validateConnection, workAccepted, workCompleted, workRejected, workStarted
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PROPERTY_POLLING_FREQUENCY

public static final String PROPERTY_POLLING_FREQUENCY
See Also:
Constant Field Values

PROPERTY_DIRECTORY

public static final String PROPERTY_DIRECTORY
See Also:
Constant Field Values

PROPERTY_OUTPUT_PATTERN

public static final String PROPERTY_OUTPUT_PATTERN
See Also:
Constant Field Values

PROPERTY_FILENAME

public static final String PROPERTY_FILENAME
See Also:
Constant Field Values

PROPERTY_ORIGINAL_FILENAME

public static final String PROPERTY_ORIGINAL_FILENAME
See Also:
Constant Field Values

PROPERTY_SELECT_EXPRESSION

public static final String PROPERTY_SELECT_EXPRESSION
See Also:
Constant Field Values

PROPERTY_FILE_EXTENSION

public static final String PROPERTY_FILE_EXTENSION
See Also:
Constant Field Values

PROPERTY_INCLUDE_SUBFOLDERS

public static final String PROPERTY_INCLUDE_SUBFOLDERS
See Also:
Constant Field Values

PROPERTY_IDENTITY_FILE

public static final String PROPERTY_IDENTITY_FILE
See Also:
Constant Field Values

PROPERTY_PASS_PHRASE

public static final String PROPERTY_PASS_PHRASE
See Also:
Constant Field Values

PROPERTY_FILE_AGE

public static final String PROPERTY_FILE_AGE
See Also:
Constant Field Values

PROPERTY_TEMP_DIR

public static final String PROPERTY_TEMP_DIR
See Also:
Constant Field Values

PROPERTY_SIZE_CHECK_WAIT_TIME

public static final String PROPERTY_SIZE_CHECK_WAIT_TIME
See Also:
Constant Field Values

PROPERTY_ARCHIVE_DIR

public static final String PROPERTY_ARCHIVE_DIR
See Also:
Constant Field Values

PROPERTY_ARCHIVE_TEMP_RECEIVING_DIR

public static final String PROPERTY_ARCHIVE_TEMP_RECEIVING_DIR
See Also:
Constant Field Values

PROPERTY_ARCHIVE_TEMP_SENDING_DIR

public static final String PROPERTY_ARCHIVE_TEMP_SENDING_DIR
See Also:
Constant Field Values

PROPERTY_DUPLICATE_HANDLING

public static final String PROPERTY_DUPLICATE_HANDLING
See Also:
Constant Field Values

PROPERTY_USE_TEMP_FILE_TIMESTAMP_SUFFIX

public static final String PROPERTY_USE_TEMP_FILE_TIMESTAMP_SUFFIX
See Also:
Constant Field Values

PROPERTY_DUPLICATE_HANDLING_THROW_EXCEPTION

public static final String PROPERTY_DUPLICATE_HANDLING_THROW_EXCEPTION
See Also:
Constant Field Values

PROPERTY_DUPLICATE_HANDLING_OVERWRITE

public static final String PROPERTY_DUPLICATE_HANDLING_OVERWRITE
See Also:
Constant Field Values

PROPERTY_DUPLICATE_HANDLING_ASS_SEQ_NO

public static final String PROPERTY_DUPLICATE_HANDLING_ASS_SEQ_NO
See Also:
Constant Field Values

PROPERTY_MAX_CONNECTION_POOL_SIZE

public static final String PROPERTY_MAX_CONNECTION_POOL_SIZE
See Also:
Constant Field Values

PROPERTY_KEEP_FILE_ON_ERROR

public static final String PROPERTY_KEEP_FILE_ON_ERROR
See Also:
Constant Field Values

DEFAULT_POLLING_FREQUENCY

public static final int DEFAULT_POLLING_FREQUENCY
See Also:
Constant Field Values

logger

protected static final Log logger
logger used by this class

Constructor Detail

SftpConnector

public SftpConnector(MuleContext context)
Method Detail

getProtocol

public String getProtocol()
Returns:
the primary protocol name for endpoints of this connector

createReceiver

public MessageReceiver createReceiver(FlowConstruct flow,
                                      InboundEndpoint endpoint)
                               throws Exception
Description copied from class: AbstractConnector
Create a Message receiver for this connector

Overrides:
createReceiver in class AbstractConnector
Parameters:
flow - the service that will receive events from this receiver, the listener
endpoint - the endpoint that defies this inbound communication
Returns:
an instance of the message receiver defined in this connectors' TransportServiceDescriptor initialised using the service and endpoint.
Throws:
Exception - if there is a problem creating the receiver. This exception really depends on the underlying transport, thus any exception could be thrown

createSftpClient

public SftpClient createSftpClient(ImmutableEndpoint endpoint)
                            throws Exception
Throws:
Exception

createSftpClient

public SftpClient createSftpClient(ImmutableEndpoint endpoint,
                                   SftpNotifier notifier)
                            throws Exception
Throws:
Exception

useConnectionPool

public boolean useConnectionPool()
Returns:
True if connection pooling is used, otherwise false

releaseClient

public void releaseClient(ImmutableEndpoint endpoint,
                          SftpClient client)
                   throws Exception
Throws:
Exception

destroyClient

public void destroyClient(ImmutableEndpoint endpoint,
                          SftpClient client)
                   throws Exception
Throws:
Exception

getClientPool

protected ObjectPool getClientPool(ImmutableEndpoint endpoint)

doConnect

protected void doConnect()
                  throws Exception
Description copied from class: AbstractConnector
Template method where any connections should be made for the connector

Specified by:
doConnect in class AbstractConnector
Throws:
Exception

doDisconnect

protected void doDisconnect()
                     throws Exception
Description copied from class: AbstractConnector
Template method where any connected resources used by the connector should be disconnected

Specified by:
doDisconnect in class AbstractConnector
Throws:
Exception

doDispose

protected void doDispose()
Description copied from class: AbstractConnector
Template method to perform any work when destroying the connectoe

Specified by:
doDispose in class AbstractConnector

doInitialise

protected void doInitialise()
                     throws InitialisationException
Specified by:
doInitialise in class AbstractConnector
Throws:
InitialisationException

doStart

protected void doStart()
                throws MuleException
Description copied from class: AbstractConnector
Template method to perform any work when starting the connectoe

Specified by:
doStart in class AbstractConnector
Throws:
MuleException - if the method fails

doStop

protected void doStop()
               throws MuleException
Description copied from class: AbstractConnector
Template method to perform any work when stopping the connectoe

Specified by:
doStop in class AbstractConnector
Throws:
MuleException - if the method fails

getPollingFrequency

public long getPollingFrequency()

setPollingFrequency

public void setPollingFrequency(long pollingFrequency)

getFilenameParser

public FilenameParser getFilenameParser()

setFilenameParser

public void setFilenameParser(FilenameParser filenameParser)

getOutputPattern

public String getOutputPattern()

setOutputPattern

public void setOutputPattern(String outputPattern)

isAutoDelete

public boolean isAutoDelete()

setAutoDelete

public void setAutoDelete(boolean autoDelete)

getIdentityFile

public String getIdentityFile()

setIdentityFile

public void setIdentityFile(String identityFile)

getPassphrase

public String getPassphrase()

setPassphrase

public void setPassphrase(String passphrase)

getFileAge

public long getFileAge()
Returns the file age.

Returns:
Returns the fileAge in milliseconds.

setFileAge

public void setFileAge(long fileAge)
Sets the file age.

Parameters:
fileAge - the fileAge in milliseconds to set.

getCheckFileAge

public boolean getCheckFileAge()

getTempDirInbound

public String getTempDirInbound()

setTempDirInbound

public void setTempDirInbound(String pTempDirInbound)

getTempDirOutbound

public String getTempDirOutbound()

setTempDirOutbound

public void setTempDirOutbound(String pTempDirOutbound)

isEnableMessageEvents

public boolean isEnableMessageEvents()
Overrides:
isEnableMessageEvents in class AbstractConnector

setDuplicateHandling

public void setDuplicateHandling(String duplicateHandling)

getDuplicateHandling

public String getDuplicateHandling()

setUseTempFileTimestampSuffix

public void setUseTempFileTimestampSuffix(Boolean useTempFileTimestampSuffix)

isUseTempFileTimestampSuffix

public Boolean isUseTempFileTimestampSuffix()

setSizeCheckWaitTime

public void setSizeCheckWaitTime(Long sizeCheckWaitTime)

getSizeCheckWaitTime

public Long getSizeCheckWaitTime()

setArchiveDir

public void setArchiveDir(String archiveDir)

getArchiveDir

public String getArchiveDir()

setArchiveTempReceivingDir

public void setArchiveTempReceivingDir(String archiveTempReceivingDir)

getArchiveTempReceivingDir

public String getArchiveTempReceivingDir()

setArchiveTempSendingDir

public void setArchiveTempSendingDir(String archiveTempSendingDir)

getArchiveTempSendingDir

public String getArchiveTempSendingDir()

setMaxConnectionPoolSize

public void setMaxConnectionPoolSize(int maxConnectionPoolSize)
See Also:
maxConnectionPoolSize

getMaxConnectionPoolSize

public int getMaxConnectionPoolSize()
Returns:
the max connection pool size. If the system parameter mule.sftp.transport.maxConnectionPoolSize is set, that value will be used instead.

isKeepFileOnError

public Boolean isKeepFileOnError()

setKeepFileOnError

public void setKeepFileOnError(Boolean pKeepFileOnError)


Copyright © 2003-2012 MuleSoft, Inc.. All Rights Reserved.