1 18 package org.objectweb.speedo.runtime.jca; 19 20 import javax.naming.spi.InitialContextFactory ; 21 import javax.naming.Context ; 22 import javax.naming.NamingException ; 23 import javax.naming.Name ; 24 import javax.naming.NamingEnumeration ; 25 import javax.naming.NameParser ; 26 import java.util.Hashtable ; 27 28 32 public class SimpleNamingManager implements InitialContextFactory { 33 34 private static SimpleContext ictx; 35 36 public SimpleNamingManager() { 37 } 38 39 public Context getInitialContext(Hashtable environment) 40 throws NamingException { 41 if (ictx == null) { 42 ictx = new SimpleContext(environment); 43 } else { 44 ictx.context.putAll(environment); 45 } 46 return ictx; 47 } 48 49 class SimpleContext implements Context { 50 51 public Hashtable context; 52 53 public SimpleContext(Hashtable context) { 54 this.context = context; 55 } 56 57 private String name2String(Name n) { 58 StringBuffer sb = new StringBuffer (""); 59 String sep = ""; 60 for(int i=0; i<n.size(); i++) { 61 sb.append(sep); 62 sep = "."; 63 sb.append(n.get(i)); 64 } 65 return sb.toString(); 66 } 67 68 71 public Object lookup(Name name) throws NamingException { 72 return context.get(name2String(name)); 73 } 74 75 public Object lookup(String name) throws NamingException { 76 return context.get(name); 77 } 78 79 public void bind(Name name, Object obj) throws NamingException { 80 String n = name2String(name); 81 if (context.containsKey(n)) { 82 throw new NamingException (n + " already bound: " + context.get(n)); 83 } else { 84 context.put(n, obj); 85 } 86 } 87 88 public void bind(String n, Object obj) throws NamingException { 89 if (context.containsKey(n)) { 90 throw new NamingException (n + " already bound: " + context.get(n)); 91 } else { 92 context.put(n, obj); 93 } 94 } 95 96 public void rebind(Name name, Object obj) throws NamingException { 97 context.put(name2String(name), obj); 98 } 99 100 public void rebind(String n, Object obj) throws NamingException { 101 context.put(n, obj); 102 } 103 104 public void unbind(Name name) throws NamingException { 105 context.remove(name2String(name)); 106 } 107 108 public void unbind(String name) throws NamingException { 109 context.remove(name); 110 } 111 112 public void rename(Name oldName, Name newName) throws NamingException { 113 bind(newName, lookup(oldName)); 114 unbind(oldName); 115 } 116 117 public void rename(String oldName, String newName) throws NamingException { 118 bind(newName, lookup(oldName)); 119 unbind(oldName); 120 } 121 122 public NamingEnumeration list(Name name) throws NamingException { 123 return null; 124 } 125 126 public NamingEnumeration list(String name) throws NamingException { 127 return null; 128 } 129 130 public NamingEnumeration listBindings(Name name) throws NamingException { 131 return null; 132 } 133 134 public NamingEnumeration listBindings(String name) throws NamingException { 135 return null; 136 } 137 138 public void destroySubcontext(Name name) throws NamingException { 139 } 140 141 public void destroySubcontext(String name) throws NamingException { 142 } 143 144 public Context createSubcontext(Name name) throws NamingException { 145 return null; 146 } 147 148 public Context createSubcontext(String name) throws NamingException { 149 return null; 150 } 151 152 public Object lookupLink(Name name) throws NamingException { 153 return null; 154 } 155 156 public Object lookupLink(String name) throws NamingException { 157 return null; 158 } 159 160 public NameParser getNameParser(Name name) throws NamingException { 161 return null; 162 } 163 164 public NameParser getNameParser(String name) throws NamingException { 165 return null; 166 } 167 168 public Name composeName(Name name, Name prefix) throws NamingException { 169 return null; 170 } 171 172 public String composeName(String name, String prefix) 173 throws NamingException { 174 return null; 175 } 176 177 public Object addToEnvironment(String propName, Object propVal) 178 throws NamingException { 179 return null; 180 } 181 182 public Object removeFromEnvironment(String propName) 183 throws NamingException { 184 return null; 185 } 186 187 public Hashtable getEnvironment() throws NamingException { 188 return context; 189 } 190 191 public void close() throws NamingException { 192 } 193 194 public String getNameInNamespace() throws NamingException { 195 return null; 196 } 197 } 198 } 199 | Popular Tags |