Class FtpConsumerImpl
- java.lang.Object
-
- com.adaptris.core.AdaptrisMessageWorkerImp
-
- com.adaptris.core.AdaptrisMessageConsumerImp
-
- com.adaptris.core.AdaptrisPollingConsumer
-
- com.adaptris.core.ftp.FtpConsumerImpl
-
- All Implemented Interfaces:
AdaptrisComponent
,AdaptrisMessageConsumer
,AdaptrisMessageWorker
,ComponentLifecycle
,ComponentLifecycleExtension
,MessageEventGenerator
,StateManagedComponent
- Direct Known Subclasses:
FtpConsumer
,RelaxedFtpConsumer
public abstract class FtpConsumerImpl extends AdaptrisPollingConsumer
Abstract FTP Implementation of theAdaptrisMessageConsumer
implementation.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.adaptris.core.AdaptrisPollingConsumer
AdaptrisPollingConsumer.LockOperator
-
-
Field Summary
Fields Modifier and Type Field Description protected static java.lang.String
DEFAULT_FILE_FILTER_IMPL
Deprecated.since 3.11.1instead.
protected static TimeInterval
DEFAULT_OLDER_THAN
protected java.io.FileFilter
fileFilter
protected FileTransferClient
ftpClient
-
Fields inherited from class com.adaptris.core.AdaptrisMessageWorkerImp
log
-
-
Constructor Summary
Constructors Constructor Description FtpConsumerImpl()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected boolean
accept(java.lang.String path)
protected boolean
additionalDebug()
protected AdaptrisMessage
addStandardMetadata(AdaptrisMessage msg, java.lang.String filename, java.lang.String dir)
protected java.lang.String
configureWorkDir(java.lang.String path)
java.lang.String
consumeLocationKey()
Provides the metadata key '"fsConsumeDir"' that contains the directory (if not null) where the file was read from.protected abstract boolean
fetchAndProcess(java.lang.String fullPath)
protected java.lang.String
fileFilterImp()
protected java.lang.String
filterExpression()
protected java.lang.String
ftpURL()
java.lang.String
getFileFilterImp()
Set the filename filter implementation that will be used for filtering files.java.lang.String
getFilterExpression()
The filter expression to use when listing files.java.lang.String
getFtpEndpoint()
The FTP endpoint where we will retrieve files files.TimeInterval
getQuietInterval()
protected boolean
handle(java.lang.String fileToGet)
void
init()
Initialises the component.protected boolean
oldEnough(java.lang.String fullPath)
protected long
olderThanMs()
protected void
prepareConsumer()
protected int
processMessages()
Implemented by protocol-specific sub-classes.void
setFileFilterImp(java.lang.String fileFilterImp)
Set the filename filter implementation that will be used for filtering files.void
setFilterExpression(java.lang.String filterExpression)
The filter expression to use when listing files.void
setFtpEndpoint(java.lang.String ftpEndpoint)
The FTP endpoint where we will retrieve files files.void
setQuietInterval(TimeInterval interval)
Specify the time in which a file has been untouched before it is deemed safe to be processed.-
Methods inherited from class com.adaptris.core.AdaptrisPollingConsumer
close, continueProcessingMessages, getMaxMessagesPerPoll, getPoller, getReacquireLockBetweenMessages, prepare, releaseLock, setMaxMessagesPerPoll, setPoller, setReacquireLockBetweenMessages, start, stop
-
Methods inherited from class com.adaptris.core.AdaptrisMessageConsumerImp
changeState, newThreadName, registerAdaptrisMessageListener, renameThread, requestClose, requestInit, requestStart, requestStop, retrieveAdaptrisMessageListener, retrieveComponentState
-
Methods inherited from class com.adaptris.core.AdaptrisMessageWorkerImp
createName, createQualifier, decode, encode, getEncoder, getIsTrackingEndpoint, getMessageFactory, getUniqueId, handleConnectionException, isTrackingEndpoint, registerConnection, registerEncoderMessageFactory, retrieveConnection, setEncoder, setIsTrackingEndpoint, setMessageFactory, setUniqueId, withMessageFactory, withUniqueID
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.adaptris.core.AdaptrisComponent
getUniqueId
-
Methods inherited from interface com.adaptris.core.AdaptrisMessageWorker
decode, encode, getEncoder, getMessageFactory, handleConnectionException, registerConnection, retrieveConnection, setEncoder, setMessageFactory
-
Methods inherited from interface com.adaptris.core.MessageEventGenerator
createName, createQualifier, isTrackingEndpoint
-
-
-
-
Field Detail
-
DEFAULT_OLDER_THAN
protected static final TimeInterval DEFAULT_OLDER_THAN
-
DEFAULT_FILE_FILTER_IMPL
@Deprecated protected static final java.lang.String DEFAULT_FILE_FILTER_IMPL
Deprecated.since 3.11.1instead.
-
fileFilter
protected transient java.io.FileFilter fileFilter
-
ftpClient
protected transient FileTransferClient ftpClient
-
-
Method Detail
-
init
public void init() throws CoreException
Description copied from interface:ComponentLifecycle
Initialises the component.Component initialisation includes config verification, creation of connections etc.
- Specified by:
init
in interfaceComponentLifecycle
- Overrides:
init
in classAdaptrisPollingConsumer
- Throws:
CoreException
- wrapping any underlyingException
s- See Also:
ComponentLifecycle.init()
-
additionalDebug
protected boolean additionalDebug()
-
oldEnough
protected boolean oldEnough(java.lang.String fullPath) throws FileTransferException, java.io.IOException
- Throws:
FileTransferException
java.io.IOException
-
addStandardMetadata
protected AdaptrisMessage addStandardMetadata(AdaptrisMessage msg, java.lang.String filename, java.lang.String dir)
-
processMessages
protected int processMessages()
Description copied from class:AdaptrisPollingConsumer
Implemented by protocol-specific sub-classes.
- Specified by:
processMessages
in classAdaptrisPollingConsumer
-
handle
protected boolean handle(java.lang.String fileToGet)
-
fetchAndProcess
protected abstract boolean fetchAndProcess(java.lang.String fullPath) throws java.lang.Exception
- Throws:
java.lang.Exception
-
configureWorkDir
protected java.lang.String configureWorkDir(java.lang.String path)
-
accept
protected boolean accept(java.lang.String path) throws java.lang.Exception
- Throws:
java.lang.Exception
-
prepareConsumer
protected void prepareConsumer() throws CoreException
- Specified by:
prepareConsumer
in classAdaptrisPollingConsumer
- Throws:
CoreException
-
ftpURL
protected java.lang.String ftpURL()
-
filterExpression
protected java.lang.String filterExpression()
-
fileFilterImp
protected java.lang.String fileFilterImp()
-
olderThanMs
protected long olderThanMs()
-
getQuietInterval
public TimeInterval getQuietInterval()
-
setQuietInterval
public void setQuietInterval(TimeInterval interval)
Specify the time in which a file has been untouched before it is deemed safe to be processed.The purpose of this is to delay processing of files that may be currently being written to by another process. On certain platforms (e.g. most Unix) it is still possible to obtain an exclusive lock on the file even though it is being written to by another process.
Note: your mileage may vary when using this setting. The FTP Server and the FTP Client will almost certainly have to time-synchronized. Depending on the FTP Server implementation in question, you may need to additionally specify the server's timezone in order to get accurate information.Additionally, the remote FTP server needs to support support the MDTM command.
- Parameters:
interval
- the quietPeriod to set (default to 0)- See Also:
FtpConnectionImp.setServerTimezone(String)
,CompositeFileFilter
,setFileFilterImp(String)
-
consumeLocationKey
public java.lang.String consumeLocationKey()
Provides the metadata key '"fsConsumeDir"' that contains the directory (if not null) where the file was read from.- Returns:
- the metadata key;
- Since:
- 3.9.0
-
getFileFilterImp
public java.lang.String getFileFilterImp()
Set the filename filter implementation that will be used for filtering files.The file filter implementation that is used in conjunction with the
getFilterExpression()
, if not specified, then the default isorg.apache.commons.io.filefilter.RegexFileFilter
which uses the java.util regular expressions to perform filteringThe expression that is used to filter messages is derived from
getFilterExpression()
.Note that because we working against a remote server, support for additional file attributes such as size (e.g. via
SizeGreaterThan
) or last modified may not be supported. We encourage you to stick with filtering by filename only.- See Also:
getFilterExpression()
-
setFileFilterImp
public void setFileFilterImp(java.lang.String fileFilterImp)
Set the filename filter implementation that will be used for filtering files.The file filter implementation that is used in conjunction with the
getFilterExpression()
, if not specified, then the default isorg.apache.commons.io.filefilter.RegexFileFilter
which uses the java.util regular expressions to perform filteringThe expression that is used to filter messages is derived from
getFilterExpression()
.Note that because we working against a remote server, support for additional file attributes such as size (e.g. via
SizeGreaterThan
) or last modified may not be supported. We encourage you to stick with filtering by filename only.- See Also:
getFilterExpression()
-
getFtpEndpoint
public java.lang.String getFtpEndpoint()
The FTP endpoint where we will retrieve files files.Although nominally a URL, you can configure the following styles
- Just the server name / IP Address (e.g. 10.0.0.1) in which case the username and password
from the corresponding
FileTransferConnection
will be used to supply the username and password. You will be working off directly off the perceived root filesystem which will be a problem if you aren't in a chroot jail. - A FTP style URL
ftp://10.0.0.1/path/to/dir
, the username and password will be taken from the corresponding connection. The working directory start with/path/to/dir
- A FTP style URL with a username/password
ftp://user:password@10.0.0.1/path/to/dir
. The working directory will start with/path/to/dir
- Just the server name / IP Address (e.g. 10.0.0.1) in which case the username and password
from the corresponding
-
setFtpEndpoint
public void setFtpEndpoint(java.lang.String ftpEndpoint)
The FTP endpoint where we will retrieve files files.Although nominally a URL, you can configure the following styles
- Just the server name / IP Address (e.g. 10.0.0.1) in which case the username and password
from the corresponding
FileTransferConnection
will be used to supply the username and password. You will be working off directly off the perceived root filesystem which will be a problem if you aren't in a chroot jail. - A FTP style URL
ftp://10.0.0.1/path/to/dir
, the username and password will be taken from the corresponding connection. The working directory start with/path/to/dir
- A FTP style URL with a username/password
ftp://user:password@10.0.0.1/path/to/dir
. The working directory will start with/path/to/dir
- Just the server name / IP Address (e.g. 10.0.0.1) in which case the username and password
from the corresponding
-
getFilterExpression
public java.lang.String getFilterExpression()
The filter expression to use when listing files.If not specified then will default in a file filter that matches all files.
-
setFilterExpression
public void setFilterExpression(java.lang.String filterExpression)
The filter expression to use when listing files.If not specified then will default in a file filter that matches all files.
-
-