7 hello.idlから生成されたコード
7.1 Hello
// Tue Aug 26 11:57:35 EDT 2003
package helloWorld;
public interface Hello extends org.omg.CORBA.Object, org.omg.CORBA.portable.IDLEntity, helloWorld.HelloOperations
{
}
7.2 HelloOperations
// Tue Aug 26 11:57:35 EDT 2003
package helloWorld;
public interface HelloOperations
{
public java.lang.String sayHello();
}
7.3 HelloHelper
// Tue Aug 26 11:57:35 EDT 2003
package helloWorld;
/** Helper for Hello */
public final class HelloHelper
{
// get the singleton ORB
private static final org.omg.CORBA.ORB _orb() {
| return org.omg.CORBA.ORB.init();
}
// read Hello
public static helloWorld.Hello read(org.omg.CORBA.portable.InputStream _is)
{
| return helloWorld.HelloHelper.narrow(_is.read_Object());
}
// write Hello
public static void write(org.omg.CORBA.portable.OutputStream _os, helloWorld.Hello _value)
{
| _os.write_Object(_value);
}
private static org.omg.CORBA.TypeCode _type;
// typecode for Hello
public static org.omg.CORBA.TypeCode type()
{
| if (_type == null) {
| | synchronized(org.omg.CORBA.TypeCode.class) {
| | | if (_type == null) {
| | | | _type = _orb().create_interface_tc(id(), "Hello");
| | | }
| | }
| }
|
| return _type;
}
// insert Hello
public static void insert(org.omg.CORBA.Any any, helloWorld.Hello value)
{
| org.omg.CORBA.portable.OutputStream os = any.create_output_stream();
| any.type(type());
| write(os, value);
| any.read_value(os.create_input_stream(), type());
}
// extract Hello
public static helloWorld.Hello extract(org.omg.CORBA.Any any)
{
| return read(any.create_input_stream());
}
// repository Id for Hello
public static String id() {
| return "IDL:helloWorld/Hello:1.0";
}
// narrow to Hello
public static helloWorld.Hello narrow(org.omg.CORBA.Object _object)
{
| if (_object == null) return null;
|
| // check for expected Stub
| if (_object.getClass() == _stubClass)
| return (helloWorld.Hello) _object;
|
| // test for type
| if (!_object._is_a(id()))
| throw new org.omg.CORBA.BAD_PARAM();
|
| // create the stub
| helloWorld._HelloStub stub = null;
| try {
| | stub = (helloWorld._HelloStub) _stubClass.newInstance();
| } catch (Exception ex) {
| | throw new org.omg.CORBA.UNKNOWN(ex.toString());
| }
|
| // set the delegate in the stub
| org.omg.CORBA.portable.Delegate delegate =
| ((org.omg.CORBA.portable.ObjectImpl) _object)._get_delegate();
| stub._set_delegate(delegate);
|
| return stub;
}
private static java.lang.Class _stubClass = helloWorld._HelloStub.class;
}
7.4 HelloHolder
// Tue Aug 26 11:57:35 EDT 2003
package helloWorld;
/** Holder for Hello */
public final class HelloHolder implements org.omg.CORBA.portable.Streamable
{
// instance variable
public helloWorld.Hello value;
// constructors
public HelloHolder() {}
public HelloHolder(helloWorld.Hello value) {
| this.value = value;
}
// _read method
public void _read(org.omg.CORBA.portable.InputStream is) {
| value = helloWorld.HelloHelper.read(is);
}
// _write method
public void _write(org.omg.CORBA.portable.OutputStream os) {
| helloWorld.HelloHelper.write(os, value);
}
// _type method
public org.omg.CORBA.TypeCode _type() {
| return helloWorld.HelloHelper.type();
}
}
7.5 _HelloImplBase
// Tue Aug 26 11:57:35 EDT 2003
package helloWorld;
/** Stream based Skeleton for Hello */
public abstract class _HelloImplBase
extends org.omg.CORBA.portable.ObjectImpl
implements helloWorld.Hello, org.omg.CORBA.portable.InvokeHandler
{
// the method dispatch table
private static final java.util.Dictionary _mtable =
new java.util.Hashtable();
static {
| _mtable.put("sayHello", new java.lang.Integer(0));
}
// dispatch to invoke handler
public org.omg.CORBA.portable.OutputStream _invoke(String _method,
org.omg.CORBA.portable.InputStream _is,
org.omg.CORBA.portable.ResponseHandler _rh)
{
| org.omg.CORBA.portable.OutputStream _os = null;
| // get the method Id
|
| java.lang.Integer _methodId = (java.lang.Integer) _mtable.get(_method);
| if (_methodId == null) throw new org.omg.CORBA.BAD_OPERATION();
|
| // invoke the method
| switch (_methodId.intValue())
| {
| | case 0: {
| | |
| | | // invoke the method
| | | java.lang.String _result = this.sayHello();
| | |
| | | // create the output stream
| | | _os = _rh.createReply();
| | |
| | | // marshal the result
| | | _os.write_string(_result);
| | }
| | break;
| }
|
| // return the output stream
| return _os;
}
private static final java.lang.String __ids[] = {
| "IDL:helloWorld/Hello:1.0"
};
public java.lang.String[] _ids() {
| return __ids;
}
}
7.6 _HelloTie
// Tue Aug 26 11:57:35 EDT 2003
package helloWorld;
/** Stream based TIE Skeleton for Hello */
public class _HelloTie extends helloWorld._HelloImplBase
{
private helloWorld.HelloOperations _delegate;
public _HelloTie(helloWorld.HelloOperations delegate) {
| this._delegate = delegate;
}
public helloWorld.HelloOperations _delegate() {
| return _delegate;
}
public void _delegate(helloWorld.HelloOperations delegate) {
| _delegate = delegate;
}
public java.lang.String sayHello()
{
| return _delegate.sayHello();
}
}
7.7 _HelloStub
デフォルト設定により、idl2javaコンパイラは、ローカル呼び出しに有効なスタブを生成します。ローカルで実行されるオブジェクトの場合、パラメータおよびIIOPのマーシャル/マーシャル解除は、サーバントオブジェクトで直接コールを行うためにバイパスされます。idl2javaコンパイラで-nolocalフラグを使用すると、このスタブを無効に設定できます。
// Tue Aug 26 11:57:35 EDT 2003
package helloWorld;
/** Stub for Hello */
public class _HelloStub extends org.omg.CORBA.portable.ObjectImpl
implements helloWorld.Hello
{
public _HelloStub()
{
| super();
}
public java.lang.String sayHello()
{
| _local_stub:
|
| if (_get_delegate().is_local(this)) {
| |
| | // get the Servant Object
| | org.omg.CORBA.portable.ServantObject _servObj =
| | _servant_preinvoke("sayHello", helloWorld.HelloOperations.class);
| | if (_servObj == null) break _local_stub;
| |
| | try {
| | |
| | | // invoke on the servant
| | | return ((helloWorld.HelloOperations) _servObj.servant).sayHello();
| | |
| | } finally {
| | | _servant_postinvoke(_servObj);
| | }
| }
|
| org.omg.CORBA.portable.InputStream _is = null;
|
| try {
| | try {
| | | // create a request
| | | org.omg.CORBA.portable.OutputStream _os =
| | | _request("sayHello", true);
| | |
| | | // do the invocation
| | | _is = _invoke(_os);
| | |
| | | // unmarshal the result
| | | java.lang.String _result = _is.read_string();
| | |
| | | // return the result
| | | return _result;
| | |
| | } catch (org.omg.CORBA.portable.ApplicationException _ex) {
| | |
| | | // read the exception id
| | | _is = _ex.getInputStream();
| | | String _id = _ex.getId();
| | |
| | | // no matching exception found
| | | throw new org.omg.CORBA.UNKNOWN(_id);
| | |
| | } catch (org.omg.CORBA.portable.RemarshalException _rex) {
| | | return sayHello();
| | }
| } finally {
| | _releaseReply(_is);
| }
}
private static final java.lang.String __ids[] = {
| "IDL:helloWorld/Hello:1.0"
};
public java.lang.String[] _ids() {
| return __ids;
}
}