1 21 package oracle.toplink.essentials.internal.helper; 23 24 import java.util.*; 25 26 39 public class DeferredLockManager { 40 protected Vector deferredLocks; 41 protected Vector activeLocks; 42 protected int threadDepth; 43 protected boolean isThreadComplete; 44 45 public static boolean SHOULD_USE_DEFERRED_LOCKS = true; 46 47 50 public DeferredLockManager() { 51 super(); 52 this.deferredLocks = new Vector(1); 53 this.activeLocks = new Vector(1); 54 this.threadDepth = 0; 55 this.isThreadComplete = false; 56 } 57 58 61 public void addActiveLock(Object manager) { 62 getActiveLocks().addElement(manager); 63 } 64 65 68 public void addDeferredLock(Object manager) { 69 getDeferredLocks().addElement(manager); 70 } 71 72 75 public void decrementDepth() { 76 threadDepth--; 77 } 78 79 82 public Vector getActiveLocks() { 83 return activeLocks; 84 } 85 86 89 public Vector getDeferredLocks() { 90 return deferredLocks; 91 } 92 93 96 public int getThreadDepth() { 97 return threadDepth; 98 } 99 100 103 public boolean hasDeferredLock() { 104 return !getDeferredLocks().isEmpty(); 105 } 106 107 110 public void incrementDepth() { 111 threadDepth++; 112 } 113 114 117 public boolean isThreadComplete() { 118 return isThreadComplete; 119 } 120 121 124 public void releaseActiveLocksOnThread() { 125 Vector activeLocks = getActiveLocks(); 126 if (!activeLocks.isEmpty()) { 127 for (Enumeration activeLocksEnum = activeLocks.elements(); 128 activeLocksEnum.hasMoreElements();) { 129 ConcurrencyManager manager = (ConcurrencyManager)activeLocksEnum.nextElement(); 130 manager.release(); 131 } 132 } 133 setIsThreadComplete(true); 134 } 135 136 139 public void setActiveLocks(Vector activeLocks) { 140 this.activeLocks = activeLocks; 141 } 142 143 146 public void setDeferredLocks(Vector deferredLocks) { 147 this.deferredLocks = deferredLocks; 148 } 149 150 153 public void setIsThreadComplete(boolean isThreadComplete) { 154 this.isThreadComplete = isThreadComplete; 155 } 156 } 157 | Popular Tags |