org.entityfs.util.itr
Interface LockingIterator<T extends EntityView>

All Superinterfaces:
Iterator<T>
All Known Subinterfaces:
LockingDepthFirstIterator<T>, LockingDepthLastIterator<T>
All Known Implementing Classes:
AbstractNoLockingIterator, AbstractPessimisticLockingIterator, NoLockingDepthFirstIterator, NoLockingDepthLastIterator, OptimisticLockingDepthLastIterator, PessimisticLockingDepthFirstIterator, PessimisticLockingDepthLastIterator

public interface LockingIterator<T extends EntityView>
extends Iterator<T>

This interface defines a locking iterator, i.e. an iterator that will lock the entities returned. Different implementations use different locking strategies.

Clients are responsible for unlocking the entities returned from this iterator, either by calling unlock(EntityView) for each entity, or unlockAll() after iterating. (Or a combination of the two.)

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

Method Summary
 void unlock(T ent)
          Unlock the entity.
 void unlockAll()
          Unlock all entities that this iterator locked.
 
Methods inherited from interface java.util.Iterator
hasNext, next, remove
 

Method Detail

unlock

void unlock(T ent)
            throws EntityNotFoundException
Unlock the entity.

Parameters:
ent - The entity.
Throws:
EntityNotFoundException - If the iterator does not have a lock for the entity.

unlockAll

void unlockAll()
Unlock all entities that this iterator locked. Either call this when the iterator is done or unlock each returned entity manually.