1 package org.sapia.regis.remote; 2 3 import org.sapia.regis.RegisSession; 4 5 public class RemoteSessions { 6 7 private static ThreadLocal sessions = new ThreadLocal (); 8 9 public static RegisSession get(){ 10 if(sessions.get() == null){ 11 throw new IllegalStateException ("Server thread not registered with session"); 12 } 13 return (RegisSession)sessions.get(); 14 } 15 16 public static void join(RegisSession session){ 17 sessions.set(session); 18 } 19 20 public static void close(){ 21 if(sessions.get() != null){ 22 ((RegisSession)sessions.get()).close(); 23 sessions.set(null); 24 } 25 } 26 } 27 | Popular Tags |