public abstract class FsConsumerImpl extends AdaptrisPollingConsumer
Abstract implementation of AdaptrisMessageConsumer
based on the com.adaptris.fs
package.
AdaptrisPollingConsumer.LockOperator
Modifier and Type | Field and Description |
---|---|
protected java.io.FileFilter |
fileFilter |
protected FsWorker |
fsWorker |
log
CONFIRMATION_ID_KEY
Constructor and Description |
---|
FsConsumerImpl() |
Modifier and Type | Method and Description |
---|---|
protected void |
addStandardMetadata(AdaptrisMessage msg,
java.io.File originalFile,
java.io.File wipFile) |
protected boolean |
checkModified(java.io.File f)
Does this file match the quiet period directive.
|
java.lang.String |
consumeLocationKey()
Provides the metadata key '"fsConsumeDir"' that
contains the directory (if not null) where the file was read from.
|
protected AdaptrisMessage |
createAdaptrisMessage(java.io.File fileToProcess) |
java.lang.Boolean |
getCreateDirs()
Get the flag specifying creation of directories.
|
java.lang.String |
getFileFilterImp()
Returns the name of the
FileFilter being used. |
FileSorter |
getFileSorter() |
java.lang.Boolean |
getLogAllExceptions() |
TimeInterval |
getQuietInterval() |
void |
init()
Initialises the component.
|
protected boolean |
isFileAccessible(java.io.File f)
Could we read and process this file.
|
boolean |
logAllExceptions() |
protected abstract int |
processFile(java.io.File f)
Attempt to process this file which might be a directory.
|
protected int |
processMessages()
If reacquire-lock-between-messages is set to true, this.reaquireLock is called after each message has been processed.
|
void |
setCreateDirs(java.lang.Boolean b)
Specify whether to create directories that do not exist.
|
void |
setFileFilterImp(java.lang.String string)
Set the filename filter
|
void |
setFileSorter(FileSorter fs)
Set the filesorter implementation to use.
|
void |
setLogAllExceptions(java.lang.Boolean b)
Whether or not to log all stacktraces.
|
void |
setQuietInterval(TimeInterval interval)
Specify how old a file must be before a file is deemed safe to be processed.
|
boolean |
shouldCreateDirs() |
protected java.io.File |
verifyDirectory() |
close, continueProcessingMessages, getMaxMessagesPerPoll, getPoller, getReacquireLockBetweenMessages, prepare, prepareConsumer, releaseLock, setMaxMessagesPerPoll, setPoller, setReacquireLockBetweenMessages, start, stop
changeState, getDestination, registerAdaptrisMessageListener, renameThread, requestClose, requestInit, requestStart, requestStop, retrieveAdaptrisMessageListener, retrieveComponentState, setDestination
createName, createQualifier, decode, encode, getEncoder, getIsTrackingEndpoint, getMessageFactory, getUniqueId, handleConnectionException, isTrackingEndpoint, registerConnection, registerEncoderMessageFactory, retrieveConnection, setEncoder, setIsTrackingEndpoint, setMessageFactory, setUniqueId, withMessageFactory
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
decode, encode, getEncoder, getMessageFactory, handleConnectionException, registerConnection, retrieveConnection, setEncoder, setMessageFactory
getUniqueId
createName, createQualifier, isTrackingEndpoint
protected transient java.io.FileFilter fileFilter
protected transient FsWorker fsWorker
protected int processMessages()
If reacquire-lock-between-messages is set to true, this.reaquireLock is called after each message has been processed. This gives other Threads (e.g. something stopping the adapter) the opportunity to obtain the lock without waiting for all messages to be processed.
processMessages
in class AdaptrisPollingConsumer
AdaptrisPollingConsumer.processMessages()
protected boolean checkModified(java.io.File f) throws java.io.IOException
f
- the file.java.io.IOException
protected boolean isFileAccessible(java.io.File f)
f
- the file.protected abstract int processFile(java.io.File f) throws CoreException
f
- the FileCoreException
- wrapping any other Exception.public void init() throws CoreException
ComponentLifecycle
Component initialisation includes config verification, creation of connections etc.
init
in interface ComponentLifecycle
init
in class AdaptrisPollingConsumer
CoreException
- wrapping any underlying Exception
sComponentLifecycle.init()
protected java.io.File verifyDirectory() throws java.lang.Exception
java.lang.Exception
public void setCreateDirs(java.lang.Boolean b)
When the ConsumeDestination returns a destination, if this flag has been set, then an attempt to create the directory is made, if the directory does not exist.
b
- true to enable directory creation; default false.public java.lang.Boolean getCreateDirs()
public boolean shouldCreateDirs()
protected AdaptrisMessage createAdaptrisMessage(java.io.File fileToProcess) throws CoreException
CoreException
protected void addStandardMetadata(AdaptrisMessage msg, java.io.File originalFile, java.io.File wipFile) throws CoreException
CoreException
public void setFileFilterImp(java.lang.String string)
string
- the classname of the FileFilter
implementation to use, if not specified, then it defaults to
org.apache.commons.io.filefilter.RegexFileFilter
which uses Pattern
.ConsumeDestination.getFilterExpression()
public java.lang.String getFileFilterImp()
Returns the name of the FileFilter
being used.
FileFilter
being usedpublic java.lang.Boolean getLogAllExceptions()
public void setLogAllExceptions(java.lang.Boolean b)
b
- the logAllExceptions to set, default truepublic boolean logAllExceptions()
public TimeInterval getQuietInterval()
public void setQuietInterval(TimeInterval interval)
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.
An alternative to specifying a last-modified is to specify CompositeFileFilter
as the filter implementation and then a
combination of OlderThan
along with your actual filter-implementation.
Note: your mileage may vary when using this setting. The only surefire way is for the triggering application to write the file to a staging area and use an atomic operation (such as move) to move the file into the target directory.
interval
- the interval to set (default is 0)File.lastModified()
,
CompositeFileFilter
,
setFileFilterImp(String)
public FileSorter getFileSorter()
public void setFileSorter(FileSorter fs)
The file sorter is responsible for sorting the list of files that is collected for processing. The sorted list is then processed.
fs
- the sorter, default is NoSorting
public java.lang.String consumeLocationKey()