421 String abstractBaseID = "IDL:omg.org/CORBA/AbstractBase:1.0"; 422 423 return orb.create_abstract_interface_tc(abstractBaseID, ""); 424 } 425 426 /** 427 * Reads a java.lang.Object as a CORBA any. 428 * @param in the stream from which to read the any. 429 * @return the object read from the stream. 430 */ 431 public Object readAny(InputStream in) 432 { 433 Any any = in.read_any(); 434 if ( any.type().kind().value() == TCKind._tk_objref ) 435 return any.extract_Object (); 436 else 437 return any.extract_Value(); 438 } 439 440 /** 441 * Writes a java.lang.Object as a CORBA Object. If <code>obj</code> is 442 * an exported RMI-IIOP server object, the tie is found 443 * and wired to <code>obj</code>, then written to <code>out.write_Object(org.omg.CORBA.Object)</code>. 444 * If <code>obj</code> is a CORBA Object, it is written to 445 * <code>out.write_Object(org.omg.CORBA.Object)</code>. 446 * @param out the stream in which to write the object. 447 * @param obj the object to write. 448 */ 449 public void writeRemoteObject(OutputStream out, java.lang.Object obj) 450 { 451 // Make sure we have a connected object, then 452 // write it out... 453 454 Object newObj = Utility.autoConnect(obj,out.orb(),false); 455 out.write_Object((org.omg.CORBA.Object)newObj); 456 } 457 458 /** 459 * Writes a java.lang.Object as either a value or a CORBA Object. 460 * If <code>obj</code> is a value object or a stub object, it is written to 461 * <code>out.write_abstract_interface(java.lang.Object)</code>. If <code>obj</code> is an exported 462 * RMI-IIOP server object, the tie is found and wired to <code>obj</code>, 463 * then written to <code>out.write_abstract_interface(java.lang.Object)</code>. 464 * @param out the stream in which to write the object. 465 * @param obj the object to write. 466 */ 467 public void writeAbstractObject( OutputStream out, java.lang.Object obj ) 468 { 469 // Make sure we have a connected object, then 470 // write it out... 471 472 Object newObj = Utility.autoConnect(obj,out.orb(),false); 473 ((org.omg.CORBA_2_3.portable.OutputStream)out).write_abstract_interface(newObj); 474 } 475 476 /** 477 * Registers a target for a tie. Adds the tie to an internal table and calls 478 * {@link Tie#setTarget} on the tie object. 479 * @param tie the tie to register. 480 * @param target the target for the tie. 481 */ 482 public void registerTarget(javax.rmi.CORBA.Tie tie, java.rmi.Remote target) 483 { 578 { 579 return valueHandlerSingleton; 580 } 581 582 /** 583 * Returns the codebase, if any, for the given class. 584 * @param clz the class to get a codebase for. 585 * @return a space-separated list of URLs, or null. 586 */ 587 public String getCodebase(java.lang.Class clz) { 588 return RMIClassLoader.getClassAnnotation(clz); 589 } 590 591 /** 592 * Returns a class instance for the specified class. 593 * @param className the name of the class. 594 * @param remoteCodebase a space-separated list of URLs at which 595 * the class might be found. May be null. 596 * @param loader a class whose ClassLoader may be used to 597 * load the class if all other methods fail. 598 * @return the <code>Class</code> object representing the loaded class. 599 * @exception ClassNotFoundException if class cannot be loaded. 600 */ 601 public Class loadClass( String className, String remoteCodebase, 602 ClassLoader loader) throws ClassNotFoundException 603 { 604 return JDKBridge.loadClass(className,remoteCodebase,loader); 605 } 606 607 /** 608 * The <tt>isLocal</tt> method has the same semantics as the 609 * ObjectImpl._is_local method, except that it can throw a RemoteException. 610 * (no it doesn't but the spec says it should.) 611 * 612 * The <tt>_is_local()</tt> method is provided so that stubs may determine 613 * if a particular object is implemented by a local servant and hence local 614 * invocation APIs may be used. 615 * 616 * @param stub the stub to test. 617 * 618 * @return The <tt>_is_local()</tt> method returns true if 619 * the servant incarnating the object is located in the same process as 620 * the stub and they both share the same ORB instance. The <tt>_is_local()</tt> 621 * method returns false otherwise. The default behavior of <tt>_is_local()</tt> is 622 * to return false. 623 * 624 * @throws RemoteException The Java to IDL specification does to 625 * specify the conditions that cause a RemoteException to be thrown. 626 */ 627 public boolean isLocal(javax.rmi.CORBA.Stub stub) throws RemoteException 628 { 629 boolean result = false ; 630 631 try { 632 org.omg.CORBA.portable.Delegate delegate = stub._get_delegate() ; 633 if (delegate instanceof CorbaClientDelegate) { 634 // For the Sun ORB 635 CorbaClientDelegate cdel = (CorbaClientDelegate)delegate ; 636 ContactInfoList cil = cdel.getContactInfoList() ; 637 if (cil instanceof CorbaContactInfoList) { 638 CorbaContactInfoList ccil = (CorbaContactInfoList)cil ; 639 LocalClientRequestDispatcher lcs = ccil.getLocalClientRequestDispatcher() ; 640 result = lcs.useLocalInvocation( null ) ; 641 } | 421 String abstractBaseID = "IDL:omg.org/CORBA/AbstractBase:1.0"; 422 423 return orb.create_abstract_interface_tc(abstractBaseID, ""); 424 } 425 426 /** 427 * Reads a java.lang.Object as a CORBA any. 428 * @param in the stream from which to read the any. 429 * @return the object read from the stream. 430 */ 431 public Object readAny(InputStream in) 432 { 433 Any any = in.read_any(); 434 if ( any.type().kind().value() == TCKind._tk_objref ) 435 return any.extract_Object (); 436 else 437 return any.extract_Value(); 438 } 439 440 /** 441 * Writes a java.lang.Object as a CORBA Object. If {@code obj} is 442 * an exported RMI-IIOP server object, the tie is found 443 * and wired to {@code obj}, then written to {@code out.write_Object(org.omg.CORBA.Object)}. 444 * If {@code obj} is a CORBA Object, it is written to 445 * {@code out.write_Object(org.omg.CORBA.Object)}. 446 * @param out the stream in which to write the object. 447 * @param obj the object to write. 448 */ 449 public void writeRemoteObject(OutputStream out, java.lang.Object obj) 450 { 451 // Make sure we have a connected object, then 452 // write it out... 453 454 Object newObj = Utility.autoConnect(obj,out.orb(),false); 455 out.write_Object((org.omg.CORBA.Object)newObj); 456 } 457 458 /** 459 * Writes a java.lang.Object as either a value or a CORBA Object. 460 * If {@code obj} is a value object or a stub object, it is written to 461 * {@code out.write_abstract_interface(java.lang.Object)}. If {@code obj} is an exported 462 * RMI-IIOP server object, the tie is found and wired to {@code obj}, 463 * then written to {@code out.write_abstract_interface(java.lang.Object)}. 464 * @param out the stream in which to write the object. 465 * @param obj the object to write. 466 */ 467 public void writeAbstractObject( OutputStream out, java.lang.Object obj ) 468 { 469 // Make sure we have a connected object, then 470 // write it out... 471 472 Object newObj = Utility.autoConnect(obj,out.orb(),false); 473 ((org.omg.CORBA_2_3.portable.OutputStream)out).write_abstract_interface(newObj); 474 } 475 476 /** 477 * Registers a target for a tie. Adds the tie to an internal table and calls 478 * {@link Tie#setTarget} on the tie object. 479 * @param tie the tie to register. 480 * @param target the target for the tie. 481 */ 482 public void registerTarget(javax.rmi.CORBA.Tie tie, java.rmi.Remote target) 483 { 578 { 579 return valueHandlerSingleton; 580 } 581 582 /** 583 * Returns the codebase, if any, for the given class. 584 * @param clz the class to get a codebase for. 585 * @return a space-separated list of URLs, or null. 586 */ 587 public String getCodebase(java.lang.Class clz) { 588 return RMIClassLoader.getClassAnnotation(clz); 589 } 590 591 /** 592 * Returns a class instance for the specified class. 593 * @param className the name of the class. 594 * @param remoteCodebase a space-separated list of URLs at which 595 * the class might be found. May be null. 596 * @param loader a class whose ClassLoader may be used to 597 * load the class if all other methods fail. 598 * @return the {@code Class} object representing the loaded class. 599 * @exception ClassNotFoundException if class cannot be loaded. 600 */ 601 public Class loadClass( String className, String remoteCodebase, 602 ClassLoader loader) throws ClassNotFoundException 603 { 604 return JDKBridge.loadClass(className,remoteCodebase,loader); 605 } 606 607 /** 608 * The {@code isLocal} method has the same semantics as the 609 * ObjectImpl._is_local method, except that it can throw a RemoteException. 610 * (no it doesn't but the spec says it should.) 611 * 612 * The {@code _is_local()} method is provided so that stubs may determine 613 * if a particular object is implemented by a local servant and hence local 614 * invocation APIs may be used. 615 * 616 * @param stub the stub to test. 617 * 618 * @return The {@code _is_local()} method returns true if 619 * the servant incarnating the object is located in the same process as 620 * the stub and they both share the same ORB instance. The {@code _is_local()} 621 * method returns false otherwise. The default behavior of {@code _is_local()} is 622 * to return false. 623 * 624 * @throws RemoteException The Java to IDL specification does to 625 * specify the conditions that cause a RemoteException to be thrown. 626 */ 627 public boolean isLocal(javax.rmi.CORBA.Stub stub) throws RemoteException 628 { 629 boolean result = false ; 630 631 try { 632 org.omg.CORBA.portable.Delegate delegate = stub._get_delegate() ; 633 if (delegate instanceof CorbaClientDelegate) { 634 // For the Sun ORB 635 CorbaClientDelegate cdel = (CorbaClientDelegate)delegate ; 636 ContactInfoList cil = cdel.getContactInfoList() ; 637 if (cil instanceof CorbaContactInfoList) { 638 CorbaContactInfoList ccil = (CorbaContactInfoList)cil ; 639 LocalClientRequestDispatcher lcs = ccil.getLocalClientRequestDispatcher() ; 640 result = lcs.useLocalInvocation( null ) ; 641 } |