1 29 30 package com.caucho.naming.burlap; 31 32 import com.caucho.burlap.client.BurlapProxyFactory; 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 burlapURLContextFactory implements ObjectFactory { 47 private static L10N L = new L10N(burlapURLContextFactory.class); 48 private static Logger dbg = Log.open(burlapURLContextFactory.class); 49 50 private BurlapProxyFactory _proxyFactory = new BurlapProxyFactory(); 51 private BurlapModel _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 BurlapModel model = _model; 64 65 if (model == null) { 66 model = new BurlapModel(); 67 _model = model; 68 } 69 70 return new BurlapContextImpl(model, env); 71 } 72 73 String url = (String ) obj; 74 75 if (url.startsWith("burlap:")) 76 url = url.substring("burlap:".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 |