org.apache.camel.component.file.strategy
Class MarkerFileExclusiveReadLockStrategy

java.lang.Object
  extended by org.apache.camel.component.file.strategy.MarkerFileExclusiveReadLockStrategy
All Implemented Interfaces:
GenericFileExclusiveReadLockStrategy<File>

public class MarkerFileExclusiveReadLockStrategy
extends Object
implements GenericFileExclusiveReadLockStrategy<File>

Acquires read lock to the given file using a marker file so other Camel consumers wont acquire the same file. This is the default behavior in Camel 1.x.


Constructor Summary
MarkerFileExclusiveReadLockStrategy()
           
 
Method Summary
 boolean acquireExclusiveReadLock(GenericFileOperations<File> fileGenericFileOperations, GenericFile<File> file, Exchange exchange)
          Acquires exclusive read lock to the file.
 void releaseExclusiveReadLock(GenericFileOperations<File> operations, GenericFile<File> file, Exchange exchange)
          Releases the exclusive read lock granted by the acquireExclusiveReadLock method.
 void setTimeout(long timeout)
          Sets an optional timeout period.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MarkerFileExclusiveReadLockStrategy

public MarkerFileExclusiveReadLockStrategy()
Method Detail

acquireExclusiveReadLock

public boolean acquireExclusiveReadLock(GenericFileOperations<File> fileGenericFileOperations,
                                        GenericFile<File> file,
                                        Exchange exchange)
                                 throws Exception
Description copied from interface: GenericFileExclusiveReadLockStrategy
Acquires exclusive read lock to the file.

Specified by:
acquireExclusiveReadLock in interface GenericFileExclusiveReadLockStrategy<File>
Parameters:
fileGenericFileOperations - generic file operations
file - the file
exchange - the exchange
Returns:
true if read lock was acquired. If false Camel will skip the file and try it on the next poll
Throws:
Exception - can be thrown in case of errors

releaseExclusiveReadLock

public void releaseExclusiveReadLock(GenericFileOperations<File> operations,
                                     GenericFile<File> file,
                                     Exchange exchange)
                              throws Exception
Description copied from interface: GenericFileExclusiveReadLockStrategy
Releases the exclusive read lock granted by the acquireExclusiveReadLock method.

Specified by:
releaseExclusiveReadLock in interface GenericFileExclusiveReadLockStrategy<File>
Parameters:
operations - generic file operations
file - the file
exchange - the exchange
Throws:
Exception - can be thrown in case of errors

setTimeout

public void setTimeout(long timeout)
Description copied from interface: GenericFileExclusiveReadLockStrategy
Sets an optional timeout period.

If the readlock could not be granted within the timeperiod then the wait is stopped and the acquireExclusiveReadLock method returns false.

Specified by:
setTimeout in interface GenericFileExclusiveReadLockStrategy<File>
Parameters:
timeout - period in millis


Apache CAMEL