Defining the interface for a CORBA servant class

Why and when to perform this task

Use this task to define the public interface of a CORBA servant class. It provides the business logic to be used by clients. This defines the information that a client must know to call and use servant objects of that class and forms one stage of the tasks to develop a CORBA server or client.

Steps for this task

  1. Create an IDL file, servant.idl, where servant is the name of the server implementation class.
    This step results in a fully specified servant.idl file.
  2. Edit the servant.idl file to add an interface definition.
    The interface definition declares the interface name (and optionally its base interface names) and the methods (operations), and any constants, type definitions, and exception structures that the interface exports.

    The following information is an overview of the format of an interface declaration. It provides links to the reference topics that describe parts of the IDL declaration and IDL syntax. For reference information about IDL interface declarations and the component declarations that they can contain, see IDL interface declarations.

    An interface declaration has the following syntax:

    interface  interface-name
     [: base-interface1, base-interface2, ...]
      {
       [constant declarations]
       [type declarations]
       [exception declarations]
       [attribute declarations]
       [operation declarations]
     };
    
    interface-name
    The name of the public interface for the servant object. This should match the servant class name.
    [: base-interface1, base-interface2, ...]
    The base interface names for one or more parent interfaces from which this interface, interface-name, is derived.

    Specify base interface names only if this interface is derived from one or more parent interfaces. Each base interface is specified in the form, interface_name, and can be named only once in the interface statement header. If you specify a base interface name, you also must add an include statement for the base interface IDL file to the top of the servant.idl file.

    [constant declarations] and [type declarations]
    An interface declaration can include constant declarations and type declarations, as in C and C++, with some restrictions and extensions. For more information about these declaration types, see IDL type and constant declarations.
    [exception declarations]
    An interface declaration can include exception declarations that define data structures to be returned when an exception occurs during the execution of an operation. Each exception declaration specifies a name and, optionally, a struct-like data structure for holding error information. For more information about these declaration types, see IDL exception declarations.
    [attribute declarations]
    Declaring an attribute as part of an interface is equivalent to declaring one or two accessor operations: one to retrieve the value of the attribute (a get or read operation) and, unless the attribute specifies read only, one to set the value of the attribute (a set or write operation). For more information about these declaration types, see IDL attribute declarations.
    [operation declarations]
    Operation declarations define the interface of each operation introduced by the interface. An IDL operation typically is implemented by a method in the implementation programming language. Hence, the terms operation and method often are used interchangeably. For more information about these declaration types, see IDL operation declarations.

    The order in which these declarations are specified is usually optional and declarations of different kinds can be intermixed. Although all of the declarations listed previously are optional, in some cases using one declaration can mandate another. For example, if an operation raises an exception, the exception structure must be defined beforehand. In general, types, constants, and exceptions, as well as interface declarations, must be defined before they are referenced, as in C or C++.

Results

This task results in a fully specified IDL file, servant.idl, that contains a declaration for the public interface to a servant class, servant.

For example, for a servant class called WSLogger, the IDL file, WSLogger.idl, was created and edited to add the following interface definition:

interface WSLogger
{
  void setFileName(in string newFileName);
  string getFileName();
  void setMethodName( in string newMethodName );
  string getMethodName();
  short openLogFile();
  short closeLogFile();
  short writeLogMessage(in string newMessage, in short newSeverity);
  enum mdyFormat { DMY_DATE_FORMAT,
                   MDY_DATE_FORMAT };
  void setDateFormat(in unsigned short newDateFormat);
  unsigned short getDateFormat();
};

What to do next

Compile the servant.idl to create the usage bindings and other files needed to complete the implementation as described in Compiling the servant IDL (using idlc).

Related tasks
Developing a CORBA C++ server
Related reference
IDL interface declarations
IDL type declarations
IDL exception declarations
IDL attribute declarations
IDL operation declarations



Searchable topic ID:   tcor_pgms1
Last updated: Jun 21, 2007 8:07:48 PM CDT    WebSphere Business Integration Server Foundation, Version 5.0.2
http://publib.boulder.ibm.com/infocenter/wasinfo/index.jsp?topic=/com.ibm.wasee.doc/info/ee/corba/tasks/tcor_pgms1.html

Library | Support | Terms of Use | Feedback