org.apache.servicemix.ftp
Class FtpPollerEndpoint

java.lang.Object
  extended by org.apache.servicemix.common.endpoints.AbstractEndpoint
      extended by org.apache.servicemix.common.endpoints.SimpleEndpoint
          extended by org.apache.servicemix.common.endpoints.ConsumerEndpoint
              extended by org.apache.servicemix.common.endpoints.PollingEndpoint
                  extended by org.apache.servicemix.ftp.FtpPollerEndpoint
All Implemented Interfaces:
Endpoint, FtpEndpointType

public class FtpPollerEndpoint
extends PollingEndpoint
implements FtpEndpointType

A polling endpoint which looks for a file or files in a directory and sends the files into the JBI bus as messages, deleting the files by default when they are processed.

Version:
$Revision: 468487 $

Nested Class Summary
protected  class FtpPollerEndpoint.FtpData
           
 
Field Summary
 
Fields inherited from class org.apache.servicemix.common.endpoints.SimpleEndpoint
logger
 
Fields inherited from class org.apache.servicemix.common.endpoints.AbstractEndpoint
definition, description, endpoint, interfaceName, service, serviceUnit
 
Constructor Summary
FtpPollerEndpoint()
           
FtpPollerEndpoint(DefaultComponent component, javax.jbi.servicedesc.ServiceEndpoint endpoint)
          Bean defining the class implementing the JBI DefaultComponent.
FtpPollerEndpoint(ServiceUnit serviceUnit, javax.xml.namespace.QName service, java.lang.String endpoint)
           
 
Method Summary
 void activate()
           
protected  org.apache.commons.net.ftp.FTPClient borrowClient()
           
protected  FTPClientPool createClientPool()
           
protected  LockManager createLockManager()
           
 java.net.URI getArchive()
           
 FTPClientPool getClientPool()
           
 java.io.FileFilter getFilter()
           
 java.lang.String getLocationURI()
           
 LockManager getLockManager()
           
 org.apache.servicemix.components.util.FileMarshaler getMarshaler()
           
 javax.xml.namespace.QName getTargetOperation()
           
 java.net.URI getUri()
           
 boolean isAutoCreateDirectory()
           
 boolean isDeleteFile()
           
 boolean isRecursive()
           
 boolean isStateless()
           
 void poll()
           
protected  void pollFile(java.lang.String file)
           
protected  void pollFileOrDirectory(org.apache.commons.net.ftp.FTPClient ftp, java.lang.String fileOrDirectory, boolean processDir)
           
protected  void pollFileOrDirectory(java.lang.String fileOrDirectory)
           
 void process(javax.jbi.messaging.MessageExchange exchange)
           
protected  void processFile(org.apache.commons.net.ftp.FTPClient ftp, java.lang.String file)
           
protected  void processFileNow(java.lang.String file)
           
protected  void returnClient(org.apache.commons.net.ftp.FTPClient client)
           
 void setArchive(java.net.URI archive)
          Specifies a directory relative to the polling directory to which processed files are archived.
 void setAutoCreateDirectory(boolean autoCreateDirectory)
          Specifies if the endpoint should create the target directory, if it does not already exist.
 void setChangeWorkingDirectory(boolean changeWorkingDirectory)
          When set to true, the poller will do an explicit cwd into the directory to be polled.
 void setClientPool(FTPClientPool clientPool)
          Set a custom FTPClientPool.
 void setDeleteFile(boolean deleteFile)
          Delete the file after it has been succesfully processed? Defaults to true
 void setFilter(java.io.FileFilter filter)
          Sets the filter to select which files have to be processed.
 void setLockManager(LockManager lockManager)
          Set a custom LockManager implementation for keeping track of which files are already being processed.
 void setMarshaler(org.apache.servicemix.components.util.FileMarshaler marshaler)
          Set a custom FileMarshaler implementation to control how the file contents is being translated into a JBI message.
 void setRecursive(boolean recursive)
          Specifies whether subdirectories should be polled.
 void setStateless(boolean stateless)
          When set to false
 void setTargetOperation(javax.xml.namespace.QName targetOperation)
          Set the operation to be invoked on the target service.
 void setUri(java.net.URI uri)
          Configures the endpoint from a URI.
 void start()
           
 void validate()
           
 
Methods inherited from class org.apache.servicemix.common.endpoints.PollingEndpoint
getDelay, getExecutor, getFirstTime, getPeriod, getScheduler, handlePollException, isConcurrentPolling, setConcurrentPolling, setDelay, setFirstTime, setPeriod, setScheduler, stop
 
Methods inherited from class org.apache.servicemix.common.endpoints.ConsumerEndpoint
configureExchangeTarget, deactivate, getRole, getTargetEndpoint, getTargetInterface, getTargetService, getTargetUri, setTargetEndpoint, setTargetInterface, setTargetService, setTargetUri
 
Methods inherited from class org.apache.servicemix.common.endpoints.SimpleEndpoint
done, fail, getChannel, getContext, getExchangeFactory, send, sendSync
 
Methods inherited from class org.apache.servicemix.common.endpoints.AbstractEndpoint
getDefinition, getDescription, getEndpoint, getInterfaceName, getKey, getService, getServiceUnit, isExchangeOkay, prepareExchange, setDefinition, setDescription, setEndpoint, setInterfaceName, setService, setServiceUnit, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FtpPollerEndpoint

public FtpPollerEndpoint()

FtpPollerEndpoint

public FtpPollerEndpoint(ServiceUnit serviceUnit,
                         javax.xml.namespace.QName service,
                         java.lang.String endpoint)

FtpPollerEndpoint

public FtpPollerEndpoint(DefaultComponent component,
                         javax.jbi.servicedesc.ServiceEndpoint endpoint)
Bean defining the class implementing the JBI DefaultComponent. This bean must be an implementation of the org.apache.servicemix.common.DefaultComponent class.

Parameters:
component - the component implementation to use
Method Detail

poll

public void poll()
          throws java.lang.Exception
Specified by:
poll in class PollingEndpoint
Throws:
java.lang.Exception

validate

public void validate()
              throws javax.jbi.management.DeploymentException
Specified by:
validate in interface Endpoint
Overrides:
validate in class ConsumerEndpoint
Throws:
javax.jbi.management.DeploymentException

activate

public void activate()
              throws java.lang.Exception
Specified by:
activate in interface Endpoint
Overrides:
activate in class ConsumerEndpoint
Throws:
java.lang.Exception

start

public void start()
           throws java.lang.Exception
Specified by:
start in interface Endpoint
Overrides:
start in class PollingEndpoint
Throws:
java.lang.Exception

createLockManager

protected LockManager createLockManager()

getClientPool

public FTPClientPool getClientPool()
Returns:
the clientPool

setClientPool

public void setClientPool(FTPClientPool clientPool)
Set a custom FTPClientPool. If this property has not been set, the FTP client pool will be created based on the information provided in the URI.

Parameters:
clientPool - the clientPool implementation to use

getUri

public java.net.URI getUri()
Returns:
the uri

setUri

public void setUri(java.net.URI uri)
Configures the endpoint from a URI.


getFilter

public java.io.FileFilter getFilter()

setFilter

public void setFilter(java.io.FileFilter filter)
Sets the filter to select which files have to be processed. When not set, all files will be picked up by the poller.


isDeleteFile

public boolean isDeleteFile()

setDeleteFile

public void setDeleteFile(boolean deleteFile)
Delete the file after it has been succesfully processed? Defaults to true

Parameters:
deleteFile -

isRecursive

public boolean isRecursive()

setRecursive

public void setRecursive(boolean recursive)
Specifies whether subdirectories should be polled. Defaults to true

Parameters:
recursive - is a boolean specifying whether subdirectories should be polled. Default value is true. .

getMarshaler

public org.apache.servicemix.components.util.FileMarshaler getMarshaler()

setMarshaler

public void setMarshaler(org.apache.servicemix.components.util.FileMarshaler marshaler)
Set a custom FileMarshaler implementation to control how the file contents is being translated into a JBI message. The default implementation reads XML contents from the file.

Parameters:
marshaler - the marshaler implementation to use

getTargetOperation

public javax.xml.namespace.QName getTargetOperation()
Overrides:
getTargetOperation in class ConsumerEndpoint

setTargetOperation

public void setTargetOperation(javax.xml.namespace.QName targetOperation)
Set the operation to be invoked on the target service.

Overrides:
setTargetOperation in class ConsumerEndpoint
Parameters:
targetOperation - a QName specifiying the name of the target operation

setChangeWorkingDirectory

public void setChangeWorkingDirectory(boolean changeWorkingDirectory)
When set to true, the poller will do an explicit cwd into the directory to be polled. Default to false. Recursive polling will not be possible if this feature is enabled.

Parameters:
changeWorkingDirectory - is a boolean specifying if the endpoint can change the working directory .

isStateless

public boolean isStateless()

setStateless

public void setStateless(boolean stateless)
When set to false

Parameters:
stateless - is a boolean specifying whether the polled file should be sent asynchronous or synchronous to the nmr. Default value is true. .

setAutoCreateDirectory

public void setAutoCreateDirectory(boolean autoCreateDirectory)
Specifies if the endpoint should create the target directory, if it does not already exist. If you set this to false and the directory does not exist, the endpoint will not do anything. Default value is true.

Parameters:
autoCreateDirectory - a boolean specifying if the endpoint creates directories.

isAutoCreateDirectory

public boolean isAutoCreateDirectory()

setArchive

public void setArchive(java.net.URI archive)
Specifies a directory relative to the polling directory to which processed files are archived.

Parameters:
archive - a URI object for the archive directory

getArchive

public java.net.URI getArchive()

setLockManager

public void setLockManager(LockManager lockManager)
Set a custom LockManager implementation for keeping track of which files are already being processed. The default implementation is a simple, in-memory lock management system.

Parameters:
lockManager - the LockManager implementation to use

getLockManager

public LockManager getLockManager()

pollFileOrDirectory

protected void pollFileOrDirectory(java.lang.String fileOrDirectory)
                            throws java.lang.Exception
Throws:
java.lang.Exception

pollFileOrDirectory

protected void pollFileOrDirectory(org.apache.commons.net.ftp.FTPClient ftp,
                                   java.lang.String fileOrDirectory,
                                   boolean processDir)
                            throws java.lang.Exception
Throws:
java.lang.Exception

pollFile

protected void pollFile(java.lang.String file)

processFileNow

protected void processFileNow(java.lang.String file)

processFile

protected void processFile(org.apache.commons.net.ftp.FTPClient ftp,
                           java.lang.String file)
                    throws java.lang.Exception
Throws:
java.lang.Exception

getLocationURI

public java.lang.String getLocationURI()
Overrides:
getLocationURI in class ConsumerEndpoint

process

public void process(javax.jbi.messaging.MessageExchange exchange)
             throws java.lang.Exception
Specified by:
process in interface Endpoint
Specified by:
process in class AbstractEndpoint
Throws:
java.lang.Exception

createClientPool

protected FTPClientPool createClientPool()
                                  throws java.lang.Exception
Throws:
java.lang.Exception

borrowClient

protected org.apache.commons.net.ftp.FTPClient borrowClient()
                                                     throws javax.jbi.JBIException
Throws:
javax.jbi.JBIException

returnClient

protected void returnClient(org.apache.commons.net.ftp.FTPClient client)


Copyright © 2005-2011 FuseSource. All Rights Reserved.