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
Constructor and Description |
---|
FsConsumerImpl() |
Modifier and Type | Method and Description |
---|---|
protected void |
addStandardMetadata(AdaptrisMessage msg,
java.io.File originalFile,
java.io.File wipFile) |
protected java.lang.String |
baseDirUrl() |
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) |
protected java.lang.String |
filterExpression() |
java.lang.String |
getBaseDirectoryUrl()
The base directory specified as a URL.
|
java.lang.Boolean |
getCreateDirs()
Create missing directories when trying to poll
|
ConsumeDestination |
getDestination()
Deprecated.
|
java.lang.String |
getFileFilterImp()
Set the filename filter implementation that will be used for filtering files.
|
@NonNull FileSorter |
getFileSorter()
Set the filesorter implementation to use.
|
java.lang.String |
getFilterExpression()
The filter expression to use when listing files.
|
java.lang.Boolean |
getLogAllExceptions()
Log all the stack traces or not.
|
TimeInterval |
getQuietInterval()
Specify how old a file must be before a file is deemed safe to be processed.
|
void |
init()
Initialises the component.
|
protected boolean |
isFileAccessible(java.io.File f)
Could we read and process this file.
|
boolean |
logAllExceptions() |
protected java.lang.String |
newThreadName() |
protected void |
prepareConsumer() |
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 |
setBaseDirectoryUrl(java.lang.String baseDirectoryUrl)
The base directory specified as a URL.
|
void |
setCreateDirs(java.lang.Boolean createDirs)
Create missing directories when trying to poll
|
void |
setDestination(ConsumeDestination destination)
Deprecated.
|
void |
setFileFilterImp(java.lang.String fileFilterImp)
Set the filename filter implementation that will be used for filtering files.
|
void |
setFileSorter(@NonNull FileSorter fileSorter)
Set the filesorter implementation to use.
|
void |
setFilterExpression(java.lang.String filterExpression)
The filter expression to use when listing files.
|
void |
setLogAllExceptions(java.lang.Boolean logAllExceptions)
Log all the stack traces or not.
|
void |
setQuietInterval(TimeInterval quietInterval)
Specify how old a file must be before a file is deemed safe to be processed.
|
boolean |
shouldCreateDirs() |
protected java.io.File |
verifyDirectory() |
<T extends FsConsumerImpl> |
withBaseDirectoryUrl(java.lang.String s) |
<T extends FsConsumerImpl> |
withFilterExpression(java.lang.String s) |
close, continueProcessingMessages, getMaxMessagesPerPoll, getPoller, getReacquireLockBetweenMessages, prepare, releaseLock, setMaxMessagesPerPoll, setPoller, setReacquireLockBetweenMessages, start, stop
changeState, registerAdaptrisMessageListener, renameThread, requestClose, requestInit, requestStart, requestStop, retrieveAdaptrisMessageListener, retrieveComponentState
createName, createQualifier, decode, encode, getEncoder, getIsTrackingEndpoint, getMessageFactory, getUniqueId, handleConnectionException, isTrackingEndpoint, registerConnection, registerEncoderMessageFactory, retrieveConnection, setEncoder, setIsTrackingEndpoint, setMessageFactory, setUniqueId, withMessageFactory, withUniqueID
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 void prepareConsumer() throws CoreException
prepareConsumer
in class AdaptrisPollingConsumer
CoreException
protected java.lang.String baseDirUrl()
protected java.lang.String filterExpression()
protected java.lang.String newThreadName()
newThreadName
in class AdaptrisMessageConsumerImp
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 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 boolean logAllExceptions()
public java.lang.String consumeLocationKey()
public <T extends FsConsumerImpl> T withBaseDirectoryUrl(java.lang.String s)
public <T extends FsConsumerImpl> T withFilterExpression(java.lang.String s)
public java.lang.String getFileFilterImp()
The file filter implementation that is used in conjunction with the
getFilterExpression()
, if not specified, then the default is
org.apache.commons.io.filefilter.RegexFileFilter
which uses the java.util regular
expressions to perform filtering
The expression that is used to filter messages is derived from getFilterExpression()
or from the deprecated getDestination()
.
getFilterExpression()
public void setFileFilterImp(java.lang.String fileFilterImp)
The file filter implementation that is used in conjunction with the
getFilterExpression()
, if not specified, then the default is
org.apache.commons.io.filefilter.RegexFileFilter
which uses the java.util regular
expressions to perform filtering
The expression that is used to filter messages is derived from getFilterExpression()
or from the deprecated getDestination()
.
getFilterExpression()
public java.lang.Boolean getCreateDirs()
this defaults to false because we consider it a dangerous thing to do especially if you have bad configuration. The last thing we want is for you to accuse interlok of creating random directories.
public void setCreateDirs(java.lang.Boolean createDirs)
this defaults to false because we consider it a dangerous thing to do especially if you have bad configuration. The last thing we want is for you to accuse interlok of creating random directories.
public java.lang.Boolean getLogAllExceptions()
public void setLogAllExceptions(java.lang.Boolean logAllExceptions)
public TimeInterval getQuietInterval()
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.
File.lastModified()
,
CompositeFileFilter
,
setFileFilterImp(String)
public void setQuietInterval(TimeInterval quietInterval)
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.
File.lastModified()
,
CompositeFileFilter
,
setFileFilterImp(String)
@NonNull public @NonNull FileSorter getFileSorter()
The file sorter is responsible for sorting the list of files that is collected for processing. The sorted list is then processed.
public void setFileSorter(@NonNull @NonNull FileSorter fileSorter)
The file sorter is responsible for sorting the list of files that is collected for processing. The sorted list is then processed.
@Deprecated public ConsumeDestination getDestination()
@Deprecated public void setDestination(ConsumeDestination destination)
public java.lang.String getBaseDirectoryUrl()
public void setBaseDirectoryUrl(java.lang.String baseDirectoryUrl)
public java.lang.String getFilterExpression()
If not specified then will default in a file filter that matches all files.
public void setFilterExpression(java.lang.String filterExpression)
If not specified then will default in a file filter that matches all files.