1 package net.walend.somnifugi; 2 3 import java.util.Hashtable ; 4 5 import javax.naming.Context ; 6 import javax.naming.NamingException ; 7 import javax.naming.Name ; 8 import javax.naming.NamingEnumeration ; 9 import javax.naming.NameParser ; 10 import javax.naming.OperationNotSupportedException ; 11 import javax.naming.InvalidNameException ; 12 import javax.naming.CompositeName ; 13 import javax.naming.NameClassPair ; 14 import javax.naming.Binding ; 15 16 22 23 public abstract class SomniContext 24 implements Context 25 { 26 private String name; 27 28 private Hashtable <Object ,Object > environment; 29 30 SomniContext(String name,Hashtable <Object ,Object > environment) 31 { 32 this.name = name; 33 this.environment = environment; 34 } 35 36 public abstract Object lookup(String name) 37 throws NamingException ; 38 39 public Object lookup(Name name) 40 throws NamingException 41 { 42 return lookup(name.toString()); 43 } 44 45 public void bind(String name,Object obj) 46 throws NamingException 47 { 48 throw new OperationNotSupportedException ("Binding not supported."); 49 } 50 51 public void bind(Name name,Object obj) 52 throws NamingException 53 { 54 bind(name.toString(),obj); 55 } 56 57 public void rebind(String name,Object obj) 58 throws NamingException 59 { 60 throw new OperationNotSupportedException ("Rebinding not supported."); 61 } 62 63 public void rebind(Name name,Object obj) 64 throws NamingException 65 { 66 rebind(name.toString(),obj); 67 } 68 69 public void unbind(String name) 70 throws NamingException 71 { 72 throw new OperationNotSupportedException ("Unbind not supported."); 73 } 74 75 public void unbind(Name name) 76 throws NamingException 77 { 78 unbind(name.toString()); 79 } 80 81 public void rename(String oldname, String newname) 82 throws NamingException 83 { 84 throw new OperationNotSupportedException ("Rename not supported."); 85 } 86 87 public void rename(Name oldname,Name newname) 88 throws NamingException 89 { 90 rename(oldname.toString(),newname.toString()); 91 } 92 93 public NamingEnumeration <NameClassPair > list(String name) 94 throws NamingException 95 { 96 throw new OperationNotSupportedException ("List not supported."); 97 } 98 99 public NamingEnumeration <NameClassPair > list(Name name) 100 throws NamingException 101 { 102 return list(name.toString()); 103 } 104 105 public NamingEnumeration <Binding > listBindings(String name) 106 throws NamingException 107 { 108 throw new OperationNotSupportedException ("ListBindings not supported."); 109 } 110 111 public NamingEnumeration <Binding > listBindings(Name name) 112 throws NamingException 113 { 114 return listBindings(name.toString()); 115 } 116 117 public void destroySubcontext(String name) 118 throws NamingException 119 { 120 throw new OperationNotSupportedException ("Subcontexts not supported."); 121 } 122 123 public void destroySubcontext(Name name) 124 throws NamingException 125 { 126 destroySubcontext(name.toString()); 127 } 128 129 public Context createSubcontext(String name) 130 throws NamingException 131 { 132 throw new OperationNotSupportedException ("Subcontexts not supported."); 133 } 134 135 public Context createSubcontext(Name name) 136 throws NamingException 137 { 138 return createSubcontext(name.toString()); 139 } 140 141 public Object lookupLink(String name) 142 throws NamingException 143 { 144 return lookup(name); 145 } 146 147 public Object lookupLink(Name name) 148 throws NamingException 149 { 150 return lookupLink(name.toString()); 151 } 152 153 public NameParser getNameParser(String name) 154 throws NamingException 155 { 156 throw new OperationNotSupportedException ("GetNameParser not supported."); 157 } 158 159 public NameParser getNameParser(Name name) 160 throws NamingException 161 { 162 return getNameParser(name.toString()); 163 } 164 165 public String composeName(String name, String prefix) 166 throws NamingException 167 { 168 Name result = composeName(((Name ) (new CompositeName (name))), ((Name ) (new CompositeName (prefix)))); 169 return result.toString(); 170 } 171 172 public Name composeName(Name name, Name prefix) 173 throws NamingException 174 { 175 Name result = (Name )prefix.clone(); 176 result.addAll(name); 177 return result; 178 } 179 180 public Object addToEnvironment(String propName, Object propVal) 181 throws NamingException 182 { 183 return environment.put(propName, propVal); 184 } 185 186 public Object removeFromEnvironment(String propName) 187 throws NamingException 188 { 189 return environment.remove(propName); 190 } 191 192 public Hashtable <Object ,Object > getEnvironment() 193 throws NamingException 194 { 195 return environment; 196 } 197 198 public String getNameInNamespace() 199 throws NamingException 200 { 201 return name; 202 } 203 204 public void close() 205 throws NamingException 206 { 207 } 209 210 } 211 233 | Popular Tags |