1 7 8 package javax.naming.spi; 9 10 import java.util.Hashtable ; 11 import javax.naming.*; 12 13 21 22 class ContinuationContext implements Context, Resolver { 23 protected CannotProceedException cpe; 24 protected Hashtable env; 25 protected Context contCtx = null; 26 27 protected ContinuationContext(CannotProceedException cpe, 28 Hashtable env) { 29 this.cpe = cpe; 30 this.env = env; 31 } 32 33 protected Context getTargetContext() throws NamingException { 34 if (contCtx == null) { 35 if (cpe.getResolvedObj() == null) 36 throw (NamingException)cpe.fillInStackTrace(); 37 38 contCtx = NamingManager.getContext(cpe.getResolvedObj(), 39 cpe.getAltName(), 40 cpe.getAltNameCtx(), 41 env); 42 if (contCtx == null) 43 throw (NamingException)cpe.fillInStackTrace(); 44 } 45 return contCtx; 46 } 47 48 public Object lookup(Name name) throws NamingException { 49 Context ctx = getTargetContext(); 50 return ctx.lookup(name); 51 } 52 53 public Object lookup(String name) throws NamingException { 54 Context ctx = getTargetContext(); 55 return ctx.lookup(name); 56 } 57 58 public void bind(Name name, Object newObj) throws NamingException { 59 Context ctx = getTargetContext(); 60 ctx.bind(name, newObj); 61 } 62 63 public void bind(String name, Object newObj) throws NamingException { 64 Context ctx = getTargetContext(); 65 ctx.bind(name, newObj); 66 } 67 68 public void rebind(Name name, Object newObj) throws NamingException { 69 Context ctx = getTargetContext(); 70 ctx.rebind(name, newObj); 71 } 72 public void rebind(String name, Object newObj) throws NamingException { 73 Context ctx = getTargetContext(); 74 ctx.rebind(name, newObj); 75 } 76 77 public void unbind(Name name) throws NamingException { 78 Context ctx = getTargetContext(); 79 ctx.unbind(name); 80 } 81 public void unbind(String name) throws NamingException { 82 Context ctx = getTargetContext(); 83 ctx.unbind(name); 84 } 85 86 public void rename(Name name, Name newName) throws NamingException { 87 Context ctx = getTargetContext(); 88 ctx.rename(name, newName); 89 } 90 public void rename(String name, String newName) throws NamingException { 91 Context ctx = getTargetContext(); 92 ctx.rename(name, newName); 93 } 94 95 public NamingEnumeration list(Name name) throws NamingException { 96 Context ctx = getTargetContext(); 97 return ctx.list(name); 98 } 99 public NamingEnumeration list(String name) throws NamingException { 100 Context ctx = getTargetContext(); 101 return ctx.list(name); 102 } 103 104 105 public NamingEnumeration listBindings(Name name) 106 throws NamingException 107 { 108 Context ctx = getTargetContext(); 109 return ctx.listBindings(name); 110 } 111 112 public NamingEnumeration listBindings(String name) throws NamingException { 113 Context ctx = getTargetContext(); 114 return ctx.listBindings(name); 115 } 116 117 public void destroySubcontext(Name name) throws NamingException { 118 Context ctx = getTargetContext(); 119 ctx.destroySubcontext(name); 120 } 121 public void destroySubcontext(String name) throws NamingException { 122 Context ctx = getTargetContext(); 123 ctx.destroySubcontext(name); 124 } 125 126 public Context createSubcontext(Name name) throws NamingException { 127 Context ctx = getTargetContext(); 128 return ctx.createSubcontext(name); 129 } 130 public Context createSubcontext(String name) throws NamingException { 131 Context ctx = getTargetContext(); 132 return ctx.createSubcontext(name); 133 } 134 135 public Object lookupLink(Name name) throws NamingException { 136 Context ctx = getTargetContext(); 137 return ctx.lookupLink(name); 138 } 139 public Object lookupLink(String name) throws NamingException { 140 Context ctx = getTargetContext(); 141 return ctx.lookupLink(name); 142 } 143 144 public NameParser getNameParser(Name name) throws NamingException { 145 Context ctx = getTargetContext(); 146 return ctx.getNameParser(name); 147 } 148 149 public NameParser getNameParser(String name) throws NamingException { 150 Context ctx = getTargetContext(); 151 return ctx.getNameParser(name); 152 } 153 154 public Name composeName(Name name, Name prefix) 155 throws NamingException 156 { 157 Context ctx = getTargetContext(); 158 return ctx.composeName(name, prefix); 159 } 160 161 public String composeName(String name, String prefix) 162 throws NamingException { 163 Context ctx = getTargetContext(); 164 return ctx.composeName(name, prefix); 165 } 166 167 public Object addToEnvironment(String propName, Object value) 168 throws NamingException { 169 Context ctx = getTargetContext(); 170 return ctx.addToEnvironment(propName, value); 171 } 172 173 public Object removeFromEnvironment(String propName) 174 throws NamingException { 175 Context ctx = getTargetContext(); 176 return ctx.removeFromEnvironment(propName); 177 } 178 179 public Hashtable getEnvironment() throws NamingException { 180 Context ctx = getTargetContext(); 181 return ctx.getEnvironment(); 182 } 183 184 public String getNameInNamespace() throws NamingException { 185 Context ctx = getTargetContext(); 186 return ctx.getNameInNamespace(); 187 } 188 189 public ResolveResult 190 resolveToClass(Name name, Class <? extends Context> contextType) 191 throws NamingException 192 { 193 if (cpe.getResolvedObj() == null) 194 throw (NamingException)cpe.fillInStackTrace(); 195 196 Resolver res = NamingManager.getResolver(cpe.getResolvedObj(), 197 cpe.getAltName(), 198 cpe.getAltNameCtx(), 199 env); 200 if (res == null) 201 throw (NamingException)cpe.fillInStackTrace(); 202 return res.resolveToClass(name, contextType); 203 } 204 205 public ResolveResult 206 resolveToClass(String name, Class <? extends Context> contextType) 207 throws NamingException 208 { 209 if (cpe.getResolvedObj() == null) 210 throw (NamingException)cpe.fillInStackTrace(); 211 212 Resolver res = NamingManager.getResolver(cpe.getResolvedObj(), 213 cpe.getAltName(), 214 cpe.getAltNameCtx(), 215 env); 216 if (res == null) 217 throw (NamingException)cpe.fillInStackTrace(); 218 return res.resolveToClass(name, contextType); 219 } 220 221 public void close() throws NamingException { 222 cpe = null; 223 env = null; 224 if (contCtx != null) { 225 contCtx.close(); 226 contCtx = null; 227 } 228 } 229 } 230 | Popular Tags |