Netscape Internet Service Broker for Java: Reference Guide, Version 1.0

[Contents] [Previous] [Next]

Chapter 3
Generated Classes

This chapter describes the classes that can be generated by the idl2java compiler. It contains the following sections:

Overview

The Helper and Holder classes are provided for all the classes in the org.omg.CORBA package. They are also generated by the idl2java compiler for user-defined types and are given the name of the class that is generated for the type with an additional Holder or Helper suffix. Given a user-defined type named Foo, the idl2java compiler will generate the following:

The Helper Class

An abstract Helper class is generated by the idl2java compiler and contains the utility methods for operating on the associated object. The motivation for the Helper class is to avoid loading the methods that the class offers if they are not needed. The Holder class, also generated by the idl2java compiler, is used when an object needs to be passed as a parameter for an operation request.

For objects like structures, enumerations, and unions, the Helper class provides methods for reading and writing the object to a stream and returning the object's repository identifier. The Helper classes generated for interfaces contain additional methods, like bind and narrow.

The Holder Class

Because the Java language only allows parameters to be passed by value and not by reference, Holder classes are used to support the passing of out and inout parameters associated with operation requests. The interface of the Holder class is consistent for all types.

The Stub Class

The stub class provides stub implementation for <class_name> which the client calls.

The Skeleton Class

A skeleton class is used to derive an implementation class for <class_name>.

The Tie Class

This class inherits from the skeleton class and delegates every call to the real implementation class. For an example of the tie mechanism, see "The Tie Mechanism" in the Netscape Internet Service Broker for Java Programmer's Guide.

The Operations Class

This class defines all of the methods that must be implemented by the object implementation. This class acts as the delegate object for the associated _tie class when the tie mechanism is used. For an example of the tie mechanism, see "The Tie Mechanism" in the Netscape Internet Service Broker for Java Programmer's Guide.

Examples Class

This class provides code you can fill in to implement the object. After adding code, save the file using a different file name. This preserves your work if you run the compiler again and generate another (empty) example file.

<class_name>Helper

abstract public class <class_name>Helper
A Helper class is provided for most classes in the org.omg.COBRA package. Helper classes are also generated by the idl2java compiler for all user-defined types. The suffix Helper is added to the class name that is generated for the type. A variety of static methods are provided to manipulate the class.

Class Methods Interface Methods
extract

bind

id

narrow

insert

read

type

write

public static int[ ] extract(org.omg.CORBA.Any any)
This method extracts the type from the specified Any object.

Parameter Description
any

The Any object to contain the object.

public static String id()
This method gets the repository id for this object.

public static void insert(org.omg.CORBA.Any any, int[ ] seq)
This method inserts a type into the specified Any object.

Parameter Description
any

The Any object to contain the type.

seq

The type to insert.

public static int[ ] read(org.omg.CORBA.portable.InputStream is)
This method reads a type from the specified input stream.

Parameter Description
is

The input stream from which the type is read.

public static org.omg.CORBA.TypeCode type()
This method returns the TypeCode associated with this object. For a list of possible return values see "TCKind."

public static void write(org.omg.CORBA.portable.OutputStream os, int[ ] seq)
This method writes a type to the specified output stream.

Parameter Description
os

The output stream to which the object is written.

seq

The type to be written to the output stream.

Methods Generated for Interfaces

public static <class_name> narrow(org.omg.CORBA.Object object)
This method attempts to narrow a org.omg.CORBA.Object reference to an object of type <class_name>. If the object reference cannot be narrowed, a null value is returned.

Parameter Description
object

The object to be narrowed to the type <class_name>.

public static <class_name> bind(org.omg.CORBA.ORB orb)
This method attempts to bind to any instance of an object of type <class_name>.

public static <class_name> bind(org.omg.CORBA.ORB orb, String name)
This method attempts to bind to an object of type <class_name> that has the specified instance name.

Parameter Description
name

The instance name of the desired object.

public static <class_name> bind(org.omg.CORBA.ORB orb, String name, String host)
This method attempts to bind to an object of type <class_name> that has the specified instance name and which is located on the specified host.

Parameter Description
name

The instance name of the desired object.

host

The host name where the desired object is located.

public static <class_name> bind(org.omg.CORBA.ORB orb, String name, String host, org.omg.CORBA.BindOptions options)
This method attempts to bind to an object of type <class_name> that has the specified instance name and which is located on the specified host, using the specified BindOptions.

Parameter Description
name

The instance name of the desired object.

host

The optional host name where the desired object is located.

options

The bind options for this object.

<class_name>Holder

public class <class_name>Holder
A Holder class is provided for all basic IDL types in the org.omg.CORBA package. Holder classes are also generated by the idl2java compiler for all user-defined types. The suffix Holder is added to the class name that is generated for user-defined types. Each Holder has a set of constructors and a value member, which is the typed value.

The holder classes for the basic types are defined below. They are in the org.omg.CORBA package.

The Holder class for a user defined type <class_name> is shown below:

// Java
final public class <class_name>Holder implements org.omg.CORBA.portable.Streamable {
    public <class_name> value;
    public <class_name>Holder() {};
    public <class_name>Holder(<class_name> initial) {};
    public void _read(org.omg.CORBA.portable.InputStream is)
        {...};
    public void _write(org.omg.CORBA.portable.OutputStream os)
        {...};
    public org.omg.CORBA.TypeCode _type() {...};
}

Member Data

public <class_name> value;
This value represents the type contained by this object.

Methods

public <class_name>Holder()
This default constructor is useful for out parameters. The default constructor sets the value field to the default value for the type as defined by the Java language. The value is set to false for boolean types, 0 for integral and char types, null for strings, and null for object references.

public <class_name>Holder(<class_name> initial)

The initial value constructor is useful for inout parameters. The value of initial is copied from the value field of the specified <class_name> object.

Parameter Description
initial

The initial value of the inout parameter.

<interface_name>Operations

abstract public interface <interface_name>Operations
A Operations class is generated by the idl2java compiler and is meant to contain the implementations of the method for <interface_name>.

_st_<class_name>

abstract public class _st_<class_name>
A stub class is generated by the idl2java compiler to provide a stub implementation for <class_name> which the client calls. This class provides the implementation for transparently acting on an object implementation.

_sk_<class_name>

abstract public class _sk_<class_name>
A skeleton class is generated by the idl2java compiler and is used to derive an implementation class for <class_name>.

_tie_<class_name>

abstract public class <class_name>
A tie class is generated by the idl2java compiler for creating a delegator class for <class_name>.


[Contents] [Previous] [Next]

Last Updated: 02/04/98 14:19:23


Copyright © 1997 Netscape Communications Corporation

Any sample code included above is provided for your use on an "AS IS" basis, under the Netscape License Agreement - Terms of Use