Listing 3: Snippets of if_ChartServerStub, if_ChartServerPOA, if_Chartserver, and if_ChartServerOperations

//
// Java code automatically generated by the Orbix 2000 IDL Compiler
// Do not edit this code!
//

/*if_ChartServer: This class is implemented by the client side stub*/
public interface if_ChartServer
  extends if_ChartServerOperations,
  org.omg.CORBA.Object,
  org.omg.CORBA.portable.IDLEntity
{
}


/*if_ChartServerHelper: This Helper file provides several static methods
  needed to manipulate the IDL type. Do not edit this code.*/

public class if_ChartServerHelper
{
  //some not so important functions
  .
  .
  .

  
  //initialize the orb
  public static org.omg.CORBA.ORB _orb()
  {
    return org.omg.CORBA.ORB.init();
  }

  //stringified id for if_ChartServer. You can use this, for example,
  //for creating the IOR. (Refer to the main() function in the class
  //ChartServer, where you call createIOR())
  public static String id()
  {
    return "IDL:chartmanager/if_ChartServer:1.0";
  }

  //some read, write functions
  .
  .
  .

  //This function is used to get back the Java instance of if_ChartServer
  //which is activated by the ChartServer. You can then use this instance
  //to call operation functions on this component.
  public static corba.code.chartmanager.if_ChartServer narrow(
    org.omg.CORBA.Object _obj
  ) throws org.omg.CORBA.BAD_PARAM
  {

    //1. if the CORBA object is null return null
    //2. if the CORBA object is an instance of if_ChartServer typecast it
    //   and return it
    //3. if the CORBA object is the string id create an instance of the 
    //   stub and return the Impl reference

    if (_obj == null)
    {
      return null;
    }
    if (_obj instanceof corba.code.chartmanager.if_ChartServer)
    {
      return (corba.code.chartmanager.if_ChartServer)_obj;
    }
    if (_obj._is_a(id()))
    {
      corba.code.chartmanager._if_ChartServerStub _ref =
        new corba.code.chartmanager._if_ChartServerStub();
      _ref._set_delegate(
       ((org.omg.CORBA.portable.ObjectImpl)_obj)._get_delegate());
      return _ref;
    }
    else
    {
      throw new org.omg.CORBA.BAD_PARAM();
    }
  }

}


/*if_ChartServerHolder: This Holder class is generated to allow support for
  out and inout parameter passing modes. Do not edit this code.*/ 

public final class if_ChartServerHolder
  implements org.omg.CORBA.portable.Streamable
{
  //if_ChartServer object for marshaling
  public corba.code.chartmanager.if_ChartServer value;

  public if_ChartServerHolder() {}

  //to set a different value variable
  public if_ChartServerHolder(
    corba.code.chartmanager.if_ChartServer value
  )
  {
    this.value = value;
  }

  //some read, write and related functions to make 'value'
  //into a input or output streams
  .
  .
  .

}

/*if_ChartServerOperations: Operations class: Contains the 2 operation methods
  of if_ChartServer.This interface is implemented by the OA skeleton class 
  if_ChartServerPOA. Do not edit this code.*/

public interface if_ChartServerOperations

{
   void getCommonProperties(
    org.omg.CORBA.StringHolder scale,
    org.omg.CORBA.StringHolder columns,
    org.omg.CORBA.IntHolder orientation
  );

   void getBarProperties(
    int column,
    corba.code.chartmanager.barPropertiesHolder bProp
  );

}


/* if_ChartServerPOA: The server skeleton class. Do not edit this code. Instead
 derive a Impl class from this. That way whenever the IDL is compiled and this
 file will be over written and your code will not be lost.*/
abstract public class if_ChartServerPOA
  extends org.omg.PortableServer.Servant
  implements org.omg.CORBA.portable.InvokeHandler, if_ChartServerOperations
{

  //narrows and returns a if_ChartServer object, using the helper class
  public corba.code.chartmanager.if_ChartServer _this()
  {
    return corba.code.chartmanager.if_ChartServerHelper.narrow(_this_object());
  }

  //narrows and returns a if_ChartServer object, based on the ORB
  public corba.code.chartmanager.if_ChartServer _this( org.omg.CORBA.ORB orb)
  {
    return corba.code.chartmanager.if_ChartServerHelper.narrow
      (_this_object(orb));
  }

  //This function, called by the stub implementations of getCommonProperties()
  //and getBarProperties(), gets the operations from the hash table (see below),
  //invokes them and returns the output streams. This is part of the marshaling
  //process.
  public org.omg.CORBA.portable.OutputStream _invoke(String opName, 
    org.omg.CORBA.portable.InputStream input, 
    org.omg.CORBA.portable.ResponseHandler handler  )
  {
    java.lang.Object[] _params = {input, handler, this};
    java.lang.reflect.Method _meth = 
     (java.lang.reflect.Method)_if_ChartServer_hashtable.get(opName);
    if (_meth == null)
    throw new org.omg.CORBA.BAD_OPERATION();
    java.lang.Object return_value = null;
    try {
      return_value = _meth.invoke(this, _params);
    } catch (java.lang.reflect.InvocationTargetException ite) {
      throw (RuntimeException)ite.getTargetException();
    } catch (java.lang.IllegalAccessException iae) {
      throw new org.omg.CORBA.BAD_OPERATION();
    }
    return (org.omg.CORBA.portable.OutputStream)return_value;
  }

  //This function creates instances of all the holder parameters needed by
  //getCommonProperties(), calls the function and then converts all the holder 
  //valuesinto output streams and returns it.
  public static org.omg.CORBA.portable.OutputStream _getCommonProperties_static(
    org.omg.CORBA.portable.InputStream _input,
    org.omg.CORBA.portable.ResponseHandler handler, 
    corba.code.chartmanager.if_ChartServerOperations _obj 
  )
  {
    org.omg.CORBA.portable.OutputStream _output = null;
    org.omg.CORBA.StringHolder scale = new org.omg.CORBA.StringHolder();
    org.omg.CORBA.StringHolder columns = new org.omg.CORBA.StringHolder();
    org.omg.CORBA.IntHolder orientation = new org.omg.CORBA.IntHolder();
    _obj.getCommonProperties(scale,columns,orientation);
    _output = handler.createReply();
    _output.write_string(scale.value);
    _output.write_string(columns.value);
    _output.write_long(orientation.value);
    return _output;
  }

  //This function creates instances of all the holder parameters needed by
  //getBarProperties(), calls the function and then converts all the holder 
  //values into output streams and returns it.
  public static org.omg.CORBA.portable.OutputStream _getBarProperties_static(
    org.omg.CORBA.portable.InputStream _input,
    org.omg.CORBA.portable.ResponseHandler handler, 
    corba.code.chartmanager.if_ChartServerOperations _obj 
  )
  {
    org.omg.CORBA.portable.OutputStream _output = null;
    int column;
    column = _input.read_long();
    corba.code.chartmanager.barPropertiesHolder bProp =
      new corba.code.chartmanager.barPropertiesHolder();
    _obj.getBarProperties(column,bProp);
    _output = handler.createReply();
     corba.code.chartmanager.barPropertiesHelper.write(_output, bProp.value);
    return _output;
  }

  
  //returns a string array of ids
  public String[]  _all_interfaces(
    org.omg.PortableServer.POA poa,
    byte[] objectId
  )
  {
    String __ids[] =  {"IDL:chartmanager/if_ChartServer:1.0"};
    return __ids;
  }

   
  //makes a hash table of static interface methods and their parameters
  public static void _if_ChartServer_init_hash(
    java.util.HashMap _hash
  )
  {
    java.lang.Class[] params = {org.omg.CORBA.portable.InputStream.class,
      org.omg.CORBA.portable.ResponseHandler.class,
      corba.code.chartmanager.if_ChartServerOperations.class};
      try {
        _hash.put("getCommonProperties",
          corba.code.chartmanager.if_ChartServerPOA.class.getDeclaredMethod
          ("_getCommonProperties_static", params));
      } catch (java.lang.NoSuchMethodException nsme) {
        throw new org.omg.CORBA.BAD_OPERATION();
      }
      try {
        _hash.put("getBarProperties", 
          corba.code.chartmanager.if_ChartServerPOA.class.getDeclaredMethod
          ("_getBarProperties_static", params));
      } catch (java.lang.NoSuchMethodException nsme) {
        throw new org.omg.CORBA.BAD_OPERATION();
      }
    }

    private static java.util.HashMap _if_ChartServer_hashtable;

    //call init_hash and create the static hash table of operations
    static
    {
      try { 
        _if_ChartServer_hashtable = new java.util.HashMap();
          corba.code.chartmanager.if_ChartServerPOA._if_ChartServer_init_hash
       (_if_ChartServer_hashtable);
      } catch (java.lang.Exception excep) {
        excep.printStackTrace();
      }
    }

}




/*_if_ChartServerStub: This class is the client side stub. This implements 
  the if_ChartServer interface. Marshaling and unmarshaling is done in the
  functions getCommonProperties() and getBarProperties().Do not edit this 
  code. That way whenever the IDL is compiled and this file will be over 
  written and your code will not be lost.*/
public class _if_ChartServerStub
  extends org.omg.CORBA.portable.ObjectImpl
  implements if_ChartServer
{
  final public static java.lang.Class _opsClass =
    if_ChartServerOperations.class;

  public _if_ChartServerStub () {}

  //This function is called whent the client invokes getCommonProperties() of
  //if_ChartServer. In this function first an OutputStream is made with the
  //method name as text. Then '_invoke' of the if_ChartServerPOA class is
  //called with this OutputStream as parameter. The return value of this call
  //is a marshalled InputStream of values. The actual values are then
  //unmarshalled.
  public void getCommonProperties(
    org.omg.CORBA.StringHolder scale,
    org.omg.CORBA.StringHolder columns,
    org.omg.CORBA.IntHolder orientation
  )
  {
    while (true) {
      if(!_is_local()) {
        org.omg.CORBA.portable.OutputStream _output = null;
        org.omg.CORBA.portable.InputStream _input = null;
        try {
        //MARSHALLING
          _output = _request("getCommonProperties", true);
          _input = _invoke(_output);

        //UNMARSHALLING
          scale.value = _input.read_string();
          columns.value = _input.read_string();
          orientation.value = _input.read_long();
          return;
        }
        catch (org.omg.CORBA.portable.RemarshalException _exception) {
          continue;
        }
        catch (org.omg.CORBA.portable.ApplicationException _exception)
        {
          final java.lang.String _exception_id = _exception.getId();
          throw new org.omg.CORBA.UNKNOWN("Unexpected User Exception;" +
                          _exception_id);
        }
        finally {
          _releaseReply(_input);
        }
      }
      else {
        org.omg.CORBA.portable.ServantObject _so = 
          _servant_preinvoke("getCommonProperties", _opsClass);
        if (_so == null) {
          continue;
        }
        if_ChartServerOperations _self = (if_ChartServerOperations)_so.servant;
        try {
          _self.getCommonProperties(scale, columns, orientation);
          return;
        }
        finally {
          _servant_postinvoke(_so);
        }
      }
    }
  }


  //This function is called whent the client invokes getBarProperties() of
  //if_ChartServer. In this function first an OutputStream is made with the
  //method name as text. Then '_invoke' of the if_ChartServerPOA class is
  //called with this OutputStream as parameter. The return value of this
  //call is a marshalled InputStream of values. The actual values are then
  //unmarshalled.
  public void getBarProperties(
    int column,
    corba.code.chartmanager.barPropertiesHolder bProp
  )
  {
    while (true) {
      if(!_is_local()) {
        org.omg.CORBA.portable.OutputStream _output = null;
        org.omg.CORBA.portable.InputStream _input = null;
        try {
          _output = _request("getBarProperties", true);
          _output.write_long(column);
          _input = _invoke(_output);
          bProp.value = corba.code.chartmanager.barPropertiesHelper.read
                  (_input);
          return;
        }
        catch (org.omg.CORBA.portable.RemarshalException _exception) {
          continue;
        }
        catch (org.omg.CORBA.portable.ApplicationException _exception)
        {
          final java.lang.String _exception_id = _exception.getId();
          throw new org.omg.CORBA.UNKNOWN
            ("Unexpected User Exception;" + _exception_id);
        }
        finally {
          _releaseReply(_input);
        }
      }
      else {
        org.omg.CORBA.portable.ServantObject _so =
             _servant_preinvoke("getBarProperties", _opsClass);
        if (_so == null) {
          continue;
        }
        if_ChartServerOperations _self = (if_ChartServerOperations)_so.servant;
        try {
          _self.getBarProperties(column, bProp);
          return;
        }
        finally {
          _servant_postinvoke(_so);
        }
      }
    }
  }


  public static final String _interfaces[] =
  {"IDL:chartmanager/if_ChartServer:1.0"};

  public String[] _ids()
  {
    return _interfaces;
  }

}
— End of Listing —