org.mule.transport.ftp
Class FtpConnector

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

public class FtpConnector
extends AbstractConnector


Field Summary
static String DEFAULT_FTP_CONNECTION_FACTORY_CLASS
          TODO it makes sense to have a type-safe adapter for FTP specifically, but without Java 5's covariant return types the benefits are diminished.
static int DEFAULT_POLLING_FREQUENCY
           
static String FTP
           
static String PROPERTY_BINARY_TRANSFER
           
static String PROPERTY_FILENAME
           
static String PROPERTY_OUTPUT_PATTERN
           
static String PROPERTY_PASSIVE_MODE
           
 
Fields inherited from class org.mule.transport.AbstractConnector
createMultipleTransactedReceivers, DEFAULT_NUM_CONCURRENT_TX_RECEIVERS, dispatcherFactory, dispatcherPoolFactory, dispatchers, initialStateStopped, lifecycleManager, logger, muleContext, muleMessageFactory, name, numberOfConcurrentTransactedReceivers, PROPERTY_POLLING_FREQUENCY, 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
FtpConnector(MuleContext context)
           
 
Method Summary
protected  org.apache.commons.net.ftp.FTPClient createFtpClient(ImmutableEndpoint endpoint)
          Creates a new FTPClient that logs in and changes the working directory using the data provided in endpoint.
protected  GenericObjectPool createPool(FtpConnectionFactory connectionFactory)
           
 MessageReceiver createReceiver(FlowConstruct flowConstruct, InboundEndpoint endpoint)
          Create a Message receiver for this connector
 void destroyFtp(EndpointURI uri, org.apache.commons.net.ftp.FTPClient 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
 void enterActiveOrPassiveMode(org.apache.commons.net.ftp.FTPClient client, ImmutableEndpoint endpoint)
          Passive mode is OFF by default.
 String getConnectionFactoryClass()
          Getter for property 'connectionFactoryClass'.
 FilenameParser getFilenameParser()
           
 org.apache.commons.net.ftp.FTPClient getFtp(EndpointURI uri)
           
protected  ObjectPool getFtpPool(EndpointURI uri)
           
 String getOutputPattern()
           
 OutputStream getOutputStream(OutboundEndpoint endpoint, MuleEvent event)
          Well get the output stream (if any) for this type of transport.
 long getPollingFrequency()
           
 String getProtocol()
           
protected  List<?> getReceiverArguments(Map endpointProperties)
           
 boolean isBinary()
          Getter for FTP transfer type.
 boolean isPassive()
          Getter for FTP passive mode.
 boolean isStreaming()
           
 void releaseFtp(EndpointURI uri, org.apache.commons.net.ftp.FTPClient client)
           
 void setBinary(boolean binary)
          Setter for FTP transfer type.
 void setConnectionFactoryClass(String connectionFactoryClass)
          Setter for property 'connectionFactoryClass'.
 void setFilenameParser(FilenameParser filenameParser)
           
 void setOutputPattern(String outputPattern)
           
 void setPassive(boolean passive)
          Setter for FTP passive mode.
 void setPollingFrequency(long pollingFrequency)
           
 void setStreaming(boolean streaming)
           
 void setupFileType(org.apache.commons.net.ftp.FTPClient client, ImmutableEndpoint endpoint)
          Transfer type is BINARY by default.
protected  boolean validateFile(org.apache.commons.net.ftp.FTPFile file)
          Override this method to do extra checking on the file.
 
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, 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, isEnableMessageEvents, 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

FTP

public static final String FTP
See Also:
Constant Field Values

DEFAULT_POLLING_FREQUENCY

public static final int DEFAULT_POLLING_FREQUENCY
See Also:
Constant Field Values

PROPERTY_OUTPUT_PATTERN

public static final String PROPERTY_OUTPUT_PATTERN
See Also:
Constant Field Values

PROPERTY_PASSIVE_MODE

public static final String PROPERTY_PASSIVE_MODE
See Also:
Constant Field Values

PROPERTY_BINARY_TRANSFER

public static final String PROPERTY_BINARY_TRANSFER
See Also:
Constant Field Values

PROPERTY_FILENAME

public static final String PROPERTY_FILENAME
See Also:
Constant Field Values

DEFAULT_FTP_CONNECTION_FACTORY_CLASS

public static final String DEFAULT_FTP_CONNECTION_FACTORY_CLASS
TODO it makes sense to have a type-safe adapter for FTP specifically, but without Java 5's covariant return types the benefits are diminished. Keeping it simple for now.

See Also:
Constant Field Values
Constructor Detail

FtpConnector

public FtpConnector(MuleContext context)
Method Detail

getProtocol

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

createReceiver

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

Overrides:
createReceiver in class AbstractConnector
Parameters:
flowConstruct - 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

getReceiverArguments

protected List<?> getReceiverArguments(Map endpointProperties)

getPollingFrequency

public long getPollingFrequency()
Returns:
Returns the pollingFrequency.

setPollingFrequency

public void setPollingFrequency(long pollingFrequency)
Parameters:
pollingFrequency - The pollingFrequency to set.

getConnectionFactoryClass

public String getConnectionFactoryClass()
Getter for property 'connectionFactoryClass'.

Returns:
Value for property 'connectionFactoryClass'.

setConnectionFactoryClass

public void setConnectionFactoryClass(String connectionFactoryClass)
Setter for property 'connectionFactoryClass'. Should be an instance of FtpConnectionFactory.

Parameters:
connectionFactoryClass - Value to set for property 'connectionFactoryClass'.

getFtp

public org.apache.commons.net.ftp.FTPClient getFtp(EndpointURI uri)
                                            throws Exception
Throws:
Exception

releaseFtp

public void releaseFtp(EndpointURI uri,
                       org.apache.commons.net.ftp.FTPClient client)
                throws Exception
Throws:
Exception

destroyFtp

public void destroyFtp(EndpointURI uri,
                       org.apache.commons.net.ftp.FTPClient client)
                throws Exception
Throws:
Exception

getFtpPool

protected ObjectPool getFtpPool(EndpointURI uri)

createPool

protected GenericObjectPool createPool(FtpConnectionFactory connectionFactory)

doInitialise

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

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

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

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

getOutputPattern

public String getOutputPattern()
Returns:
Returns the outputPattern.

setOutputPattern

public void setOutputPattern(String outputPattern)
Parameters:
outputPattern - The outputPattern to set.

getFilenameParser

public FilenameParser getFilenameParser()
Returns:
Returns the filenameParser.

setFilenameParser

public void setFilenameParser(FilenameParser filenameParser)
Parameters:
filenameParser - The filenameParser to set.

isPassive

public boolean isPassive()
Getter for FTP passive mode.

Returns:
true if using FTP passive mode

setPassive

public void setPassive(boolean passive)
Setter for FTP passive mode.

Parameters:
passive - passive mode flag

enterActiveOrPassiveMode

public void enterActiveOrPassiveMode(org.apache.commons.net.ftp.FTPClient client,
                                     ImmutableEndpoint endpoint)
Passive mode is OFF by default. The value is taken from the connector settings. In case there are any overriding properties set on the endpoint, those will be used.

See Also:
setPassive(boolean)

isBinary

public boolean isBinary()
Getter for FTP transfer type.

Returns:
true if using FTP binary type

setBinary

public void setBinary(boolean binary)
Setter for FTP transfer type.

Parameters:
binary - binary type flag

setupFileType

public void setupFileType(org.apache.commons.net.ftp.FTPClient client,
                          ImmutableEndpoint endpoint)
                   throws Exception
Transfer type is BINARY by default. The value is taken from the connector settings. In case there are any overriding properties set on the endpoint, those will be used.

The alternative type is ASCII.

Throws:
Exception
See Also:
setBinary(boolean)

getOutputStream

public OutputStream getOutputStream(OutboundEndpoint endpoint,
                                    MuleEvent event)
                             throws MuleException
Well get the output stream (if any) for this type of transport. Typically this will be called only when Streaming is being used on an outbound endpoint

Specified by:
getOutputStream in interface Connector
Overrides:
getOutputStream in class AbstractConnector
Parameters:
endpoint - the endpoint that releates to this Dispatcher
event - the current event being processed
Returns:
the output stream to use for this request or null if the transport does not support streaming
Throws:
MuleException - in case of any error

createFtpClient

protected org.apache.commons.net.ftp.FTPClient createFtpClient(ImmutableEndpoint endpoint)
                                                        throws Exception
Creates a new FTPClient that logs in and changes the working directory using the data provided in endpoint.

Throws:
Exception

validateFile

protected boolean validateFile(org.apache.commons.net.ftp.FTPFile file)
Override this method to do extra checking on the file.


isStreaming

public boolean isStreaming()

setStreaming

public void setStreaming(boolean streaming)


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