FileDocCategorySizeDatePackage
DeferredLockManager.javaAPI DocGlassfish v2 API5263Tue May 22 16:54:34 BST 2007oracle.toplink.essentials.internal.helper

DeferredLockManager

public class DeferredLockManager extends Object
INTERNAL:

Purpose: Be used for deadlock avoidance through allowing detection and resolution.

Responsibilities:

  • Keep track of all deferred locks of each thread.
  • Keep track of all active locks of each thread..
  • Maintain the depth of the each thread.

Fields Summary
protected Vector
deferredLocks
protected Vector
activeLocks
protected int
threadDepth
protected boolean
isThreadComplete
public static boolean
SHOULD_USE_DEFERRED_LOCKS
Constructors Summary
public DeferredLockManager()
DeferredLockManager constructor comment.


            
      
        super();
        this.deferredLocks = new Vector(1);
        this.activeLocks = new Vector(1);
        this.threadDepth = 0;
        this.isThreadComplete = false;
    
Methods Summary
public voidaddActiveLock(java.lang.Object manager)
add a concurrency manager as active locks to the DLM

        getActiveLocks().addElement(manager);
    
public voidaddDeferredLock(java.lang.Object manager)
add a concurrency manager as deferred locks to the DLM

        getDeferredLocks().addElement(manager);
    
public voiddecrementDepth()
decrement the depth of the thread

        threadDepth--;
    
public java.util.VectorgetActiveLocks()
Return a set of the active locks from the DLM

        return activeLocks;
    
public java.util.VectorgetDeferredLocks()
Return a set of the deferred locks

        return deferredLocks;
    
public intgetThreadDepth()
Return the depth of the thread associated with the DLM, being used to release the lock

        return threadDepth;
    
public booleanhasDeferredLock()
Return if there are any deferred locks.

        return !getDeferredLocks().isEmpty();
    
public voidincrementDepth()
increment the depth of the thread

        threadDepth++;
    
public booleanisThreadComplete()
Return if the thread is complete

        return isThreadComplete;
    
public voidreleaseActiveLocksOnThread()
Release the active lock on the DLM

        Vector activeLocks = getActiveLocks();
        if (!activeLocks.isEmpty()) {
            for (Enumeration activeLocksEnum = activeLocks.elements();
                     activeLocksEnum.hasMoreElements();) {
                ConcurrencyManager manager = (ConcurrencyManager)activeLocksEnum.nextElement();
                manager.release();
            }
        }
        setIsThreadComplete(true);
    
public voidsetActiveLocks(java.util.Vector activeLocks)
set a set of the active locks to the DLM

        this.activeLocks = activeLocks;
    
public voidsetDeferredLocks(java.util.Vector deferredLocks)
set a set of the deferred locks to the DLM

        this.deferredLocks = deferredLocks;
    
public voidsetIsThreadComplete(boolean isThreadComplete)
set if the thread is complete in the given DLM

        this.isThreadComplete = isThreadComplete;