1 15 package org.apache.hivemind.internal.ser; 16 17 import java.lang.ref.WeakReference ; 18 19 import org.apache.hivemind.ApplicationRuntimeException; 20 21 29 public class ServiceSerializationHelper 30 { 31 private static final ThreadLocal _threadLocal = new ThreadLocal (); 32 33 39 public static ServiceSerializationSupport getServiceSerializationSupport() 40 { 41 ServiceSerializationSupport result = null; 42 43 WeakReference reference = (WeakReference ) _threadLocal.get(); 44 if (reference != null) 45 result = (ServiceSerializationSupport) reference.get(); 46 47 if (result == null) 48 throw new ApplicationRuntimeException(SerMessages.noSupportSet()); 49 50 return result; 51 } 52 53 57 58 public static void setServiceSerializationSupport( 59 ServiceSerializationSupport serviceSerializationSupport) 60 { 61 WeakReference reference = new WeakReference (serviceSerializationSupport); 62 63 _threadLocal.set(reference); 64 } 65 } | Popular Tags |