1 28 29 package com.caucho.ejb.naming; 30 31 import java.io.*; 32 import java.util.*; 33 34 import javax.naming.*; 35 import javax.ejb.*; 36 37 import com.caucho.util.*; 38 import com.caucho.vfs.*; 39 40 import com.caucho.naming.*; 41 42 import com.caucho.ejb.EnvServerManager; 43 import com.caucho.ejb.AbstractContext; 44 import com.caucho.ejb.AbstractServer; 45 46 import com.caucho.ejb.protocol.EjbProtocolManager; 47 48 51 public class LocalModel extends AbstractModel { 52 protected EjbProtocolManager _protocolManager; 53 protected String _prefix; 54 55 58 public LocalModel(EjbProtocolManager protocolManager) 59 { 60 _protocolManager = protocolManager; 61 _prefix = ""; 62 } 63 64 70 public LocalModel(EjbProtocolManager protocolManager, String prefix) 71 { 72 _protocolManager = protocolManager; 73 74 if (! prefix.endsWith("/")) 75 prefix = prefix + "/"; 76 77 if (! prefix.startsWith("/")) 78 prefix = "/" + prefix; 79 80 _prefix = prefix; 81 } 82 83 86 protected AbstractModel create() 87 { 88 return new LocalModel(_protocolManager, _prefix); 89 } 90 91 public EnvServerManager getServerContainer() 92 { 93 return _protocolManager.getServerManager(); 94 } 95 96 104 public Object lookup(String name) 105 throws NamingException 106 { 107 try { 108 110 AbstractServer server = _protocolManager.getServerByEJBName(_prefix + name); 111 112 if (server != null) 113 return server.getEJBLocalHome(); 114 else { 115 String newPrefix = _prefix + name + "/"; 116 117 ArrayList list = _protocolManager.getLocalChildren(newPrefix); 118 119 if (list != null && list.size() > 0) 120 return new LocalModel(_protocolManager, newPrefix); 121 122 if (newPrefix.equals("caucho-ejb-admin/")) 123 return _protocolManager.getServerManager().getAdmin(); 124 125 return null; 126 } 127 } catch (Exception e) { 128 throw new NamingExceptionWrapper(e); 129 } 130 } 131 132 135 public void bind(String name, Object value) 136 throws NamingException 137 { 138 throw new UnsupportedOperationException(); 139 } 140 141 144 public void unbind(String name) 145 throws NamingException 146 { 147 throw new UnsupportedOperationException(); 148 } 149 150 153 public void destroySubcontext(String name) 154 throws NamingException 155 { 156 throw new UnsupportedOperationException(); 157 } 158 159 162 public List list() 163 { 164 ArrayList list = _protocolManager.getLocalChildren(_prefix); 165 166 return list; 167 } 168 169 public AbstractModel createSubcontext(String name) 170 throws NamingException 171 { 172 throw new UnsupportedOperationException(); 173 } 174 175 public String toString() 176 { 177 return "[LocalModel " + _prefix + "]"; 178 } 179 } 180 | Popular Tags |