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

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

public class FileRenameExclusiveReadLockStrategy
extends GenericFileRenameExclusiveReadLockStrategy<File>

Acquires exclusive read lock to the given file. Will wait until the lock is granted. After granting the read lock it is released, we just want to make sure that when we start consuming the file its not currently in progress of being written by third party.

This implementation is only supported by the File component, that leverages the MarkerFileExclusiveReadLockStrategy as well, to ensure only acquiring locks on files, which is not already in progress by another process, that have marked this using the marker file.


Constructor Summary
FileRenameExclusiveReadLockStrategy()
           
 
Method Summary
 boolean acquireExclusiveReadLock(GenericFileOperations<File> operations, 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.
 
Methods inherited from class org.apache.camel.component.file.strategy.GenericFileRenameExclusiveReadLockStrategy
getTimeout, prepareOnStartup, setCheckInterval, setTimeout
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileRenameExclusiveReadLockStrategy

public FileRenameExclusiveReadLockStrategy()
Method Detail

acquireExclusiveReadLock

public boolean acquireExclusiveReadLock(GenericFileOperations<File> operations,
                                        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>
Overrides:
acquireExclusiveReadLock in class GenericFileRenameExclusiveReadLockStrategy<File>
Parameters:
operations - 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>
Overrides:
releaseExclusiveReadLock in class GenericFileRenameExclusiveReadLockStrategy<File>
Parameters:
operations - generic file operations
file - the file
exchange - the exchange
Throws:
Exception - can be thrown in case of errors


Apache CAMEL