1 53 package org.bsf.remoting.http; 54 55 import org.bsf.remoting.ServiceFactory; 56 import org.bsf.remoting.EJBDefinition; 57 58 import java.lang.reflect.Proxy ; 59 import java.util.Hashtable ; 60 import java.util.Map ; 61 62 63 68 public class HttpServiceFactory implements ServiceFactory { 69 70 private static Map _serviceCache = new Hashtable (); 71 72 73 public HttpServiceFactory() { 74 super(); 75 } 76 77 public HttpServiceFactory(String host, int port, String serverContext) { 78 this(null, host, port, serverContext); 79 } 80 81 public HttpServiceFactory(String protocole, String host, int port, String serverContext) { 82 super(); 83 this.setProtocol(protocole); 84 this.setHost(host); 85 this.setPort(port); 86 this.setServerContext(serverContext); 87 } 88 89 93 public Object getService(EJBDefinition p_service) { 94 95 HttpServiceInvocationHandler service = null; 96 Object dynamicProxy = null; 97 98 dynamicProxy = _serviceCache.get(p_service); 99 if (dynamicProxy == null) { 100 service = new HttpServiceInvocationHandler(p_service); 101 dynamicProxy = Proxy.newProxyInstance(HttpServiceInvocationHandler.class.getClassLoader(), 102 new Class []{p_service.getRemoteClass()}, service); 103 _serviceCache.put(p_service, dynamicProxy); 104 } 105 return dynamicProxy; 106 } 107 108 public void setPort(int port) { 109 HttpSessionClient.getInstance().setPort(port); 110 } 111 112 public void setHost(String host) { 113 HttpSessionClient.getInstance().setHost(host); 114 } 115 116 public void setProtocol(String protocole){ 117 HttpSessionClient.getInstance().setProtocol(protocole); 118 } 119 120 121 125 public void setServerFile(String file) { 126 HttpSessionClient.getInstance().setServerFile(file); 127 } 128 129 135 public void setServerContext(String context){ 136 HttpSessionClient.getInstance().setContext(context); 137 138 } 139 140 public void setThreadCount(int count) { 141 HttpSessionClient.getInstance().setThreadCount(count); 142 } 143 144 public void setLogin(String login) { 145 HttpSessionClient.getInstance().setLogin(login); 146 } 147 148 public void setPassword(String password){ 149 HttpSessionClient.getInstance().setPassword(password); 150 } 151 } | Popular Tags |