Next Previous Up Top Contents Index

2.6 Implementing the server

2.6.2 Implementing the server's CORBA objects

According to the IDL we wrote, the server is supposed to provide world objects, which have an operation called hello. How do we implement world and hello in the server?

An IDL interface, such as world, is represented in Dylan using a class. Operations in an interface are represented as methods on the class representing the interface.

The server skeletons library we generated by compiling our IDL file contains the underlying CORBA framework for world objects. This framework is represented by the <world-servant> Dylan class.

A servant is the CORBA way of connecting a request to an object implementation. In this case the mapping will be one-to-one: a servant will be the object implementation. However, many objects could be implemented by one servant, or conversely, many servants could implement a single object. These more complicated applications of servants need not concern us now.

The <world-servant> class is a subclass of <world> (again from the protocol library) and another class that provides CORBA functionality. By extending <world-servant> we provide a Dylan implementation of world and inherit the CORBA functionality that our objects will need in order to communicate with their clients:

define class <world-implementation> (<world-servant>)
end class;

As noted in "Invoking an operation" on page 17, the hello operation name was mapped into Dylan as the world/hello generic function, defined on <world>. To implement hello, we write a world/hello method on <world-implementation>:

define method world/hello (world :: <world-implementation>)
    => (hello :: <string>)
  "Hello World!"
end method;

This method returns the string that will be passed back to the client. With this, the Dylan implementation of the world object type we described in IDL is complete.


Developing Component Software with CORBA - 26 May 1999

Next Previous Up Top Contents Index