1 package org.jacorb.orb; 2 3 22 23 import java.util.*; 24 import org.omg.CORBA.TypeCode ; 25 import org.omg.CORBA.BAD_PARAM ; 26 import org.omg.CORBA.BAD_TYPECODE ; 27 import org.omg.CORBA.TCKind ; 28 import org.omg.CORBA.CompletionStatus ; 29 30 import org.apache.avalon.framework.configuration.*; 31 32 36 37 public class ORBSingleton 38 extends org.omg.CORBA_2_5.ORB 39 implements Configurable 40 { 41 private boolean doStrictCheckOnTypecodeCreation = false; 42 43 public void configure(Configuration configuration) 44 throws ConfigurationException 45 { 46 doStrictCheckOnTypecodeCreation = 47 configuration.getAttribute("jacorb.interop.strict_check_on_tc_creation", "on").equals("on"); 48 49 } 50 51 52 53 54 public org.omg.CORBA.Any create_any() 55 { 56 return new org.jacorb.orb.Any(this); 57 } 58 59 66 67 final protected static boolean legalStartChar(int ch) 68 { 69 return 70 ( ch >= 'a' && ch <= 'z') || (ch == '_') || 71 ( ch >= 'A' && ch <= 'Z'); 72 } 73 74 75 79 final protected static boolean legalNameChar(int ch) 80 { 81 return 82 legalStartChar(ch) || 83 (ch == '_') 84 || (ch >= '0' && ch <= '9'); 85 } 86 87 88 93 private void checkTCName (String name) throws BAD_PARAM 94 { 95 checkTCName (name, false); 96 } 97 98 99 107 private void checkTCName (String name, boolean allowNull) 108 throws BAD_PARAM 109 { 110 if (name != null) 111 { 112 if( name.length() > 0 ) 113 { 114 if( !legalStartChar( name.charAt(0)) ) 116 { 117 throw new BAD_PARAM 118 ( 119 "Illegal start character to IDL name: " + name, 120 15, 121 CompletionStatus.COMPLETED_NO 122 ); 123 } 124 for( int i = 0; i < name.length(); i++ ) 125 { 126 if( ! legalNameChar( name.charAt(i) )) 127 throw new BAD_PARAM ("Illegal IDL name: " + name, 15, 128 CompletionStatus.COMPLETED_NO ); 129 } 130 } 131 else 132 { 133 throw new BAD_PARAM ("Illegal blank IDL name", 15, 134 CompletionStatus.COMPLETED_NO ); 135 } 136 } 137 else if (allowNull == false) 138 { 139 throw new BAD_PARAM ("Illegal null IDL name", 15, 140 CompletionStatus.COMPLETED_NO ); 141 } 142 } 143 144 150 private void checkTCRepositoryId( String repId ) 151 throws BAD_PARAM 152 { 153 if( repId == null || repId.indexOf( ':' ) < 0 ) 154 { 155 throw new BAD_PARAM ("Illegal Repository ID: " + repId, 156 16, CompletionStatus.COMPLETED_NO ); 157 } 158 } 159 160 165 166 private void checkTCMemberType( TypeCode tc ) 167 throws BAD_TYPECODE 168 { 169 if( !org.jacorb.orb.TypeCode.isRecursive(tc) && 170 (tc == null || 171 tc.kind().value() == TCKind._tk_null || 172 tc.kind().value() == TCKind._tk_void || 173 tc.kind().value() == TCKind._tk_except 174 ) 175 ) 176 { 177 throw new BAD_TYPECODE ("Illegal member tc", 2, 178 CompletionStatus.COMPLETED_NO ); 179 } 180 } 181 182 183 184 185 186 187 public TypeCode create_alias_tc( String id, 188 String name, 189 TypeCode original_type) 190 { 191 checkTCRepositoryId( id ); 192 checkTCName (name, true); 193 checkTCMemberType( original_type ); 194 return new org.jacorb.orb.TypeCode( org.omg.CORBA.TCKind._tk_alias, 195 id, name, original_type); 196 } 197 198 public TypeCode create_array_tc( int length, TypeCode element_type) 199 { 200 checkTCMemberType( element_type ); 201 return new org.jacorb.orb.TypeCode( org.omg.CORBA.TCKind._tk_array, 202 length, 203 element_type); 204 } 205 206 209 210 public TypeCode create_enum_tc( String id, 211 String name, 212 String [] members) 213 { 214 checkTCRepositoryId( id ); 215 checkTCName (name, true); 216 217 Hashtable names = new Hashtable() ; 219 for( int i = 0; i < members.length; i++ ) 220 { 221 boolean fault = false; 222 try 223 { 224 checkTCName( members[i] ); 225 } 226 catch( BAD_PARAM bp ) 227 { 228 fault = true; 229 } 230 if( names.containsKey( members[i] ) || fault ) 231 { 232 throw new BAD_PARAM ("Illegal enum member name: " + members[i], 233 17, CompletionStatus.COMPLETED_NO ); 234 } 235 names.put( members[i], "" ); 236 } 237 names.clear(); 238 239 return new org.jacorb.orb.TypeCode( id, name, members); 240 } 241 242 245 246 public TypeCode create_exception_tc( String id, 247 String name, 248 org.omg.CORBA.StructMember [] members) 249 { 250 checkTCRepositoryId( id ); 251 checkTCName (name, true); 252 253 Hashtable names = new Hashtable() ; 255 for( int i = 0; i < members.length; i++ ) 256 { 257 checkTCMemberType( members[i].type ); 258 boolean fault = false; 259 try 260 { 261 checkTCName( members[i].name ); 262 } 263 catch( BAD_PARAM bp ) 264 { 265 fault = true; 266 } 267 if( names.containsKey( members[i].name ) || fault ) 268 { 269 throw new BAD_PARAM ("Illegal exception member name: " + 270 members[i].name, 271 17, CompletionStatus.COMPLETED_NO ); 272 } 273 names.put( members[i].name, "" ); 274 } 275 names.clear(); 276 277 278 return new org.jacorb.orb.TypeCode( org.omg.CORBA.TCKind._tk_except, 279 id, 280 name, 281 members); 282 } 283 284 public TypeCode create_interface_tc( String id, String name) 285 { 286 checkTCRepositoryId( id ); 287 checkTCName (name, true); 288 return new org.jacorb.orb.TypeCode( org.omg.CORBA.TCKind._tk_objref, 289 id, name); 290 } 291 292 public org.omg.CORBA.TypeCode create_fixed_tc( short digits, 293 short scale) 294 { 295 if (digits <= 0 || scale < 0 || scale > digits) 296 { 297 throw new org.omg.CORBA.BAD_PARAM 298 ("Invalid combination of digits and scale factor"); 299 } 300 return new org.jacorb.orb.TypeCode(digits, scale); 301 } 302 303 public org.omg.CORBA.TypeCode create_recursive_tc( String id ) 304 { 305 checkTCRepositoryId( id ); 306 return new org.jacorb.orb.TypeCode( id ); 307 } 308 309 public TypeCode create_sequence_tc( int bound, TypeCode element_type) 310 { 311 checkTCMemberType( element_type ); 312 TypeCode tc = 313 new org.jacorb.orb.TypeCode( org.omg.CORBA.TCKind._tk_sequence, 314 bound, 315 element_type); 316 return tc; 317 } 318 319 public TypeCode create_string_tc(int bound) 320 { 321 return new org.jacorb.orb.TypeCode( org.omg.CORBA.TCKind._tk_string, bound ); 322 } 323 324 public TypeCode create_wstring_tc(int bound) 325 { 326 return new org.jacorb.orb.TypeCode( org.omg.CORBA.TCKind._tk_wstring, bound); 327 } 328 329 332 333 public TypeCode create_struct_tc(String id, 334 String name, 335 org.omg.CORBA.StructMember [] members) 336 { 337 checkTCRepositoryId( id ); 338 checkTCName (name, true); 339 340 Hashtable names = new Hashtable() ; 342 for( int i = 0; i < members.length; i++ ) 343 { 344 checkTCMemberType( members[i].type ); 345 boolean fault = false; 346 try 347 { 348 checkTCName( members[i].name ); 349 } 350 catch( BAD_PARAM bp ) 351 { 352 fault = true; 353 } 354 if( names.containsKey( members[i].name ) || fault ) 355 { 356 throw new BAD_PARAM ("Illegal struct member name: " + 357 members[i].name + (fault? " (Bad PARAM) ": "" ), 358 17, CompletionStatus.COMPLETED_NO ); 359 } 360 names.put( members[i].name, "" ); 361 } 362 names.clear(); 363 364 org.jacorb.orb.TypeCode tc = 365 new org.jacorb.orb.TypeCode( org.omg.CORBA.TCKind._tk_struct, 366 id, 367 name, 368 members); 369 370 tc.resolveRecursion(); 372 return tc; 373 } 374 375 378 379 public TypeCode create_union_tc( String id, 380 String name, 381 TypeCode discriminator_type, 382 org.omg.CORBA.UnionMember [] members) 383 { 384 checkTCRepositoryId( id ); 385 checkTCName (name, true); 386 387 389 TypeCode disc_tc = 390 org.jacorb.orb.TypeCode.originalType(discriminator_type); 391 392 if (disc_tc == null || 393 !(disc_tc.kind().value() == TCKind._tk_short || 394 disc_tc.kind().value() == TCKind._tk_long || 395 disc_tc.kind().value() == TCKind._tk_longlong || 396 disc_tc.kind().value() == TCKind._tk_ushort || 397 disc_tc.kind().value() == TCKind._tk_ulong || 398 disc_tc.kind().value() == TCKind._tk_ulonglong || 399 disc_tc.kind().value() == TCKind._tk_char || 400 disc_tc.kind().value() == TCKind._tk_boolean || 401 disc_tc.kind().value() == TCKind._tk_enum 402 ) 403 ) 404 { 405 throw new BAD_PARAM ("Illegal union discriminator type", 406 20, CompletionStatus.COMPLETED_NO ); 407 } 408 409 411 for( int i = 0; i < members.length; i++ ) 412 { 413 checkTCMemberType( members[i].type ); 414 try 415 { 416 checkTCName( members[i].name ); 417 } 418 catch( BAD_PARAM bp ) 419 { 420 throw new BAD_PARAM ("Illegal union member name: " + 421 members[i].name, 422 17, CompletionStatus.COMPLETED_NO ); 423 } 424 425 427 org.omg.CORBA.Any label = members[i].label; 428 if (! discriminator_type.equivalent( label.type () ) && 429 ! ( label.type().kind().value() == TCKind._tk_octet && 430 label.extract_octet() == (byte)0 431 ) 432 ) 433 { 434 throw new BAD_PARAM ("Label type does not match discriminator type", 435 19, 436 CompletionStatus.COMPLETED_NO ); 437 } 438 439 441 for( int j = 0; j < i; j++ ) 442 { 443 if( label.equal( members[j].label )) 444 { 445 throw new BAD_PARAM ("Duplicate union case label", 446 18, 447 CompletionStatus.COMPLETED_NO ); 448 } 449 } 450 } 451 452 org.jacorb.orb.TypeCode tc = 453 new org.jacorb.orb.TypeCode( id, 454 name, 455 discriminator_type, 456 members); 457 458 tc.resolveRecursion(); 460 return tc; 461 } 462 463 464 public TypeCode get_primitive_tc(org.omg.CORBA.TCKind tcKind) 465 { 466 return org.jacorb.orb.TypeCode.get_primitive_tc( tcKind.value() ); 467 } 468 469 public org.omg.CORBA.TypeCode create_value_tc(String id, 470 String name, 471 short type_modifier, 472 TypeCode concrete_base, 473 org.omg.CORBA.ValueMember [] members) 474 { 475 checkTCRepositoryId( id ); 476 477 482 if ( !id.startsWith("RMI:") ) 483 checkTCName (name, true); 484 return new org.jacorb.orb.TypeCode (id, 485 name, 486 type_modifier, 487 concrete_base, 488 members); 489 } 490 491 public org.omg.CORBA.TypeCode create_value_box_tc(String id, 492 String name, 493 TypeCode boxed_type) 494 { 495 checkTCRepositoryId( id ); 496 checkTCName (name, true); 497 return new org.jacorb.orb.TypeCode (org.omg.CORBA.TCKind._tk_value_box, 498 id, 499 name, 500 boxed_type); 501 } 502 503 public org.omg.CORBA.TypeCode create_abstract_interface_tc(String id, 504 String name) 505 { 506 checkTCRepositoryId( id ); 507 508 if ( doStrictCheckOnTypecodeCreation ) 513 checkTCName (name, true); 514 515 return new org.jacorb.orb.TypeCode (org.omg.CORBA.TCKind._tk_abstract_interface, 516 id, 517 name); 518 } 519 520 public org.omg.CORBA.TypeCode create_local_interface_tc(String id, 521 String name) 522 { 523 checkTCRepositoryId( id ); 524 checkTCName (name, true); 525 return new org.jacorb.orb.TypeCode (org.omg.CORBA.TCKind._tk_local_interface, 526 id, 527 name); 528 } 529 530 public org.omg.CORBA.TypeCode create_native_tc(String id, 531 String name) 532 { 533 checkTCRepositoryId( id ); 534 checkTCName (name, true); 535 return new org.jacorb.orb.TypeCode (org.omg.CORBA.TCKind._tk_native, 536 id, 537 name); 538 } 539 540 541 542 public org.omg.CORBA.ExceptionList create_exception_list() 543 { 544 throw new org.omg.CORBA.NO_IMPLEMENT ("The Singleton ORB only permits factory methods"); 545 } 546 547 public org.omg.CORBA.NVList create_list (int count) 548 { 549 throw new org.omg.CORBA.NO_IMPLEMENT ("The Singleton ORB only permits factory methods"); 550 } 551 552 public org.omg.CORBA.NamedValue create_named_value 553 (String name, org.omg.CORBA.Any value, int flags) 554 { 555 throw new org.omg.CORBA.NO_IMPLEMENT ("The Singleton ORB only permits factory methods"); 556 } 557 558 public org.omg.CORBA.NVList create_operation_list 559 (org.omg.CORBA.OperationDef oper) 560 { 561 throw new org.omg.CORBA.NO_IMPLEMENT ("The Singleton ORB only permits factory methods"); 562 } 563 564 public org.omg.CORBA.NVList create_operation_list 565 (org.omg.CORBA.Object obj) 566 { 567 throw new org.omg.CORBA.NO_IMPLEMENT ("The Singleton ORB only permits factory methods"); 568 } 569 570 public org.omg.CORBA.Object string_to_object(String str) 571 { 572 throw new org.omg.CORBA.NO_IMPLEMENT ("The Singleton ORB only permits factory methods"); 573 } 574 575 public org.omg.CORBA.Environment create_environment() 576 { 577 throw new org.omg.CORBA.NO_IMPLEMENT ("The Singleton ORB only permits factory methods"); 578 } 579 580 public org.omg.CORBA.ContextList create_context_list() 581 { 582 throw new org.omg.CORBA.NO_IMPLEMENT ("The Singleton ORB only permits factory methods"); 583 } 584 585 public org.omg.CORBA.portable.OutputStream create_output_stream() 586 { 587 throw new org.omg.CORBA.NO_IMPLEMENT ("The Singleton ORB only permits factory methods"); 588 } 589 590 public org.omg.CORBA.Current get_current() 591 { 592 throw new org.omg.CORBA.NO_IMPLEMENT ("The Singleton ORB only permits factory methods"); 593 } 594 595 public org.omg.CORBA.Context get_default_context() 596 { 597 throw new org.omg.CORBA.NO_IMPLEMENT ("The Singleton ORB only permits factory methods"); 598 } 599 600 public org.omg.CORBA.Request get_next_response() 601 { 602 throw new org.omg.CORBA.NO_IMPLEMENT ("The Singleton ORB only permits factory methods"); 603 } 604 605 public String [] list_initial_services() 606 { 607 throw new org.omg.CORBA.NO_IMPLEMENT ("The Singleton ORB only permits factory methods"); 608 } 609 610 public String object_to_string( org.omg.CORBA.Object obj) 611 { 612 throw new org.omg.CORBA.NO_IMPLEMENT ("The Singleton ORB only permits factory methods"); 613 } 614 615 public boolean poll_next_response() 616 { 617 throw new org.omg.CORBA.NO_IMPLEMENT ("The Singleton ORB only permits factory methods"); 618 } 619 620 public org.omg.CORBA.Object resolve_initial_references(String identifier) 621 throws org.omg.CORBA.ORBPackage.InvalidName 622 { 623 throw new org.omg.CORBA.NO_IMPLEMENT ("The Singleton ORB only permits factory methods"); 624 } 625 626 public void send_multiple_requests_deferred(org.omg.CORBA.Request [] req) 627 { 628 throw new org.omg.CORBA.NO_IMPLEMENT ("The Singleton ORB only permits factory methods"); 629 } 630 631 public void send_multiple_requests_oneway(org.omg.CORBA.Request [] req) 632 { 633 throw new org.omg.CORBA.NO_IMPLEMENT ("The Singleton ORB only permits factory methods"); 634 } 635 636 protected void set_parameters(String [] args, java.util.Properties props) 637 { 638 throw new org.omg.CORBA.NO_IMPLEMENT ("The Singleton ORB only permits factory methods"); 639 } 640 641 protected void set_parameters(java.applet.Applet app, java.util.Properties props) 642 { 643 throw new org.omg.CORBA.NO_IMPLEMENT ("The Singleton ORB only permits factory methods"); 644 } 645 646 public void run() 647 { 648 throw new org.omg.CORBA.NO_IMPLEMENT ("The Singleton ORB only permits factory methods"); 649 } 650 651 public void shutdown(boolean wait_for_completion) 652 { 653 throw new org.omg.CORBA.NO_IMPLEMENT ("The Singleton ORB only permits factory methods"); 654 } 655 656 public boolean work_pending() 657 { 658 throw new org.omg.CORBA.NO_IMPLEMENT ("The Singleton ORB only permits factory methods"); 659 } 660 661 public void perform_work() 662 { 663 throw new org.omg.CORBA.NO_IMPLEMENT ("The Singleton ORB only permits factory methods"); 664 } 665 } 666 | Popular Tags |