Package org.apache.synapse.transport.vfs
Class VFSTransportListener
java.lang.Object
org.apache.axis2.transport.base.AbstractTransportListener
org.apache.axis2.transport.base.AbstractTransportListenerEx<PollTableEntry>
org.apache.axis2.transport.base.AbstractPollingTransportListener<PollTableEntry>
org.apache.synapse.transport.vfs.VFSTransportListener
- All Implemented Interfaces:
org.apache.axis2.transport.base.ManagementSupport,org.apache.axis2.transport.TransportListener
public class VFSTransportListener
extends org.apache.axis2.transport.base.AbstractPollingTransportListener<PollTableEntry>
implements org.apache.axis2.transport.base.ManagementSupport
The "vfs" transport is a polling based transport - i.e. it gets kicked off at
specified periodic durations, and would iterate through a list of directories or files
specified according to poll durations. When scanning a directory, it will match
its contents against a given regex to find the set of input files. For compressed
files, the contents could be matched against a regex to find individual files.
Each of these files thus found would be submitted as an Axis2 "message" into the
Axis2 engine.
The processed files would be deleted or renamed as specified in the configuration
Supported VFS example URIs
file:///directory/filename.ext
file:////somehost/someshare/afile.txt
jar:../lib/classes.jar!/META-INF/manifest.mf
zip:http://somehost/downloads/somefile.zip
jar:zip:outer.zip!/nested.jar!/somedir
jar:zip:outer.zip!/nested.jar!/some%21dir
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://somehost:8080/downloads/somefile.jar
http://myusername@somehost/index.html
webdav://somehost:8080/dist
ftp://myusername:mypassword@somehost/pub/downloads/somefile.tgz[?passive=true]
sftp://myusername:mypassword@somehost/pub/downloads/somefile.tgz
smb://somehost/home
axis2.xml - transport definition
enable|disable ?
services.xml - service attachment
required parameters
..
..
optional parameters
..
..
..
..
..
..
..
FTP testing URIs
ftp://ftpuser:password@asankha/somefile.csv?passive=true
ftp://vfs:apache@vfs.netfirms.com/somepath/somefile.xml?passive=true
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final longstatic final Stringstatic final Stringstatic final StringFields inherited from class org.apache.axis2.transport.base.AbstractTransportListener
cfgCtx, config, isNonBlocking, log, metrics, state, useAxis2ThreadPoolFields inherited from interface org.apache.axis2.transport.TransportListener
HOST_ADDRESS, PARAM_PORT -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanacquireLock(org.apache.commons.vfs2.FileSystemManager fsManager, org.apache.commons.vfs2.FileObject fileObject, PollTableEntry entry, org.apache.commons.vfs2.FileSystemOptions fso, boolean isListener) protected voidaddFailedRecord(PollTableEntry pollTableEntry, org.apache.commons.vfs2.FileObject failedObject, String timeString) protected PollTableEntryvoiddestroy()protected voiddoInit()org.apache.commons.vfs2.impl.DefaultFileSystemManagerprotected booleanisFailedRecord(org.apache.commons.vfs2.FileObject fileObject, PollTableEntry entry) booleanprotected voidmoveOrDeleteAfterProcessing(PollTableEntry entry, org.apache.commons.vfs2.FileObject fileObject, org.apache.commons.vfs2.FileSystemOptions fso) Take specified action to either move or delete the processed file, depending on the outcomeprotected voidpoll(PollTableEntry entry) protected booleanprocessFile(PollTableEntry entry, org.apache.commons.vfs2.FileObject file) Process a single file through Axis2protected voidscanFileOrDirectory(PollTableEntry entry, String fileURI) Search for files that match the given regex pattern and create a list Then process each of these files and update the status of the scan on the poll tablevoidsetFileSystemClosed(boolean fileSystemClosed) voidsetFsManager(org.apache.commons.vfs2.impl.DefaultFileSystemManager fsManager) protected voidstopEndpoint(PollTableEntry endpoint) Methods inherited from class org.apache.axis2.transport.base.AbstractPollingTransportListener
maintenenceShutdown, onPollCompletion, pause, processFailure, resume, startEndpointMethods inherited from class org.apache.axis2.transport.base.AbstractTransportListenerEx
getEndpoints, getEPRsForService, init, start, startListeningForService, stop, stopListeningForServiceMethods inherited from class org.apache.axis2.transport.base.AbstractTransportListener
createMessageContext, disableTransportForService, getActiveThreadCount, getAvgSizeReceived, getAvgSizeSent, getBytesReceived, getBytesSent, getConfigurationContext, getEPRForService, getEPRsForService, getFaultsReceiving, getFaultsSending, getLastResetTime, getMaxSizeReceived, getMaxSizeSent, getMessagesReceived, getMessagesSent, getMetricsCollector, getMetricsWindow, getMinSizeReceived, getMinSizeSent, getQueueSize, getResponseCodeTable, getSessionContext, getTimeoutsReceiving, getTimeoutsSending, getTransportInDescription, getTransportName, handleException, handleIncomingMessage, logException, resetStatisticsMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.axis2.transport.base.ManagementSupport
getActiveThreadCount, getAvgSizeReceived, getAvgSizeSent, getBytesReceived, getBytesSent, getFaultsReceiving, getFaultsSending, getLastResetTime, getMaxSizeReceived, getMaxSizeSent, getMessagesReceived, getMessagesSent, getMetricsWindow, getMinSizeReceived, getMinSizeSent, getQueueSize, getResponseCodeTable, getTimeoutsReceiving, getTimeoutsSending, maintenenceShutdown, pause, resetStatistics, resume
-
Field Details
-
TRANSPORT_NAME
- See Also:
-
DELETE
- See Also:
-
MOVE
- See Also:
-
NONE
- See Also:
-
EMPTY_MD5
- See Also:
-
GRACEFUL_SHUTDOWN_POLL_INTERVAL_MS
public static final long GRACEFUL_SHUTDOWN_POLL_INTERVAL_MS- See Also:
-
-
Constructor Details
-
VFSTransportListener
public VFSTransportListener()
-
-
Method Details
-
doInit
protected void doInit() throws org.apache.axis2.AxisFault- Overrides:
doInitin classorg.apache.axis2.transport.base.AbstractPollingTransportListener<PollTableEntry>- Throws:
org.apache.axis2.AxisFault
-
poll
- Specified by:
pollin classorg.apache.axis2.transport.base.AbstractPollingTransportListener<PollTableEntry>
-
scanFileOrDirectory
Search for files that match the given regex pattern and create a list Then process each of these files and update the status of the scan on the poll table- Parameters:
entry- the poll table entry for the scanfileURI- the file or directory to be scanned
-
destroy
public void destroy()- Specified by:
destroyin interfaceorg.apache.axis2.transport.TransportListener- Overrides:
destroyin classorg.apache.axis2.transport.base.AbstractPollingTransportListener<PollTableEntry>
-
acquireLock
protected boolean acquireLock(org.apache.commons.vfs2.FileSystemManager fsManager, org.apache.commons.vfs2.FileObject fileObject, PollTableEntry entry, org.apache.commons.vfs2.FileSystemOptions fso, boolean isListener) -
moveOrDeleteAfterProcessing
protected void moveOrDeleteAfterProcessing(PollTableEntry entry, org.apache.commons.vfs2.FileObject fileObject, org.apache.commons.vfs2.FileSystemOptions fso) throws org.apache.axis2.AxisFault Take specified action to either move or delete the processed file, depending on the outcome- Parameters:
entry- the PollTableEntry for the file that has been processedfileObject- the FileObject representing the file to be moved or deleted- Throws:
org.apache.axis2.AxisFault
-
processFile
protected boolean processFile(PollTableEntry entry, org.apache.commons.vfs2.FileObject file) throws org.apache.axis2.AxisFault Process a single file through Axis2- Parameters:
entry- the PollTableEntry for the file (or its parent directory or archive)file- the file that contains the actual message pumped into Axis2- Returns:
- boolean the status of the operation
- Throws:
org.apache.axis2.AxisFault- on error
-
createEndpoint
- Specified by:
createEndpointin classorg.apache.axis2.transport.base.AbstractTransportListenerEx<PollTableEntry>
-
stopEndpoint
- Overrides:
stopEndpointin classorg.apache.axis2.transport.base.AbstractPollingTransportListener<PollTableEntry>
-
addFailedRecord
protected void addFailedRecord(PollTableEntry pollTableEntry, org.apache.commons.vfs2.FileObject failedObject, String timeString) -
isFailedRecord
protected boolean isFailedRecord(org.apache.commons.vfs2.FileObject fileObject, PollTableEntry entry) -
getFsManager
public org.apache.commons.vfs2.impl.DefaultFileSystemManager getFsManager() -
setFsManager
public void setFsManager(org.apache.commons.vfs2.impl.DefaultFileSystemManager fsManager) -
isFileSystemClosed
public boolean isFileSystemClosed() -
setFileSystemClosed
public void setFileSystemClosed(boolean fileSystemClosed)
-