public class LockHandler
extends java.lang.Object
 boolean bTryAgain = true;
 while (bTryAgain) {
     bTryAgain = false;
     try {
         LockHandler.withLock(lockCount,session,md5,critical);
     } catch (DeadLockException e) {
         e.checkRaise();
         bTryAgain = true;
     }
 }
 
 
 The critical parameter is an instance of the Callable interface.
 it is perfectly possible that inside the Callable method a nested call to
 LockHandler is performed. In that case, take care of using the same lockCount parameter
 to keep track of the nested calls and recognize how many calls to checkRaise() shall
 be performed.| Constructor and Description | 
|---|
| LockHandler() | 
| Modifier and Type | Method and Description | 
|---|---|
| static <T> T | withLock(java.lang.Integer[] lockCount,
        org.hibernate.Session session,
        java.lang.String md5,
        java.util.concurrent.Callable<T> critical)Obtains exclusive access to md5 and executes the
 critical block of code | 
public static <T> T withLock(java.lang.Integer[] lockCount,
                             org.hibernate.Session session,
                             java.lang.String md5,
                             java.util.concurrent.Callable<T> critical)
                      throws DeadLockException
lockCount - is an array of a single integer that will be 
   increased by one on each nested call and decreased by one
   on each termination. It serves to properly handle DeadLockExceptionSession - is used to obtain a connection to the databasemd5 - this is an MD5 string that identifies the resource
   to be used as lock token. Two JVMs trying to obtain access to
   the same resource shall produce the same MD5the - critical section to be executedDeadLockException - in case this JVM and other JVM have
   tokens that will produce a deadlock if md5 is obtained by
   this processCopyright 2006-2015 Reporting Standard S.L., C/ Torrecilla del Puerto 1, 28043, Madrid, Espaņa