1 7 8 package com.sun.corba.se.impl.interceptors; 9 10 import org.omg.CORBA.BAD_PARAM ; 11 import org.omg.CORBA.BAD_INV_ORDER ; 12 import org.omg.CORBA.CompletionStatus ; 13 import org.omg.CORBA.NO_IMPLEMENT ; 14 import org.omg.CORBA.OBJECT_NOT_EXIST ; 15 import org.omg.CORBA.LocalObject ; 16 import org.omg.CORBA.Policy ; 17 import org.omg.CORBA.PolicyError ; 18 import org.omg.IOP.CodecFactory ; 19 import org.omg.PortableInterceptor.ORBInitInfo ; 20 import org.omg.PortableInterceptor.ClientRequestInterceptor ; 21 import org.omg.PortableInterceptor.IORInterceptor ; 22 import org.omg.PortableInterceptor.PolicyFactory ; 23 import org.omg.PortableInterceptor.ServerRequestInterceptor ; 24 import org.omg.PortableInterceptor.ORBInitInfoPackage.DuplicateName ; 25 import org.omg.PortableInterceptor.ORBInitInfoPackage.InvalidName ; 26 27 import com.sun.corba.se.spi.orb.ORB; 28 import com.sun.corba.se.spi.legacy.interceptor.ORBInitInfoExt ; 29 import com.sun.corba.se.spi.logging.CORBALogDomains; 30 31 import com.sun.corba.se.impl.orbutil.ORBUtility; 32 33 import com.sun.corba.se.impl.logging.InterceptorsSystemException; 34 import com.sun.corba.se.impl.logging.ORBUtilSystemException; 35 import com.sun.corba.se.impl.logging.OMGSystemException; 36 37 41 public final class ORBInitInfoImpl 42 extends org.omg.CORBA.LocalObject 43 implements ORBInitInfo , ORBInitInfoExt 44 { 45 private ORB orb; 47 48 private InterceptorsSystemException wrapper ; 49 private ORBUtilSystemException orbutilWrapper ; 50 private OMGSystemException omgWrapper ; 51 52 private String [] args; 54 55 private String orbId; 57 58 private CodecFactory codecFactory; 60 61 private int stage = STAGE_PRE_INIT; 63 64 public static final int STAGE_PRE_INIT = 0; 66 67 public static final int STAGE_POST_INIT = 1; 69 70 public static final int STAGE_CLOSED = 2; 72 73 private static final String MESSAGE_ORBINITINFO_INVALID = 75 "ORBInitInfo object is only valid during ORB_init"; 76 77 82 ORBInitInfoImpl( ORB orb, String [] args, 83 String orbId, CodecFactory codecFactory ) 84 { 85 this.orb = orb; 86 87 wrapper = InterceptorsSystemException.get( orb, 88 CORBALogDomains.RPC_PROTOCOL ) ; 89 orbutilWrapper = ORBUtilSystemException.get( orb, 90 CORBALogDomains.RPC_PROTOCOL ) ; 91 omgWrapper = OMGSystemException.get( orb, 92 CORBALogDomains.RPC_PROTOCOL ) ; 93 94 this.args = args; 95 this.orbId = orbId; 96 this.codecFactory = codecFactory; 97 } 98 99 102 public ORB getORB() 103 { 104 return orb ; 105 } 106 107 111 void setStage( int stage ) { 112 this.stage = stage; 113 } 114 115 121 private void checkStage() { 122 if( stage == STAGE_CLOSED ) { 123 throw wrapper.orbinitinfoInvalid() ; 124 } 125 } 126 127 131 132 136 public String [] arguments () { 137 checkStage(); 138 return args; 139 } 140 141 144 public String orb_id () { 145 checkStage(); 146 return orbId; 147 } 148 149 156 public CodecFactory codec_factory () { 157 checkStage(); 158 return codecFactory; 159 } 160 161 170 public void register_initial_reference( String id, 171 org.omg.CORBA.Object obj ) 172 throws InvalidName 173 { 174 checkStage(); 175 if( id == null ) nullParam(); 176 177 if( obj == null ) { 184 throw omgWrapper.rirWithNullObject() ; 185 } 186 187 195 try { 198 orb.register_initial_reference( id, obj ); 199 } catch( org.omg.CORBA.ORBPackage.InvalidName e ) { 200 InvalidName exc = new InvalidName ( e.getMessage() ); 201 exc.initCause( e ) ; 202 throw exc ; 203 } 204 } 205 206 217 public org.omg.CORBA.Object resolve_initial_references (String id) 218 throws InvalidName 219 { 220 checkStage(); 221 if( id == null ) nullParam(); 222 223 if( stage == STAGE_PRE_INIT ) { 224 227 throw wrapper.rirInvalidPreInit() ; 230 } 231 232 org.omg.CORBA.Object objRef = null; 233 234 try { 235 objRef = orb.resolve_initial_references( id ); 236 } 237 catch( org.omg.CORBA.ORBPackage.InvalidName e ) { 238 throw new InvalidName (); 240 } 241 242 return objRef; 243 } 244 245 public void add_client_request_interceptor_with_policy ( 247 ClientRequestInterceptor interceptor, Policy [] policies ) 248 throws DuplicateName 249 { 250 add_client_request_interceptor( interceptor ) ; 252 } 253 254 261 public void add_client_request_interceptor ( 262 ClientRequestInterceptor interceptor) 263 throws DuplicateName 264 { 265 checkStage(); 266 if( interceptor == null ) nullParam(); 267 268 orb.getPIHandler().register_interceptor( interceptor, 269 InterceptorList.INTERCEPTOR_TYPE_CLIENT ); 270 } 271 272 public void add_server_request_interceptor_with_policy ( 274 ServerRequestInterceptor interceptor, Policy [] policies ) 275 throws DuplicateName , PolicyError 276 { 277 add_server_request_interceptor( interceptor ) ; 279 } 280 281 288 public void add_server_request_interceptor ( 289 ServerRequestInterceptor interceptor) 290 throws DuplicateName 291 { 292 checkStage(); 293 if( interceptor == null ) nullParam(); 294 295 orb.getPIHandler().register_interceptor( interceptor, 296 InterceptorList.INTERCEPTOR_TYPE_SERVER ); 297 } 298 299 public void add_ior_interceptor_with_policy ( 301 IORInterceptor interceptor, Policy [] policies ) 302 throws DuplicateName , PolicyError 303 { 304 add_ior_interceptor( interceptor ) ; 306 } 307 308 315 public void add_ior_interceptor ( 316 IORInterceptor interceptor ) 317 throws DuplicateName 318 { 319 checkStage(); 320 if( interceptor == null ) nullParam(); 321 322 orb.getPIHandler().register_interceptor( interceptor, 323 InterceptorList.INTERCEPTOR_TYPE_IOR ); 324 } 325 326 332 public int allocate_slot_id () { 333 checkStage(); 334 335 return ((PICurrent)orb.getPIHandler().getPICurrent()).allocateSlotId( ); 336 337 } 338 339 345 public void register_policy_factory( int type, 346 PolicyFactory policy_factory ) 347 { 348 checkStage(); 349 if( policy_factory == null ) nullParam(); 350 orb.getPIHandler().registerPolicyFactory( type, policy_factory ); 351 } 352 353 354 358 private void nullParam() 359 throws BAD_PARAM 360 { 361 throw orbutilWrapper.nullParam() ; 362 } 363 } 364 | Popular Tags |