1 7 8 package com.sun.corba.se.impl.orbutil; 9 10 import java.lang.Character ; 11 import java.lang.reflect.Field ; 12 import java.lang.reflect.Method ; 13 import java.rmi.NoSuchObjectException ; 14 import java.security.AccessController ; 15 import java.security.PermissionCollection ; 16 import java.security.Policy ; 17 import java.security.PrivilegedAction ; 18 import java.security.ProtectionDomain ; 19 import java.util.ArrayList ; 20 import java.util.Arrays ; 21 import java.util.Map ; 22 import java.util.List ; 23 import java.util.ListIterator ; 24 import java.util.Set ; 25 import java.util.Map.Entry; 26 import java.util.Collection ; 27 import java.util.HashMap ; 28 import java.util.HashSet ; 29 import java.util.Hashtable ; 30 import java.util.Iterator ; 31 import java.util.Enumeration ; 32 import java.util.Properties ; 33 import java.util.IdentityHashMap ; 34 import java.util.StringTokenizer ; 35 import java.util.NoSuchElementException ; 36 37 import javax.rmi.CORBA.ValueHandler ; 38 import javax.rmi.CORBA.ValueHandlerMultiFormat ; 39 import javax.rmi.CORBA.Util ; 40 41 import org.omg.CORBA.StructMember ; 42 import org.omg.CORBA.TypeCode ; 43 import org.omg.CORBA.Any ; 44 import org.omg.CORBA.TCKind ; 45 import org.omg.CORBA.SystemException ; 46 import org.omg.CORBA.CompletionStatus ; 47 import org.omg.CORBA.DATA_CONVERSION ; 48 import org.omg.CORBA.BAD_PARAM ; 49 import org.omg.CORBA.BAD_OPERATION ; 50 import org.omg.CORBA.INTERNAL ; 51 import org.omg.CORBA.TypeCodePackage.BadKind ; 52 import org.omg.CORBA.portable.OutputStream ; 53 import org.omg.CORBA.portable.InputStream ; 54 55 import com.sun.corba.se.pept.transport.ContactInfoList ; 56 57 import com.sun.corba.se.spi.ior.IOR ; 58 import com.sun.corba.se.spi.presentation.rmi.StubAdapter ; 59 import com.sun.corba.se.spi.orb.ORB ; 60 import com.sun.corba.se.spi.orb.ORBVersion ; 61 import com.sun.corba.se.spi.orb.ORBVersionFactory ; 62 import com.sun.corba.se.spi.protocol.CorbaClientDelegate ; 63 import com.sun.corba.se.spi.protocol.CorbaMessageMediator; 64 import com.sun.corba.se.spi.transport.CorbaContactInfoList ; 65 import com.sun.corba.se.spi.logging.CORBALogDomains ; 66 import com.sun.corba.se.spi.ior.iiop.IIOPProfile; 67 import com.sun.corba.se.spi.ior.iiop.IIOPProfileTemplate; 68 69 import com.sun.corba.se.impl.protocol.giopmsgheaders.Message; 70 import com.sun.corba.se.impl.corba.CORBAObjectImpl ; 71 import com.sun.corba.se.impl.logging.ORBUtilSystemException ; 72 import com.sun.corba.se.impl.logging.OMGSystemException ; 73 import com.sun.corba.se.impl.ior.iiop.JavaSerializationComponent; 74 75 78 public final class ORBUtility { 79 private ORBUtility() {} 80 81 private static ORBUtilSystemException wrapper = ORBUtilSystemException.get( 82 CORBALogDomains.UTIL ) ; 83 private static OMGSystemException omgWrapper = OMGSystemException.get( 84 CORBALogDomains.UTIL ) ; 85 86 private static StructMember [] members = null; 87 88 private static StructMember [] systemExceptionMembers (ORB orb) { 89 if (members == null) { 90 members = new StructMember [3]; 91 members[0] = new StructMember ("id", orb.create_string_tc(0), null); 92 members[1] = new StructMember ("minor", orb.get_primitive_tc(TCKind.tk_long), null); 93 members[2] = new StructMember ("completed", orb.get_primitive_tc(TCKind.tk_long), null); 94 } 95 return members; 96 } 97 98 private static TypeCode getSystemExceptionTypeCode(ORB orb, String repID, String name) { 99 synchronized (TypeCode .class) { 100 return orb.create_exception_tc(repID, name, systemExceptionMembers(orb)); 101 } 102 } 103 104 private static boolean isSystemExceptionTypeCode(TypeCode type, ORB orb) { 105 StructMember [] systemExceptionMembers = systemExceptionMembers(orb); 106 try { 107 return (type.kind().value() == TCKind._tk_except && 108 type.member_count() == 3 && 109 type.member_type(0).equal(systemExceptionMembers[0].type) && 110 type.member_type(1).equal(systemExceptionMembers[1].type) && 111 type.member_type(2).equal(systemExceptionMembers[2].type)); 112 } catch (BadKind ex) { 113 return false; 114 } catch (org.omg.CORBA.TypeCodePackage.Bounds ex) { 115 return false; 116 } 117 } 118 119 123 public static void insertSystemException(SystemException ex, Any any) { 124 OutputStream out = any.create_output_stream(); 125 ORB orb = (ORB)(out.orb()); 126 String name = ex.getClass().getName(); 127 String repID = ORBUtility.repositoryIdOf(name); 128 out.write_string(repID); 129 out.write_long(ex.minor); 130 out.write_long(ex.completed.value()); 131 any.read_value(out.create_input_stream(), 132 getSystemExceptionTypeCode(orb, repID, name)); 133 } 134 135 public static SystemException extractSystemException(Any any) { 136 InputStream in = any.create_input_stream(); 137 ORB orb = (ORB)(in.orb()); 138 if ( ! isSystemExceptionTypeCode(any.type(), orb)) { 139 throw wrapper.unknownDsiSysex(CompletionStatus.COMPLETED_MAYBE); 140 } 141 return ORBUtility.readSystemException(in); 142 } 143 144 150 public static ValueHandler createValueHandler(ORB orb) { 151 152 if (orb == null) 153 return Util.createValueHandler(); 154 155 ORBVersion version = orb.getORBVersion(); 156 157 if (version == null) 158 return Util.createValueHandler(); 159 160 if (version.equals(ORBVersionFactory.getOLD())) 161 return new ValueHandlerImpl_1_3(); 162 if (version.equals(ORBVersionFactory.getNEW())) 163 return new ValueHandlerImpl_1_3_1(); 164 165 return Util.createValueHandler(); 166 } 167 168 173 public static boolean isLegacyORB(ORB orb) 174 { 175 try { 176 ORBVersion currentORB = orb.getORBVersion(); 177 return currentORB.equals( ORBVersionFactory.getOLD() ) ; 178 } catch (SecurityException se) { 179 return false; 180 } 181 } 182 183 188 public static boolean isForeignORB(ORB orb) 189 { 190 if (orb == null) 191 return false; 192 193 try { 194 return orb.getORBVersion().equals(ORBVersionFactory.getFOREIGN()); 195 } catch (SecurityException se) { 196 return false; 197 } 198 } 199 200 207 public static int bytesToInt(byte[] array, int offset) 208 { 209 int b1, b2, b3, b4; 210 211 b1 = (array[offset++] << 24) & 0xFF000000; 212 b2 = (array[offset++] << 16) & 0x00FF0000; 213 b3 = (array[offset++] << 8) & 0x0000FF00; 214 b4 = (array[offset++] << 0) & 0x000000FF; 215 216 return (b1 | b2 | b3 | b4); 217 } 218 219 226 public static void intToBytes(int value, byte[] array, int offset) 227 { 228 array[offset++] = (byte)((value >>> 24) & 0xFF); 229 array[offset++] = (byte)((value >>> 16) & 0xFF); 230 array[offset++] = (byte)((value >>> 8) & 0xFF); 231 array[offset++] = (byte)((value >>> 0) & 0xFF); 232 } 233 234 236 public static int hexOf( char x ) 237 { 238 int val; 239 240 val = x - '0'; 241 if (val >=0 && val <= 9) 242 return val; 243 244 val = (x - 'a') + 10; 245 if (val >= 10 && val <= 15) 246 return val; 247 248 val = (x - 'A') + 10; 249 if (val >= 10 && val <= 15) 250 return val; 251 252 throw wrapper.badHexDigit() ; 253 } 254 255 257 261 public static void writeSystemException(SystemException ex, OutputStream strm) 262 { 263 String s; 264 265 s = repositoryIdOf(ex.getClass().getName()); 266 strm.write_string(s); 267 strm.write_long(ex.minor); 268 strm.write_long(ex.completed.value()); 269 } 270 271 275 public static SystemException readSystemException(InputStream strm) 276 { 277 try { 278 String name = classNameOf(strm.read_string()); 279 SystemException ex 280 = (SystemException )ORBClassLoader.loadClass(name).newInstance(); 281 ex.minor = strm.read_long(); 282 ex.completed = CompletionStatus.from_int(strm.read_long()); 283 return ex; 284 } catch ( Exception ex ) { 285 throw wrapper.unknownSysex( CompletionStatus.COMPLETED_MAYBE, ex ); 286 } 287 } 288 289 296 public static String classNameOf(String repositoryId) 297 { 298 String className=null; 299 300 className = (String ) exceptionClassNames.get(repositoryId); 301 if (className == null) 302 className = "org.omg.CORBA.UNKNOWN"; 303 304 return className; 305 } 306 307 311 public static boolean isSystemException(String repositoryId) 312 { 313 String className=null; 314 315 className = (String ) exceptionClassNames.get(repositoryId); 316 if (className == null) 317 return false; 318 else 319 return true; 320 } 321 322 325 public static byte getEncodingVersion(ORB orb, IOR ior) { 326 327 334 if (orb.getORBData().isJavaSerializationEnabled()) { 335 IIOPProfile prof = ior.getProfile(); 336 IIOPProfileTemplate profTemp = 337 (IIOPProfileTemplate) prof.getTaggedProfileTemplate(); 338 java.util.Iterator iter = profTemp.iteratorById( 339 ORBConstants.TAG_JAVA_SERIALIZATION_ID); 340 if (iter.hasNext()) { 341 JavaSerializationComponent jc = 342 (JavaSerializationComponent) iter.next(); 343 byte jcVersion = jc.javaSerializationVersion(); 344 if (jcVersion >= Message.JAVA_ENC_VERSION) { 345 return Message.JAVA_ENC_VERSION; 346 } else if (jcVersion > Message.CDR_ENC_VERSION) { 347 return jc.javaSerializationVersion(); 348 } else { 349 } 352 } 353 } 354 return Message.CDR_ENC_VERSION; } 356 357 363 public static String repositoryIdOf(String name) 364 { 365 String id; 366 367 id = (String ) exceptionRepositoryIds.get(name); 368 if (id == null) 369 id = "IDL:omg.org/CORBA/UNKNOWN:1.0"; 370 371 return id; 372 } 373 374 private static final Hashtable exceptionClassNames = new Hashtable (); 375 private static final Hashtable exceptionRepositoryIds = new Hashtable (); 376 377 static { 378 379 exceptionClassNames.put("IDL:omg.org/CORBA/BAD_CONTEXT:1.0", 383 "org.omg.CORBA.BAD_CONTEXT"); 384 exceptionClassNames.put("IDL:omg.org/CORBA/BAD_INV_ORDER:1.0", 385 "org.omg.CORBA.BAD_INV_ORDER"); 386 exceptionClassNames.put("IDL:omg.org/CORBA/BAD_OPERATION:1.0", 387 "org.omg.CORBA.BAD_OPERATION"); 388 exceptionClassNames.put("IDL:omg.org/CORBA/BAD_PARAM:1.0", 389 "org.omg.CORBA.BAD_PARAM"); 390 exceptionClassNames.put("IDL:omg.org/CORBA/BAD_TYPECODE:1.0", 391 "org.omg.CORBA.BAD_TYPECODE"); 392 exceptionClassNames.put("IDL:omg.org/CORBA/COMM_FAILURE:1.0", 393 "org.omg.CORBA.COMM_FAILURE"); 394 exceptionClassNames.put("IDL:omg.org/CORBA/DATA_CONVERSION:1.0", 395 "org.omg.CORBA.DATA_CONVERSION"); 396 exceptionClassNames.put("IDL:omg.org/CORBA/IMP_LIMIT:1.0", 397 "org.omg.CORBA.IMP_LIMIT"); 398 exceptionClassNames.put("IDL:omg.org/CORBA/INTF_REPOS:1.0", 399 "org.omg.CORBA.INTF_REPOS"); 400 exceptionClassNames.put("IDL:omg.org/CORBA/INTERNAL:1.0", 401 "org.omg.CORBA.INTERNAL"); 402 exceptionClassNames.put("IDL:omg.org/CORBA/INV_FLAG:1.0", 403 "org.omg.CORBA.INV_FLAG"); 404 exceptionClassNames.put("IDL:omg.org/CORBA/INV_IDENT:1.0", 405 "org.omg.CORBA.INV_IDENT"); 406 exceptionClassNames.put("IDL:omg.org/CORBA/INV_OBJREF:1.0", 407 "org.omg.CORBA.INV_OBJREF"); 408 exceptionClassNames.put("IDL:omg.org/CORBA/MARSHAL:1.0", 409 "org.omg.CORBA.MARSHAL"); 410 exceptionClassNames.put("IDL:omg.org/CORBA/NO_MEMORY:1.0", 411 "org.omg.CORBA.NO_MEMORY"); 412 exceptionClassNames.put("IDL:omg.org/CORBA/FREE_MEM:1.0", 413 "org.omg.CORBA.FREE_MEM"); 414 exceptionClassNames.put("IDL:omg.org/CORBA/NO_IMPLEMENT:1.0", 415 "org.omg.CORBA.NO_IMPLEMENT"); 416 exceptionClassNames.put("IDL:omg.org/CORBA/NO_PERMISSION:1.0", 417 "org.omg.CORBA.NO_PERMISSION"); 418 exceptionClassNames.put("IDL:omg.org/CORBA/NO_RESOURCES:1.0", 419 "org.omg.CORBA.NO_RESOURCES"); 420 exceptionClassNames.put("IDL:omg.org/CORBA/NO_RESPONSE:1.0", 421 "org.omg.CORBA.NO_RESPONSE"); 422 exceptionClassNames.put("IDL:omg.org/CORBA/OBJ_ADAPTER:1.0", 423 "org.omg.CORBA.OBJ_ADAPTER"); 424 exceptionClassNames.put("IDL:omg.org/CORBA/INITIALIZE:1.0", 425 "org.omg.CORBA.INITIALIZE"); 426 exceptionClassNames.put("IDL:omg.org/CORBA/PERSIST_STORE:1.0", 427 "org.omg.CORBA.PERSIST_STORE"); 428 exceptionClassNames.put("IDL:omg.org/CORBA/TRANSIENT:1.0", 429 "org.omg.CORBA.TRANSIENT"); 430 exceptionClassNames.put("IDL:omg.org/CORBA/UNKNOWN:1.0", 431 "org.omg.CORBA.UNKNOWN"); 432 exceptionClassNames.put("IDL:omg.org/CORBA/OBJECT_NOT_EXIST:1.0", 433 "org.omg.CORBA.OBJECT_NOT_EXIST"); 434 435 exceptionClassNames.put("IDL:omg.org/CORBA/INVALID_TRANSACTION:1.0", 437 "org.omg.CORBA.INVALID_TRANSACTION"); 438 exceptionClassNames.put("IDL:omg.org/CORBA/TRANSACTION_REQUIRED:1.0", 439 "org.omg.CORBA.TRANSACTION_REQUIRED"); 440 exceptionClassNames.put("IDL:omg.org/CORBA/TRANSACTION_ROLLEDBACK:1.0", 441 "org.omg.CORBA.TRANSACTION_ROLLEDBACK"); 442 443 exceptionClassNames.put("IDL:omg.org/CORBA/INV_POLICY:1.0", 445 "org.omg.CORBA.INV_POLICY"); 446 447 exceptionClassNames. 449 put("IDL:omg.org/CORBA/TRANSACTION_UNAVAILABLE:1.0", 450 "org.omg.CORBA.TRANSACTION_UNAVAILABLE"); 451 exceptionClassNames.put("IDL:omg.org/CORBA/TRANSACTION_MODE:1.0", 452 "org.omg.CORBA.TRANSACTION_MODE"); 453 454 exceptionClassNames.put("IDL:omg.org/CORBA/CODESET_INCOMPATIBLE:1.0", 456 "org.omg.CORBA.CODESET_INCOMPATIBLE"); 457 exceptionClassNames.put("IDL:omg.org/CORBA/REBIND:1.0", 458 "org.omg.CORBA.REBIND"); 459 exceptionClassNames.put("IDL:omg.org/CORBA/TIMEOUT:1.0", 460 "org.omg.CORBA.TIMEOUT"); 461 exceptionClassNames.put("IDL:omg.org/CORBA/BAD_QOS:1.0", 462 "org.omg.CORBA.BAD_QOS"); 463 464 exceptionClassNames.put("IDL:omg.org/CORBA/INVALID_ACTIVITY:1.0", 466 "org.omg.CORBA.INVALID_ACTIVITY"); 467 exceptionClassNames.put("IDL:omg.org/CORBA/ACTIVITY_COMPLETED:1.0", 468 "org.omg.CORBA.ACTIVITY_COMPLETED"); 469 exceptionClassNames.put("IDL:omg.org/CORBA/ACTIVITY_REQUIRED:1.0", 470 "org.omg.CORBA.ACTIVITY_REQUIRED"); 471 472 Enumeration keys = exceptionClassNames.keys(); 476 java.lang.Object s; 477 String rId; 478 String cName; 479 480 try{ 481 while (keys.hasMoreElements()) { 482 s = keys.nextElement(); 483 rId = (String ) s; 484 cName = (String ) exceptionClassNames.get(rId); 485 exceptionRepositoryIds.put (cName, rId); 486 } 487 } catch (NoSuchElementException e) { } 488 } 489 490 494 public static int[] parseVersion(String version) { 495 if (version == null) 496 return new int[0]; 497 char[] s = version.toCharArray(); 498 int start = 0; 500 for (; start < s.length && (s[start] < '0' || s[start] > '9'); ++start) 501 if (start == s.length) return new int[0]; 503 int end = start + 1; 504 int size = 1; 505 for (; end < s.length; ++end) 506 if (s[end] == '.') 507 ++size; 508 else if (s[end] < '0' || s[end] > '9') 509 break; 510 int[] val = new int[size]; 511 for (int i = 0; i < size; ++i) { 512 int dot = version.indexOf('.', start); 513 if (dot == -1 || dot > end) 514 dot = end; 515 if (start >= dot) val[i] = 0; else 518 val[i] = Integer.parseInt(version.substring(start, dot)); 519 start = dot + 1; 520 } 521 return val; 522 } 523 524 527 public static int compareVersion(int[] v1, int[] v2) { 528 if (v1 == null) 529 v1 = new int[0]; 530 if (v2 == null) 531 v2 = new int[0]; 532 for (int i = 0; i < v1.length; ++i) { 533 if (i >= v2.length || v1[i] > v2[i]) return 1; 535 if (v1[i] < v2[i]) 536 return -1; 537 } 538 return v1.length == v2.length ? 0 : -1; 539 } 540 541 544 public static synchronized int compareVersion(String v1, String v2) { 545 return compareVersion(parseVersion(v1), parseVersion(v2)); 546 } 547 548 private static String compressClassName( String name ) 549 { 550 String prefix = "com.sun.corba.se." ; 552 if (name.startsWith( prefix ) ) { 553 return "(ORB)." + name.substring( prefix.length() ) ; 554 } else 555 return name ; 556 } 557 558 public static String getThreadName( Thread thr ) 562 { 563 if (thr == null) 564 return "null" ; 565 566 String name = thr.getName() ; 571 StringTokenizer st = new StringTokenizer ( name ) ; 572 int numTokens = st.countTokens() ; 573 if (numTokens != 5) 574 return name ; 575 576 String [] tokens = new String [numTokens] ; 577 for (int ctr=0; ctr<numTokens; ctr++ ) 578 tokens[ctr] = st.nextToken() ; 579 580 if( !tokens[0].equals("SelectReaderThread")) 581 return name ; 582 583 return "SelectReaderThread[" + tokens[2] + ":" + tokens[3] + "]" ; 584 } 585 586 private static String formatStackTraceElement( StackTraceElement ste ) 587 { 588 return compressClassName( ste.getClassName() ) + "." + ste.getMethodName() + 589 (ste.isNativeMethod() ? "(Native Method)" : 590 (ste.getFileName() != null && ste.getLineNumber() >= 0 ? 591 "(" + ste.getFileName() + ":" + ste.getLineNumber() + ")" : 592 (ste.getFileName() != null ? "("+ste.getFileName()+")" : "(Unknown Source)"))); 593 } 594 595 private static void printStackTrace( StackTraceElement [] trace ) 596 { 597 System.out.println( " Stack Trace:" ) ; 598 for ( int ctr = 1; ctr < trace.length; ctr++ ) { 601 System.out.print( " >" ) ; 602 System.out.println( formatStackTraceElement( trace[ctr] ) ) ; 603 } 604 } 605 606 public static synchronized void dprint(java.lang.Object obj, String msg) { 610 System.out.println( 611 compressClassName( obj.getClass().getName() ) + "(" + 612 getThreadName( Thread.currentThread() ) + "): " + msg); 613 } 614 615 public static synchronized void dprint(String className, String msg) { 616 System.out.println( 617 compressClassName( className ) + "(" + 618 getThreadName( Thread.currentThread() ) + "): " + msg); 619 } 620 621 public synchronized void dprint(String msg) { 622 ORBUtility.dprint(this, msg); 623 } 624 625 public static synchronized void dprintTrace(Object obj, String msg) { 626 ORBUtility.dprint(obj, msg); 627 628 Throwable thr = new Throwable () ; 629 printStackTrace( thr.getStackTrace() ) ; 630 } 631 632 public static synchronized void dprint(java.lang.Object caller, 633 String msg, Throwable t) 634 { 635 System.out.println( 636 compressClassName( caller.getClass().getName() ) + 637 '(' + Thread.currentThread() + "): " + msg); 638 639 if (t != null) 640 printStackTrace( t.getStackTrace() ) ; 641 } 642 643 public static String [] concatenateStringArrays( String [] arr1, String [] arr2 ) 644 { 645 String [] result = new String [ 646 arr1.length + arr2.length ] ; 647 648 for (int ctr = 0; ctr<arr1.length; ctr++) 649 result[ctr] = arr1[ctr] ; 650 651 for (int ctr = 0; ctr<arr2.length; ctr++) 652 result[ctr + arr1.length] = arr2[ctr] ; 653 654 return result ; 655 } 656 657 669 public static void throwNotSerializableForCorba(String className) { 670 throw omgWrapper.notSerializable( CompletionStatus.COMPLETED_MAYBE, 671 className ) ; 672 } 673 674 678 public static byte getMaxStreamFormatVersion() { 679 ValueHandler vh = Util.createValueHandler(); 680 681 if (!(vh instanceof javax.rmi.CORBA.ValueHandlerMultiFormat )) 682 return ORBConstants.STREAM_FORMAT_VERSION_1; 683 else 684 return ((ValueHandlerMultiFormat )vh).getMaximumStreamFormatVersion(); 685 } 686 687 public static CorbaClientDelegate makeClientDelegate( IOR ior ) 688 { 689 ORB orb = ior.getORB() ; 690 CorbaContactInfoList ccil = orb.getCorbaContactInfoListFactory().create( ior ) ; 691 CorbaClientDelegate del = orb.getClientDelegateFactory().create(ccil); 692 return del ; 693 } 694 695 697 public static org.omg.CORBA.Object makeObjectReference( IOR ior ) 698 { 699 CorbaClientDelegate del = makeClientDelegate( ior ) ; 700 org.omg.CORBA.Object objectImpl = new CORBAObjectImpl() ; 701 StubAdapter.setDelegate( objectImpl, del ) ; 702 return objectImpl ; 703 } 704 705 716 public static IOR getIOR( org.omg.CORBA.Object obj ) 717 { 718 if (obj == null) 719 throw wrapper.nullObjectReference() ; 720 721 IOR ior = null ; 722 if (StubAdapter.isStub(obj)) { 723 org.omg.CORBA.portable.Delegate del = StubAdapter.getDelegate( 724 obj ) ; 725 726 if (del instanceof CorbaClientDelegate) { 727 CorbaClientDelegate cdel = (CorbaClientDelegate)del ; 728 ContactInfoList cil = cdel.getContactInfoList() ; 729 730 if (cil instanceof CorbaContactInfoList) { 731 CorbaContactInfoList ccil = (CorbaContactInfoList)cil ; 732 ior = ccil.getTargetIOR() ; 733 if (ior == null) 734 throw wrapper.nullIor() ; 735 736 return ior ; 737 } else { 738 throw new INTERNAL () ; 745 } 746 } 747 748 throw wrapper.objrefFromForeignOrb() ; 756 } else 757 throw wrapper.localObjectNotAllowed() ; 758 } 759 760 769 public static IOR connectAndGetIOR( ORB orb, org.omg.CORBA.Object obj ) 770 { 771 IOR result ; 772 try { 773 result = getIOR( obj ) ; 774 } catch (BAD_OPERATION bop) { 775 if (StubAdapter.isStub(obj)) { 776 try { 777 StubAdapter.connect( obj, orb ) ; 778 } catch (java.rmi.RemoteException exc) { 779 throw wrapper.connectingServant( exc ) ; 780 } 781 } else { 782 orb.connect( obj ) ; 783 } 784 785 result = getIOR( obj ) ; 786 } 787 788 return result ; 789 } 790 791 public static String operationNameAndRequestId(CorbaMessageMediator m) 792 { 793 return "op/" + m.getOperationName() + " id/" + m.getRequestId(); 794 } 795 796 public static boolean isPrintable(char c) 797 { 798 if (Character.isJavaIdentifierStart(c)) { 799 return true; 801 } 802 if (Character.isDigit(c)) { 803 return true; 804 } 805 switch (Character.getType(c)) { 806 case Character.MODIFIER_SYMBOL : return true; case Character.DASH_PUNCTUATION : return true; case Character.MATH_SYMBOL : return true; case Character.OTHER_PUNCTUATION : return true; case Character.START_PUNCTUATION : return true; case Character.END_PUNCTUATION : return true; } 813 return false; 814 } 815 816 public static String getClassSecurityInfo(final Class cl) 817 { 818 828 String result = 829 (String )AccessController.doPrivileged(new PrivilegedAction () { 830 public java.lang.Object run() { 831 StringBuffer sb = new StringBuffer (500); 832 ProtectionDomain pd = cl.getProtectionDomain(); 833 Policy policy = Policy.getPolicy(); 834 PermissionCollection pc = policy.getPermissions(pd); 835 sb.append("\nPermissionCollection "); 836 sb.append(pc.toString()); 837 sb.append(pd.toString()); 840 return sb.toString(); 841 } 842 }); 843 return result; 844 } 845 } 846 847 | Popular Tags |