org.apache.camel.component.file.strategy
Class GenericFileProcessStrategySupport<T>

java.lang.Object
  extended by org.apache.camel.component.file.strategy.GenericFileProcessStrategySupport<T>
All Implemented Interfaces:
GenericFileProcessStrategy<T>
Direct Known Subclasses:
GenericFileDeleteProcessStrategy, GenericFileNoOpProcessStrategy, GenericFileRenameProcessStrategy

public abstract class GenericFileProcessStrategySupport<T>
extends Object
implements GenericFileProcessStrategy<T>


Field Summary
protected  GenericFileExclusiveReadLockStrategy<T> exclusiveReadLockStrategy
           
protected  org.apache.commons.logging.Log log
           
 
Constructor Summary
GenericFileProcessStrategySupport()
           
 
Method Summary
 boolean begin(GenericFileOperations<T> operations, GenericFileEndpoint<T> endpoint, Exchange exchange, GenericFile<T> file)
          Called when work is about to begin on this file.
 void commit(GenericFileOperations<T> operations, GenericFileEndpoint<T> endpoint, Exchange exchange, GenericFile<T> file)
          Releases any file locks and possibly deletes or moves the file after successful processing
 GenericFileExclusiveReadLockStrategy<T> getExclusiveReadLockStrategy()
           
 void prepareOnStartup(GenericFileOperations<T> operations, GenericFileEndpoint<T> endpoint)
          Allows custom logic to be run on startup preparing the strategy, such as removing old lock files etc.
protected  GenericFile<T> renameFile(GenericFileOperations<T> operations, GenericFile<T> from, GenericFile<T> to)
           
 void rollback(GenericFileOperations<T> operations, GenericFileEndpoint<T> endpoint, Exchange exchange, GenericFile<T> file)
          Releases any file locks and possibly deletes or moves the file after unsuccessful processing
 void setExclusiveReadLockStrategy(GenericFileExclusiveReadLockStrategy<T> exclusiveReadLockStrategy)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected final transient org.apache.commons.logging.Log log

exclusiveReadLockStrategy

protected GenericFileExclusiveReadLockStrategy<T> exclusiveReadLockStrategy
Constructor Detail

GenericFileProcessStrategySupport

public GenericFileProcessStrategySupport()
Method Detail

prepareOnStartup

public void prepareOnStartup(GenericFileOperations<T> operations,
                             GenericFileEndpoint<T> endpoint)
                      throws Exception
Description copied from interface: GenericFileProcessStrategy
Allows custom logic to be run on startup preparing the strategy, such as removing old lock files etc.

Specified by:
prepareOnStartup in interface GenericFileProcessStrategy<T>
Parameters:
operations - file operations
endpoint - the endpoint
Throws:
Exception - can be thrown in case of errors which causes startup to fail

begin

public boolean begin(GenericFileOperations<T> operations,
                     GenericFileEndpoint<T> endpoint,
                     Exchange exchange,
                     GenericFile<T> file)
              throws Exception
Description copied from interface: GenericFileProcessStrategy
Called when work is about to begin on this file. This method may attempt to acquire some file lock before returning true; returning false if the file lock could not be obtained so that the file should be ignored.

Specified by:
begin in interface GenericFileProcessStrategy<T>
Parameters:
operations - file operations
endpoint - the endpoint
exchange - the exchange
file - the file
Returns:
true if the file can be processed (such as if a file lock could be obtained)
Throws:
Exception - can be thrown in case of errors

commit

public void commit(GenericFileOperations<T> operations,
                   GenericFileEndpoint<T> endpoint,
                   Exchange exchange,
                   GenericFile<T> file)
            throws Exception
Description copied from interface: GenericFileProcessStrategy
Releases any file locks and possibly deletes or moves the file after successful processing

Specified by:
commit in interface GenericFileProcessStrategy<T>
Parameters:
operations - file operations
endpoint - the endpoint
exchange - the exchange
file - the file
Throws:
Exception - can be thrown in case of errors

rollback

public void rollback(GenericFileOperations<T> operations,
                     GenericFileEndpoint<T> endpoint,
                     Exchange exchange,
                     GenericFile<T> file)
              throws Exception
Description copied from interface: GenericFileProcessStrategy
Releases any file locks and possibly deletes or moves the file after unsuccessful processing

Specified by:
rollback in interface GenericFileProcessStrategy<T>
Parameters:
operations - file operations
endpoint - the endpoint
exchange - the exchange
file - the file
Throws:
Exception - can be thrown in case of errors

getExclusiveReadLockStrategy

public GenericFileExclusiveReadLockStrategy<T> getExclusiveReadLockStrategy()

setExclusiveReadLockStrategy

public void setExclusiveReadLockStrategy(GenericFileExclusiveReadLockStrategy<T> exclusiveReadLockStrategy)

renameFile

protected GenericFile<T> renameFile(GenericFileOperations<T> operations,
                                    GenericFile<T> from,
                                    GenericFile<T> to)
                             throws IOException
Throws:
IOException


Apache CAMEL