7 Code Generated from hello.idl

7.1 Hello

// Wed Nov 19 16:39:13 EST 2003
                                                                           
package helloWorld;
                                                                           
public interface Hello extends org.omg.CORBA.Object, org.omg.CORBA.portable.IDLEntity, helloWorld.HelloOperations
{
}

7.2 HelloOperations

// Wed Nov 19 16:39:13 EST 2003
                                                                           
package helloWorld;
                                                                           
public interface HelloOperations
{
    public java.lang.String sayHello();
                                                                           
}

7.3 HelloHelper

// Wed Nov 19 16:39:13 EST 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

// Wed Nov 19 16:39:13 EST 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 HelloPOA

// Wed Nov 19 16:39:13 EST 2003
                                                                           
package helloWorld;
                                                                           
/** Stream based POA Skeleton for Hello */
public abstract class HelloPOA
    extends org.omg.PortableServer.Servant
    implements helloWorld.HelloOperations, org.omg.CORBA.portable.InvokeHandler
{
    // the method dispatch table
    private static final java.util.Map _mtable =
        new java.util.HashMap();
    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[] _all_interfaces(org.omg.PortableServer.POA poa, byte[] oid)
    {
    |   return __ids;
    }
                                                                           
    public helloWorld.Hello _this() {
    |   return helloWorld.HelloHelper.narrow(_this_object());
    }
                                                                           
    public helloWorld.Hello _this(org.omg.CORBA.ORB orb) {
    |   return helloWorld.HelloHelper.narrow(_this_object(orb));
    }
}

7.6 HelloPOATie

// Wed Nov 19 16:39:13 EST 2003
                                                                           
package helloWorld;
                                                                           
/** Stream based POA TIE Skeleton for Hello */
public class HelloPOATie extends helloWorld.HelloPOA
{
    private helloWorld.HelloOperations _delegate;
                                                                           
    public HelloPOATie(helloWorld.HelloOperations delegate) {
    |   this._delegate = delegate;
    }
                                                                           
    public helloWorld.HelloOperations _delegate() {
    |   return _delegate;
    }
                                                                           
    public void _delegate(helloWorld.HelloOperations delegate) {
    |   _delegate = delegate;
    }
                                                                           
    private org.omg.PortableServer.POA _poa;
                                                                           
    public HelloPOATie(helloWorld.HelloOperations delegate, org.omg.PortableServer.POA poa)
    {
    |   this._poa      = poa;
    |   this._delegate = delegate;
    }
                                                                           
    public org.omg.PortableServer.POA _default_POA()
    {
    |   if (_poa != null) return _poa;
    |                                                                      
    |   return super._default_POA();
    }
                                                                           
    public java.lang.String sayHello()
    {
    |   return _delegate.sayHello();
    }
}

7.7 _HelloStub

The idl2java compiler by default generates stubs that are enabled for local invocation. For locally running objects, marshaling/unmarshaling of parameters and IIOP is bypassed to do a direct call on the servant object. You can disable this by using the -nolocal flag on the idl2java compiler.

The _servant_preinvoke and _servant_postinvoke give the ORB the opportunity to enfore the POA semantics of POA Manager, adapter activation, object activation etc.

// Wed Nov 19 16:39:13 EST 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;
    }
}
Copyright © 2000-2003, Novell, Inc. All rights reserved.