org.apache.camel.component.file
Class FileConsumer

java.lang.Object
  extended by org.apache.camel.support.ServiceSupport
      extended by org.apache.camel.impl.DefaultConsumer
          extended by org.apache.camel.impl.ScheduledPollConsumer
              extended by org.apache.camel.impl.ScheduledBatchPollingConsumer
                  extended by org.apache.camel.component.file.GenericFileConsumer<File>
                      extended by org.apache.camel.component.file.FileConsumer
All Implemented Interfaces:
Runnable, BatchConsumer, Consumer, PollingConsumerPollingStrategy, Service, ShutdownableService, ShutdownAware, ShutdownPrepared, StatefulService, SuspendableService

public class FileConsumer
extends GenericFileConsumer<File>

File consumer.


Field Summary
 
Fields inherited from class org.apache.camel.component.file.GenericFileConsumer
customProcessor, eagerLimitMaxMessagesPerPoll, endpoint, fileExpressionResult, log, loggedIn, operations, pendingExchanges, shutdownRunningTask
 
Fields inherited from class org.apache.camel.impl.ScheduledBatchPollingConsumer
maxMessagesPerPoll
 
Fields inherited from class org.apache.camel.support.ServiceSupport
shutdown, shuttingdown, started, starting, stopped, stopping, suspended, suspending
 
Constructor Summary
FileConsumer(GenericFileEndpoint<File> endpoint, Processor processor, GenericFileOperations<File> operations)
           
 
Method Summary
static GenericFile<File> asGenericFile(String endpointPath, File file, String charset)
          Creates a new GenericFile based on the given file.
 FileEndpoint getEndpoint()
          Gets the endpoint this Consumer consumes from.
protected  boolean isMatched(GenericFile<File> file, String doneFileName, List<File> files)
          Strategy to perform file matching based on endpoint configuration in terms of done file name.
protected  boolean pollDirectory(String fileName, List<GenericFile<File>> fileList, int depth)
          Polls the given directory for files to process
 
Methods inherited from class org.apache.camel.component.file.GenericFileConsumer
canPollMoreFiles, customProcessExchange, doStart, getCustomProcessor, isEagerLimitMaxMessagesPerPoll, isInProgress, isMatched, isValidFile, poll, postPollCheck, prePollCheck, processBatch, processExchange, removeExcessiveInProgressFiles, setCustomProcessor, setEagerLimitMaxMessagesPerPoll, setOperations
 
Methods inherited from class org.apache.camel.impl.ScheduledBatchPollingConsumer
deferShutdown, getMaxMessagesPerPoll, getPendingExchangesSize, isBatchAllowed, prepareShutdown, processEmptyMessage, setMaxMessagesPerPoll
 
Methods inherited from class org.apache.camel.impl.ScheduledPollConsumer
afterPoll, beforePoll, doShutdown, doStop, doSuspend, getDelay, getInitialDelay, getPollStrategy, getRunLoggingLevel, getScheduledExecutorService, getTimeUnit, isGreedy, isPollAllowed, isPolling, isSchedulerStarted, isSendEmptyMessageWhenIdle, isStartScheduler, isUseFixedDelay, onInit, run, setDelay, setGreedy, setInitialDelay, setPollStrategy, setRunLoggingLevel, setScheduledExecutorService, setSendEmptyMessageWhenIdle, setStartScheduler, setTimeUnit, setUseFixedDelay, startScheduler
 
Methods inherited from class org.apache.camel.impl.DefaultConsumer
getAsyncProcessor, getExceptionHandler, getProcessor, handleException, handleException, setExceptionHandler, toString
 
Methods inherited from class org.apache.camel.support.ServiceSupport
doResume, getStatus, getVersion, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isSuspended, isSuspending, resume, shutdown, start, stop, suspend
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.apache.camel.Service
start, stop
 
Methods inherited from interface org.apache.camel.SuspendableService
isSuspended, resume, suspend
 

Constructor Detail

FileConsumer

public FileConsumer(GenericFileEndpoint<File> endpoint,
                    Processor processor,
                    GenericFileOperations<File> operations)
Method Detail

pollDirectory

protected boolean pollDirectory(String fileName,
                                List<GenericFile<File>> fileList,
                                int depth)
Description copied from class: GenericFileConsumer
Polls the given directory for files to process

Specified by:
pollDirectory in class GenericFileConsumer<File>
Parameters:
fileName - current directory or file
fileList - current list of files gathered
depth - the current depth of the directory (will start from 0)
Returns:
whether or not to continue polling, false means the maxMessagesPerPoll limit has been hit

isMatched

protected boolean isMatched(GenericFile<File> file,
                            String doneFileName,
                            List<File> files)
Description copied from class: GenericFileConsumer
Strategy to perform file matching based on endpoint configuration in terms of done file name.

Specified by:
isMatched in class GenericFileConsumer<File>
Parameters:
file - the file
doneFileName - the done file name (without any paths)
files - files in the directory
Returns:
true if the file is matched, false if not

asGenericFile

public static GenericFile<File> asGenericFile(String endpointPath,
                                              File file,
                                              String charset)
Creates a new GenericFile based on the given file.

Parameters:
endpointPath - the starting directory the endpoint was configured with
file - the source file
Returns:
wrapped as a GenericFile

getEndpoint

public FileEndpoint getEndpoint()
Description copied from interface: Consumer
Gets the endpoint this Consumer consumes from.

Specified by:
getEndpoint in interface Consumer
Overrides:
getEndpoint in class DefaultConsumer
Returns:
the endpoint


Apache CAMEL