1 45 package org.openejb.core.ivm; 46 47 import org.openejb.util.FastThreadLocal; 48 49 117 public class IntraVmCopyMonitor { 118 119 private static FastThreadLocal threadStorage = new FastThreadLocal(); 120 121 125 boolean intraVmCopyOperation = false; 126 127 131 boolean statefulPassivationOperation = false; 132 133 135 IntraVmCopyMonitor(){} 136 137 public static boolean exists(){ 138 return (threadStorage.get()!=null); 139 } 140 141 146 public static void release( ){ 147 threadStorage.set(null); 148 } 149 150 151 159 static IntraVmCopyMonitor getMonitor( ){ 160 IntraVmCopyMonitor monitor = (IntraVmCopyMonitor)threadStorage.get(); 161 if(monitor==null){ 162 monitor = new IntraVmCopyMonitor(); 163 threadStorage.set(monitor); 164 } 165 return monitor; 166 } 167 168 175 public static void preCopyOperation(){ 176 IntraVmCopyMonitor monitor = getMonitor(); 177 monitor.intraVmCopyOperation = true; 178 } 179 186 public static void postCopyOperation(){ 187 IntraVmCopyMonitor monitor = getMonitor(); 188 monitor.intraVmCopyOperation = false; 189 } 190 197 public static void prePassivationOperation(){ 198 IntraVmCopyMonitor monitor = getMonitor(); 199 monitor.statefulPassivationOperation = true; 200 } 201 208 public static void postPassivationOperation(){ 209 IntraVmCopyMonitor monitor = getMonitor(); 210 monitor.statefulPassivationOperation = false; 211 } 212 218 public static boolean isIntraVmCopyOperation(){ 219 IntraVmCopyMonitor monitor = getMonitor(); 220 if(monitor.intraVmCopyOperation) 221 return true; 222 else 223 return false; 224 } 225 231 public static boolean isStatefulPassivationOperation(){ 232 IntraVmCopyMonitor monitor = getMonitor(); 233 if(monitor.statefulPassivationOperation) 234 return true; 235 else 236 return false; 237 } 238 } 239 | Popular Tags |