Map cache = null;
Collection caches = null;
Iterator cacheIterator = null;
Iterator cacheKeyIterator = null;
Iterator keyIterator = null;
IEntityLock lock = null;
if ( entityType == null )
{
caches = getLockCache().values();
}
else
{
caches = new ArrayList(1);
caches.add(getLockCache(entityType));
}
cacheIterator = caches.iterator();
while ( cacheIterator.hasNext() )
{
cache = (Map) cacheIterator.next();
cacheKeyIterator = cache.keySet().iterator();
List keys = new ArrayList();
// Synchronize on the cache only while collecting its keys. There is some
// exposure here.
synchronized (cache) {
while ( cacheKeyIterator.hasNext() )
{ keys.add(cacheKeyIterator.next()); }
}
keyIterator = keys.iterator();
while ( keyIterator.hasNext() )
{
lock = getLockFromCache(keyIterator.next(), cache);
if ( ( lock != null ) &&
( (entityKey == null) || (entityKey.equals(lock.getEntityKey())) ) &&
( (lockType == null) || (lockType.intValue() == lock.getLockType()) ) &&
( (lockOwner == null) || (lockOwner.equals(lock.getLockOwner())) ) &&
( (expiration == null) || (expiration.equals(lock.getExpirationTime())) )
)
{ locks.add(lock); }
}
}
return ((IEntityLock[])locks.toArray(new IEntityLock[locks.size()]));