org.entityfs.util.itr
Class PessimisticLockingDepthLastIterator

java.lang.Object
  extended by org.entityfs.util.itr.AbstractLockingIterator
      extended by org.entityfs.util.itr.AbstractPessimisticLockingIterator
          extended by org.entityfs.util.itr.PessimisticLockingDepthLastIterator
All Implemented Interfaces:
Iterator<EntityView>, DepthLastIterator<EntityView>, LockingDepthLastIterator<EntityView>, LockingIterator<EntityView>

public final class PessimisticLockingDepthLastIterator
extends AbstractPessimisticLockingIterator
implements LockingDepthLastIterator<EntityView>

This is a depth-last iterator (i.e. a breadth-first iterator) that will acquire locks for all returned entities pessimistically. Locks for all entities that will be returned are acquired (depth last) the first time next or hasNext is called.

Use AbstractLockingIterator.unlock(EntityView) and/or AbstractLockingIterator.unlockAll() to unlock the returned entities. Always call AbstractLockingIterator.unlockAll() if the aborting the iteration before all entities have been returned from the iterator or if using a filter for filtering returned entities. See LockingIterator.

This class should have been named PessimisticLockingBreadthFirstIterator...

EntityFS iterators are not thread safe. Don't use them concurrently from several threads without synchronizing access to them.

Since:
1.0
Author:
Karl Gustafsson
See Also:
OptimisticLockingDepthLastIterator, PessimisticLockingDepthLastIterator

Constructor Summary
PessimisticLockingDepthLastIterator(DirectoryView dv)
          Create a pessimistic depth last iterator on the directory.
PessimisticLockingDepthLastIterator(DirectoryView dv, boolean writeLock)
          Create a pessimistic depth last iterator on the directory.
PessimisticLockingDepthLastIterator(DirectoryView dv, boolean writeLock, Filter<? super EntityView> filter)
          Create a pessimistic depth last iterator on the directory.
 
Method Summary
 
Methods inherited from class org.entityfs.util.itr.AbstractPessimisticLockingIterator
hasNext, next, remove
 
Methods inherited from class org.entityfs.util.itr.AbstractLockingIterator
assertNotUnlocked, lock, unlock, unlockAll
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.entityfs.util.itr.LockingIterator
unlock, unlockAll
 
Methods inherited from interface java.util.Iterator
hasNext, next, remove
 

Constructor Detail

PessimisticLockingDepthLastIterator

public PessimisticLockingDepthLastIterator(DirectoryView dv)
Create a pessimistic depth last iterator on the directory. The directory itself will be returned as the first entity from the iterator. All returned entities are locked for reading.

Parameters:
dv - The directory.

PessimisticLockingDepthLastIterator

public PessimisticLockingDepthLastIterator(DirectoryView dv,
                                           boolean writeLock)
Create a pessimistic depth last iterator on the directory. The directory itself will be returned as the first entity from the iterator.

Parameters:
dv - The directory.
writeLock - If true, all returned entities are locked for writing. If false, all returned entities are locked for reading.

PessimisticLockingDepthLastIterator

public PessimisticLockingDepthLastIterator(DirectoryView dv,
                                           boolean writeLock,
                                           Filter<? super EntityView> filter)
Create a pessimistic depth last iterator on the directory. Only entities that pass the supplied filter will be returned from the iterator. The directory itself will be returned as the first entity from the iterator if it passes the filter.

Parameters:
dv - The directory.
writeLock - If true, all returned entities are locked for writing. If false, all returned entities are locked for reading.
filter - Only entities that pass this filter are returned from the iterator.