1 8 9 package mx4j.tools.remote.caucho; 10 11 import java.lang.reflect.Method ; 12 13 import mx4j.tools.remote.http.HTTPService; 14 15 18 public class CauchoService extends HTTPService 19 { 20 static final String CONNECTION_ID_HEADER_NAME = "connectionContext"; 21 22 private static ThreadLocal connectionContext = new ThreadLocal (); 23 24 private final String protocol; 25 26 public CauchoService(String protocol) 27 { 28 this.protocol = protocol; 29 } 30 31 protected String getProtocol() 32 { 33 return protocol; 34 } 35 36 protected String findRequestURL() 37 { 38 ConnectionContext context = (ConnectionContext)connectionContext.get(); 39 return context == null ? null : context.url; 40 } 41 42 protected String findConnectionId() 43 { 44 ConnectionContext context = (ConnectionContext)connectionContext.get(); 45 return context == null ? null : context.connectionId; 46 } 47 48 static void setConnectionContext(String url, String connectionId) 49 { 50 connectionContext.set(new ConnectionContext(url, connectionId)); 51 } 52 53 static void resetConnectionContext() 54 { 55 connectionContext.set(null); 56 } 57 58 static String mangleMethodName(Method method) 59 { 60 return method.getName() + "__" + method.getParameterTypes().length; 61 } 62 63 private static class ConnectionContext 64 { 65 private String url; 66 private String connectionId; 67 68 private ConnectionContext(String url, String connectionId) 69 { 70 this.url = url; 71 this.connectionId = connectionId; 72 } 73 } 74 } 75 | Popular Tags |