org.apache.servicemix.vfs
Class VFSPollingEndpoint

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.vfs.VFSPollingEndpoint
All Implemented Interfaces:
Endpoint, VFSEndpointType

public class VFSPollingEndpoint
extends PollingEndpoint
implements VFSEndpointType

A polling endpoint that looks for a file or files in a virtual file system and sends the files to a target service (via the JBI bus), deleting the files by default when they are processed. The polling endpoint uses a file marshaler to send the data as a JBI message; by default this marshaler expects XML payload. For non-XML payload, e.g. plain-text or binary files, use an alternative marshaler such as the org.apache.servicemix.components.util.BinaryFileMarshaler

Author:
lhein

Field Summary
 
Fields inherited from class org.apache.servicemix.common.endpoints.AbstractEndpoint
definition, description, endpoint, interfaceName, service, serviceUnit
 
Constructor Summary
VFSPollingEndpoint()
          default constructor
VFSPollingEndpoint(DefaultComponent component, javax.jbi.servicedesc.ServiceEndpoint endpoint)
          creates a VFS polling endpoint
VFSPollingEndpoint(ServiceUnit serviceUnit, javax.xml.namespace.QName service, java.lang.String endpoint)
          creates a VFS polling endpoint
 
Method Summary
protected  LockManager createLockManager()
          returns the lock manager
 java.util.Comparator<org.apache.commons.vfs.FileObject> getComparator()
           
 org.apache.commons.vfs.FileSystemManager getFileSystemManager()
           
 java.lang.String getLocationURI()
           
 LockManager getLockManager()
           
 org.apache.servicemix.components.util.FileMarshaler getMarshaler()
           
 java.lang.String getPath()
           
 org.apache.commons.vfs.FileSelector getSelector()
           
 java.util.Set<org.apache.commons.vfs.FileObject> getWorkingSet()
          The set of FTPFiles that this component is currently working on
 boolean isConcurrentExchange()
           
 boolean isDeleteFile()
           
 boolean isRecursive()
           
 void poll()
           
protected  void pollFile(org.apache.commons.vfs.FileObject aFile)
          polls a file object
protected  void pollFileOrDirectory(org.apache.commons.vfs.FileObject fileOrDirectory)
          polls a file which is not clear to be a file or folder
protected  void pollFileOrDirectory(org.apache.commons.vfs.FileObject fileOrDirectory, boolean processDir)
          recursive method for processing a file or a folder
 void process(javax.jbi.messaging.MessageExchange exchange)
           
protected  void processFile(org.apache.commons.vfs.FileObject file)
          does the real processing logic
protected  void processFileNow(org.apache.commons.vfs.FileObject aFile)
          processes a file
 void setComparator(java.util.Comparator<org.apache.commons.vfs.FileObject> comparator)
          Specifies a Comparator object.
 void setConcurrentExchange(boolean concurrentExchange)
           
 void setDeleteFile(boolean deleteFile)
          Specifies if files should be deleted after they are processed.
 void setFileSystemManager(org.apache.commons.vfs.FileSystemManager fileSystemManager)
          sets the file system manager
 void setLockManager(LockManager lockManager)
          Bean defining the class implementing the file locking strategy.
 void setMarshaler(org.apache.servicemix.components.util.FileMarshaler marshaler)
          Specifies a FileMarshaler object that will marshal file data into the NMR.
 void setPath(java.lang.String path)
          Specifies a String object representing the path of the file/folder to be polled.

Examples:
file:///home/lhein/pollFolder zip:file:///home/lhein/pollFolder/myFile.zip jar:http://www.myhost.com/files/Examples.jar jar:../lib/classes.jar!/META-INF/manifest.mf tar:gz:http://anyhost/dir/mytar.tar.gz!/mytar.tar!/path/in/tar/README.txt tgz:file://anyhost/dir/mytar.tgz!/somepath/somefile gz:/my/gz/file.gz http://myusername@somehost/index.html webdav://somehost:8080/dist ftp://myusername:mypassword@somehost/pub/downloads/somefile.tgz sftp://myusername:mypassword@somehost/pub/downloads/somefile.tgz smb://somehost/home tmp://dir/somefile.txt res:path/in/classpath/image.png ram:///any/path/to/file.txt mime:file:///your/path/mail/anymail.mime!/filename.pdf For further details have a look at http://commons.apache.org/vfs/filesystems.html.
 void setRecursive(boolean recursive)
           
 void setSelector(org.apache.commons.vfs.FileSelector selector)
          Specifies a FileSelector object.
 void start()
           
 
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
activate, configureExchangeTarget, deactivate, getRole, getTargetEndpoint, getTargetInterface, getTargetOperation, getTargetService, getTargetUri, setTargetEndpoint, setTargetInterface, setTargetOperation, setTargetService, setTargetUri, validate
 
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

VFSPollingEndpoint

public VFSPollingEndpoint()
default constructor


VFSPollingEndpoint

public VFSPollingEndpoint(ServiceUnit serviceUnit,
                          javax.xml.namespace.QName service,
                          java.lang.String endpoint)
creates a VFS polling endpoint

Parameters:
serviceUnit - the service unit
service - the service name
endpoint - the endpoint name

VFSPollingEndpoint

public VFSPollingEndpoint(DefaultComponent component,
                          javax.jbi.servicedesc.ServiceEndpoint endpoint)
creates a VFS polling endpoint

Parameters:
component - the default component
endpoint - the endpoint
Method Detail

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()
returns the lock manager

Returns:
the lock manager

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

poll

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

pollFileOrDirectory

protected void pollFileOrDirectory(org.apache.commons.vfs.FileObject fileOrDirectory)
                            throws java.lang.Exception
polls a file which is not clear to be a file or folder

Parameters:
fileOrDirectory - the file or folder object
Throws:
java.lang.Exception - on IO errors

pollFileOrDirectory

protected void pollFileOrDirectory(org.apache.commons.vfs.FileObject fileOrDirectory,
                                   boolean processDir)
                            throws java.lang.Exception
recursive method for processing a file or a folder

Parameters:
fileOrDirectory - the file or folder object
processDir - flag if processing should act recursive
Throws:
java.lang.Exception - on IO errors

pollFile

protected void pollFile(org.apache.commons.vfs.FileObject aFile)
                 throws java.lang.Exception
polls a file object

Parameters:
aFile - the file object
Throws:
java.lang.Exception - on IO errors

processFileNow

protected void processFileNow(org.apache.commons.vfs.FileObject aFile)
processes a file

Parameters:
aFile - the file to process

processFile

protected void processFile(org.apache.commons.vfs.FileObject file)
                    throws java.lang.Exception
does the real processing logic

Parameters:
file - the file to process
Throws:
java.lang.Exception - on processing errors

setDeleteFile

public void setDeleteFile(boolean deleteFile)
Specifies if files should be deleted after they are processed. Default value is true.

Parameters:
deleteFile - a boolean specifying if the file should be deleted

isDeleteFile

public boolean isDeleteFile()

setLockManager

public void setLockManager(LockManager lockManager)
Bean defining the class implementing the file locking strategy. This bean must be an implementation of the org.apache.servicemix.locks.LockManager interface. By default, this will be set to an instances of org.apache.servicemix.common.locks.impl.SimpleLockManager.

Parameters:
lockManager - the LockManager implementation to use

getLockManager

public LockManager getLockManager()

setMarshaler

public void setMarshaler(org.apache.servicemix.components.util.FileMarshaler marshaler)
Specifies a FileMarshaler object that will marshal file data into the NMR. The default file marshaller can read valid XML data. FileMarshaler objects are implementations of org.apache.servicemix.components.util.FileMarshaler.

Parameters:
marshaler - a FileMarshaler object that can read data from the file system.

getMarshaler

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

setComparator

public void setComparator(java.util.Comparator<org.apache.commons.vfs.FileObject> comparator)
Specifies a Comparator object.

Parameters:
comparator - a Comparator object.

getComparator

public java.util.Comparator<org.apache.commons.vfs.FileObject> getComparator()

setSelector

public void setSelector(org.apache.commons.vfs.FileSelector selector)
Specifies a FileSelector object.

Parameters:
selector - a FileSelector object

getSelector

public org.apache.commons.vfs.FileSelector getSelector()

setPath

public void setPath(java.lang.String path)
Specifies a String object representing the path of the file/folder to be polled.

Examples:
For further details have a look at http://commons.apache.org/vfs/filesystems.html.

Parameters:
path - a String object that represents a file/folder/vfs

getPath

public java.lang.String getPath()

setFileSystemManager

public void setFileSystemManager(org.apache.commons.vfs.FileSystemManager fileSystemManager)
sets the file system manager

Parameters:
fileSystemManager - the file system manager

getFileSystemManager

public org.apache.commons.vfs.FileSystemManager getFileSystemManager()

getWorkingSet

public java.util.Set<org.apache.commons.vfs.FileObject> getWorkingSet()
The set of FTPFiles that this component is currently working on

Returns:
a set of in-process file objects

isRecursive

public boolean isRecursive()
Returns:
Returns the recursive.

setRecursive

public void setRecursive(boolean recursive)
Parameters:
recursive - The recursive to set.

isConcurrentExchange

public boolean isConcurrentExchange()
Returns:
the concurrentExchange

setConcurrentExchange

public void setConcurrentExchange(boolean concurrentExchange)
Parameters:
concurrentExchange - the concurrentExchange to set


Copyright © 2005-2012 FuseSource. All Rights Reserved.