6 HelloImpl.javaから生成されたコード

6.1 _Hello_Stub

デフォルト設定により、rmi2iiopコンパイラは、ローカル呼び出しに有効なすタグを生成します。ローカルで実行されるオブジェクトの場合、シリアル化可能なパラメータの完全なコピーが作成され、セマンティックを渡すRMIパラメータ (非リモートパラメータの値、およびポインタ共有により渡す)を維持し、IIOPはサーバントオブジェクトの直接呼び出しを行うためにバイパスされます。

rmi2iiopコンパイラで-localnocopyフラグを指定することにより、パラメータのコピーを使用禁止にできます。-nolocalフラグを使用することにより、まとめてローカルスタブの生成をスキップできます。

// Tue Aug 26 11:57:20 EDT 2003
                                                                           
package helloWorld2;
                                                                           
                                                                           
public class _Hello_Stub extends javax.rmi.CORBA.Stub
    implements helloWorld2.Hello
{
    private static final String[] __ids = {
    |   "RMI:helloWorld2.Hello:0000000000000000"
    };
                                                                           
    public String[] _ids() { return __ids; }
                                                                           
    public java.lang.String sayHello()
        throws java.rmi.RemoteException
    {
    |   _local_stub:
    |                                                                      
    |   if (javax.rmi.CORBA.Util.isLocal(this)) {
    |   |                                                                  
    |   |   // get the Servant Object
    |   |   org.omg.CORBA.portable.ServantObject _servObj =
    |   |       _servant_preinvoke("sayHello", helloWorld2.Hello.class);
    |   |   if (_servObj == null) break _local_stub;
    |   |                                                                  
    |   |   try {
    |   |   |   // invoke on the servant
    |   |   |   return ((helloWorld2.Hello) _servObj.servant).sayHello();
    |   |   |                                                              
    |   |   } catch (Throwable ex) {
    |   |   |   // copy the exception
    |   |   |   ex = (Throwable) javax.rmi.CORBA.Util.copyObject(ex, _orb());
    |   |   |                                                              
    |   |   |   throw javax.rmi.CORBA.Util.wrapException(ex);
    |   |   |                                                              
    |   |   } finally {
    |   |   |   _servant_postinvoke(_servObj);
    |   |   }
    |   }
    |                                                                      
    |   org.omg.CORBA_2_3.portable.InputStream in = null;
    |                                                                      
    |   try {
    |   |   try {
    |   |   |   // create an output stream
    |   |   |   org.omg.CORBA_2_3.portable.OutputStream out =
    |   |   |       (org.omg.CORBA_2_3.portable.OutputStream)
    |   |   |        _request("sayHello", true);
    |   |   |                                                              
    |   |   |   // do the invocation
    |   |   |   in = (org.omg.CORBA_2_3.portable.InputStream) _invoke(out);
    |   |   |   return (java.lang.String) in.read_value(java.lang.String.class);
    |   |   |                                                              
    |   |   } catch (org.omg.CORBA.portable.ApplicationException ex) {
    |   |   |                                                              
    |   |   |   // get the input stream
    |   |   |   in = (org.omg.CORBA_2_3.portable.InputStream)
    |   |   |       ex.getInputStream();
    |   |   |                                                              
    |   |   |   // read the exception id
    |   |   |   String id = ex.getId();
    |   |   |   in.read_string();
    |   |   |                                                              
    |   |   |   // unexpected exception
    |   |   |   throw new java.rmi.UnexpectedException(id);
    |   |   |                                                              
    |   |   } catch (org.omg.CORBA.portable.RemarshalException rex) {
    |   |   |   return sayHello();
    |   |   |                                                              
    |   |   } finally {
    |   |   |   _releaseReply(in);
    |   |   }
    |   |                                                                  
    |   } catch (org.omg.CORBA.SystemException ex) {
    |   |   throw javax.rmi.CORBA.Util.mapSystemException(ex);
    |   }
    }
                                                                           
}

6.2 _HelloImpl_Tie

// Tue Aug 26 11:57:20 EDT 2003
                                                                           
package helloWorld2;
                                                                           
                                                                           
public class _HelloImpl_Tie
    extends javax.rmi.CORBA.Stub
    implements javax.rmi.CORBA.Tie, helloWorld2.Hello
{
    private org.omg.CORBA.portable.ObjectImpl _thisObject;
                                                                           
    public synchronized org.omg.CORBA.Object thisObject()
    {
    |   if (_thisObject == null) {
    |   |   try {
    |   |   |   // create the stub
    |   |   |   _thisObject = (org.omg.CORBA.portable.ObjectImpl)
    |   |   |       Class.forName("helloWorld2._Hello_Stub").newInstance();
    |   |   |                                                              
    |   |   |   // set the delegate in the stub
    |   |   |   try {
    |   |   |   |   _thisObject._set_delegate(_get_delegate());
    |   |   |   } catch (org.omg.CORBA.BAD_OPERATION ex) {}
    |   |   |                                                              
    |   |   } catch (java.lang.Exception ex) {
    |   |   |   throw new java.lang.RuntimeException("unable to create stub");
    |   |   }
    |   }
    |                                                                      
    |   return _thisObject;
    }
                                                                           
    public org.omg.CORBA.ORB orb()
    {
    |   return _orb();
    }
                                                                           
    public void orb(org.omg.CORBA.ORB orb)
    {
    |   orb.connect(this);
    }
                                                                           
    private static final String[] __ids = {
    |   "RMI:helloWorld2.Hello:0000000000000000"
    };
                                                                           
    public String[] _ids() { return __ids; }
                                                                           
    public synchronized void deactivate()
    {
    |   _orb().disconnect(this);
    |   _thisObject = null;
    }
                                                                           
    private helloWorld2.HelloImpl _target;
                                                                           
    public void setTarget(java.rmi.Remote target)
    {
    |   _target = (helloWorld2.HelloImpl) target;
    }
                                                                           
    public java.rmi.Remote getTarget()
    {
    |   return _target;
    }
                                                                           
    public org.omg.CORBA.portable.OutputStream _invoke(String method,
        org.omg.CORBA.portable.InputStream in1,
        org.omg.CORBA.portable.ResponseHandler rh)
    {
    |   org.omg.CORBA_2_3.portable.InputStream in =
    |       (org.omg.CORBA_2_3.portable.InputStream) in1;
    |   org.omg.CORBA_2_3.portable.OutputStream out = null;
    |                                                                      
    |   try {
    |   |   if (method.equals("sayHello")) {
    |   |   |   java.lang.String result = _target.sayHello();
    |   |   |   out = (org.omg.CORBA_2_3.portable.OutputStream)
    |   |   |       rh.createReply();
    |   |   |   out.write_value(result, java.lang.String.class);
    |   |   }
    |   |                                                                  
    |   |   else throw new org.omg.CORBA.BAD_OPERATION(method);
    |   |                                                                  
    |   } catch (org.omg.CORBA.SystemException ex) {
    |   |   throw ex;
    |   |                                                                  
    |   } catch (java.lang.Throwable ex) {
    |   |   throw new org.omg.CORBA.portable.UnknownException(ex);
    |   }
    |                                                                      
    |   return out;
    }
                                                                           
                                                                           
    public java.lang.String sayHello() throws java.rmi.RemoteException
    {
    |   return _target.sayHello();
    }
}
Copyright © 2000-2003, Novell, Inc.All rights reserved.