1 package org.jacorb.orb.portableInterceptor; 2 3 22 23 import org.omg.PortableInterceptor.*; 24 import org.omg.PortableInterceptor.ORBInitInfoPackage.*; 25 import org.omg.CORBA.Object ; 26 import org.omg.IOP.CodecFactory ; 27 28 import java.util.*; 29 30 import org.jacorb.orb.ORB; 31 32 40 41 public class ORBInitInfoImpl 42 extends org.omg.CORBA.LocalObject 43 implements ORBInitInfo 44 { 45 private int slot_count = 0; 46 private ORB orb = null; 47 48 private Hashtable named_server_interceptors = null; 49 private Vector anonymous_server_interceptors = null; 50 51 private Hashtable named_client_interceptors = null; 52 private Vector anonymous_client_interceptors = null; 53 54 private Hashtable named_ior_interceptors = null; 55 private Vector anonymous_ior_interceptors = null; 56 57 private Hashtable policy_factories = null; 58 59 private boolean valid = true; 60 61 public ORBInitInfoImpl(ORB orb) 62 { 63 this.orb = orb; 64 65 named_server_interceptors = new Hashtable(); 66 named_client_interceptors = new Hashtable(); 67 68 anonymous_server_interceptors = new Vector(); 69 anonymous_client_interceptors = new Vector(); 70 71 named_ior_interceptors = new Hashtable(); 72 anonymous_ior_interceptors = new Vector(); 73 74 policy_factories = new Hashtable(); 75 76 } 77 78 83 public ORB getORB() 84 { 85 return orb; 86 } 87 88 public void setInvalid() 89 { 90 valid = false; 91 } 92 93 97 98 private void merge(Vector target, Hashtable source) 99 { 100 Enumeration enumeration = source.elements(); 101 102 while(enumeration.hasMoreElements()) 103 target.addElement(enumeration.nextElement()); 104 } 105 106 public Vector getClientInterceptors() 107 { 108 merge(anonymous_client_interceptors, 109 named_client_interceptors); 110 111 return anonymous_client_interceptors; 112 } 113 114 public Vector getServerInterceptors() 115 { 116 merge(anonymous_server_interceptors, 117 named_server_interceptors); 118 119 return anonymous_server_interceptors; 120 } 121 122 public Vector getIORInterceptors() 123 { 124 merge(anonymous_ior_interceptors, 125 named_ior_interceptors); 126 127 return anonymous_ior_interceptors; 128 } 129 130 public Hashtable getPolicyFactories() 131 { 132 return policy_factories; 133 } 134 135 public int getSlotCount() 136 { 137 return slot_count; 138 } 139 140 public void add_client_request_interceptor(ClientRequestInterceptor interceptor) 142 throws DuplicateName 143 { 144 145 if (! valid) 146 throw new org.omg.CORBA.OBJECT_NOT_EXIST ("This ORBInitIfo is not valid anymore!"); 147 148 if (interceptor.name() == null) 149 throw new DuplicateName("The name is null!"); 150 151 if (interceptor.name().length() == 0) 152 anonymous_client_interceptors.addElement(interceptor); 153 else 154 { 155 if (named_client_interceptors.containsKey(interceptor.name())) 156 throw new DuplicateName(interceptor.name()); 157 158 named_client_interceptors.put(interceptor.name(), interceptor); 159 } 160 } 161 162 public void add_ior_interceptor(IORInterceptor interceptor) 163 throws DuplicateName 164 { 165 166 if (interceptor.name() == null) 167 throw new DuplicateName("The name is null!"); 168 169 if (interceptor.name().length() == 0) 170 anonymous_ior_interceptors.addElement(interceptor); 171 else 172 { 173 if (named_ior_interceptors.containsKey(interceptor.name())) 174 throw new DuplicateName(interceptor.name()); 175 176 named_ior_interceptors.put(interceptor.name(), interceptor); 177 } 178 } 179 180 public void add_server_request_interceptor(ServerRequestInterceptor interceptor) 181 throws DuplicateName 182 { 183 184 if (! valid) 185 throw new org.omg.CORBA.OBJECT_NOT_EXIST ("This ORBInitIfo is not valid anymore!"); 186 187 if (interceptor.name() == null) 188 throw new DuplicateName("The name is null!"); 189 190 if (interceptor.name().length() == 0) 191 anonymous_server_interceptors.addElement(interceptor); 192 else { 193 if (named_server_interceptors.containsKey(interceptor.name())) 194 throw new DuplicateName(interceptor.name()); 195 196 named_server_interceptors.put(interceptor.name(), interceptor); 197 } 198 } 199 200 public int allocate_slot_id() 201 { 202 if (! valid) 203 throw new org.omg.CORBA.OBJECT_NOT_EXIST ("This ORBInitIfo is not valid anymore!"); 204 205 return slot_count++; 206 } 207 208 public String [] arguments() 209 { 210 if (! valid) 211 throw new org.omg.CORBA.OBJECT_NOT_EXIST ("This ORBInitIfo is not valid anymore!"); 212 return orb._args ; 213 } 214 215 public CodecFactory codec_factory() 216 { 217 if (! valid) 218 throw new org.omg.CORBA.OBJECT_NOT_EXIST ("This ORBInitIfo is not valid anymore!"); 219 220 try 221 { 222 return (CodecFactory ) orb.resolve_initial_references("CodecFactory"); 223 } 224 catch (Exception e) 225 { 226 } 228 return null; 229 } 230 231 public String orb_id() 232 { 233 if (! valid) 234 throw new org.omg.CORBA.OBJECT_NOT_EXIST ("This ORBInitIfo is not valid anymore!"); 235 return orb.orb_id; 236 } 237 238 public void register_initial_reference( String id, Object obj ) 239 throws InvalidName 240 { 241 if (! valid) 242 throw new org.omg.CORBA.OBJECT_NOT_EXIST ("This ORBInitIfo is not valid anymore!"); 243 244 try 245 { 246 orb.register_initial_reference(id, obj); 247 } 248 catch(org.omg.CORBA.ORBPackage.InvalidName e) 249 { 250 throw new InvalidName(); 251 } 252 } 253 254 public void register_policy_factory(int type, PolicyFactory policy_factory) 255 { 256 if (! valid) 257 throw new org.omg.CORBA.OBJECT_NOT_EXIST ("This ORBInitIfo is not valid anymore!"); 258 259 if (policy_factory == null) 260 throw new org.omg.CORBA.BAD_PARAM ("Actual parameter policy_factory is null!"); 261 262 Integer key = new Integer (type); 263 if (policy_factories.containsKey(key)) 264 throw new org.omg.CORBA.BAD_INV_ORDER ("A PolicyFactory for type " + type + 265 " has already been registered!", 12, 266 org.omg.CORBA.CompletionStatus. 267 COMPLETED_MAYBE); 268 269 policy_factories.put(key, policy_factory); 270 } 271 272 273 public org.omg.CORBA.Object resolve_initial_references(String id) 274 throws InvalidName 275 { 276 if (! valid) 277 throw new org.omg.CORBA.OBJECT_NOT_EXIST ("This ORBInitIfo is not valid anymore!"); 278 279 try 280 { 281 return orb.resolve_initial_references(id); 282 } 283 catch(org.omg.CORBA.ORBPackage.InvalidName e) 284 { 285 throw new InvalidName(); 286 } 287 } 288 } 290 291 292 293 294 295 | Popular Tags |