< prev index next >

src/java.corba/share/classes/com/sun/jndi/toolkit/corba/CorbaUtils.java

Print this page




  39 import javax.naming.Context;
  40 import javax.naming.ConfigurationException;
  41 import javax.rmi.CORBA.Stub;
  42 import javax.rmi.PortableRemoteObject;
  43 
  44 /**
  45   * Contains utilities for performing CORBA-related tasks:
  46   * 1. Get the org.omg.CORBA.Object for a java.rmi.Remote object.
  47   * 2. Create an ORB to use for a given host/port, and environment properties.
  48   *
  49   * @author Simon Nash
  50   * @author Bryan Atsatt
  51   */
  52 
  53 public class CorbaUtils {
  54     /**
  55       * Returns the CORBA object reference associated with a Remote
  56       * object by using the javax.rmi.CORBA package.
  57       *<p>
  58       * This method effective does the following:
  59       *<blockquote><pre>
  60       * java.lang.Object stub;
  61       * try {
  62       *     stub = PortableRemoteObject.toStub(remoteObj);
  63       * } catch (Exception e) {
  64       *     throw new ConfigurationException("Object not exported or not found");
  65       * }
  66       * if (!(stub instanceof javax.rmi.CORBA.Stub)) {
  67       *     return null; // JRMP impl or JRMP stub
  68       * }
  69       * try {
  70       *     ((javax.rmi.CORBA.Stub)stub).connect(orb);  // try to connect IIOP stub
  71       * } catch (RemoteException e) {
  72       *     // ignore 'already connected' error
  73       * }
  74       * return (javax.rmi.CORBA.Stub)stub;

  75       *
  76       * @param remoteObj The non-null remote object for
  77       * @param orb       The non-null ORB to connect the remote object to
  78       * @return The CORBA Object for remoteObj; null if <tt>remoteObj</tt>
  79       *                 is a JRMP implementation or JRMP stub.
  80       * @exception ConfigurationException The CORBA Object cannot be obtained
  81       *         because of configuration problems.
  82       */
  83     public static org.omg.CORBA.Object remoteToCorba(Remote remoteObj, ORB orb)
  84         throws ConfigurationException {
  85 
  86 // First, get remoteObj's stub
  87 
  88             // javax.rmi.CORBA.Stub stub = PortableRemoteObject.toStub(remoteObj);
  89 
  90             Remote stub;
  91 
  92             try {
  93                 stub = PortableRemoteObject.toStub(remoteObj);
  94             } catch (Throwable t) {




  39 import javax.naming.Context;
  40 import javax.naming.ConfigurationException;
  41 import javax.rmi.CORBA.Stub;
  42 import javax.rmi.PortableRemoteObject;
  43 
  44 /**
  45   * Contains utilities for performing CORBA-related tasks:
  46   * 1. Get the org.omg.CORBA.Object for a java.rmi.Remote object.
  47   * 2. Create an ORB to use for a given host/port, and environment properties.
  48   *
  49   * @author Simon Nash
  50   * @author Bryan Atsatt
  51   */
  52 
  53 public class CorbaUtils {
  54     /**
  55       * Returns the CORBA object reference associated with a Remote
  56       * object by using the javax.rmi.CORBA package.
  57       *<p>
  58       * This method effective does the following:
  59       * <blockquote><pre>
  60       * java.lang.Object stub;
  61       * try {
  62       *     stub = PortableRemoteObject.toStub(remoteObj);
  63       * } catch (Exception e) {
  64       *     throw new ConfigurationException("Object not exported or not found");
  65       * }
  66       * if (!(stub instanceof javax.rmi.CORBA.Stub)) {
  67       *     return null; // JRMP impl or JRMP stub
  68       * }
  69       * try {
  70       *     ((javax.rmi.CORBA.Stub)stub).connect(orb);  // try to connect IIOP stub
  71       * } catch (RemoteException e) {
  72       *     // ignore 'already connected' error
  73       * }
  74       * return (javax.rmi.CORBA.Stub)stub;
  75       * </pre></blockquote>
  76       *
  77       * @param remoteObj The non-null remote object for
  78       * @param orb       The non-null ORB to connect the remote object to
  79       * @return The CORBA Object for remoteObj; null if <tt>remoteObj</tt>
  80       *                 is a JRMP implementation or JRMP stub.
  81       * @exception ConfigurationException The CORBA Object cannot be obtained
  82       *         because of configuration problems.
  83       */
  84     public static org.omg.CORBA.Object remoteToCorba(Remote remoteObj, ORB orb)
  85         throws ConfigurationException {
  86 
  87 // First, get remoteObj's stub
  88 
  89             // javax.rmi.CORBA.Stub stub = PortableRemoteObject.toStub(remoteObj);
  90 
  91             Remote stub;
  92 
  93             try {
  94                 stub = PortableRemoteObject.toStub(remoteObj);
  95             } catch (Throwable t) {


< prev index next >