![]() |
Use this task to define the public interface of a CORBA servant class that is to provide 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.
To specify the public interface for a CORBA servant class, you create an IDL (interface definition language) file that contains an interface declaration:
This steps results in a fully-specified servant.idl file.
The following information is an overview of the format of an interface declaration, and provides links to the reference topics that provide details about 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] };
You need to 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 must also add an include statement for the base-interface IDL file to the top of the servant.idl file.
The order in which these declarations are specified is usually optional, and declarations of different kinds can be intermixed. Although all of the declarations are listed above as 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++.
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(); };
You can 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).
This task is one step of the parent task, Developing a CORBA server.
Related tasks... | |
Parent: Developing a CORBA server | |
Related concepts... | |
The CORBA programming model | |
The CORBA server programming model | |