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