1 29 30 package com.caucho.naming.hessian; 31 32 import com.caucho.hessian.client.HessianProxyFactory; 33 import com.caucho.log.Log; 34 import com.caucho.util.L10N; 35 36 import javax.naming.Context ; 37 import javax.naming.Name ; 38 import javax.naming.NamingException ; 39 import javax.naming.spi.ObjectFactory ; 40 import java.util.Hashtable ; 41 import java.util.logging.Logger ; 42 43 46 public class hessianURLContextFactory implements ObjectFactory { 47 private static L10N L = new L10N(hessianURLContextFactory.class); 48 private static Logger dbg = Log.open(hessianURLContextFactory.class); 49 50 private HessianProxyFactory _proxyFactory = new HessianProxyFactory(); 51 private HessianModel _model; 52 53 56 public Object getObjectInstance(Object obj, 57 Name name, 58 Context parentContext, 59 Hashtable <?,?> env) 60 throws NamingException 61 { 62 if (obj == null) { 63 HessianModel model = _model; 64 65 if (model == null) { 66 model = new HessianModel(); 67 _model = model; 68 } 69 70 return new HessianContextImpl(model, env); 71 } 72 73 String url = (String ) obj; 74 75 if (url.startsWith("hessian:")) 76 url = url.substring("hessian:".length()); 77 78 if (url.startsWith("//")) 79 url = "http:" + url; 80 81 try { 82 return _proxyFactory.create(url); 83 } catch (RuntimeException e) { 84 throw e; 85 } catch (Exception e) { 86 NamingException exn = new NamingException (e.toString()); 87 exn.initCause(e); 88 throw exn; 89 } 90 } 91 } 92 | Popular Tags |