Mapping Clients  «Prev  Next»
Lesson 5 Skeletons: Inheritance-based implementation
Objective Use inheritance-based skeletons.

Skeletons and Inheritance-based Implementation

Hooking an implementation object into a CORBA system requires hooking it up to a skeleton, which then provides a connection to the communications plumbing that is the ORB. The simplest way to hook an implementation class into a skeleton is through inheritance.

Skeletons

Skeleton classes themselves inherit from the org.omg.PortableServer.Servant base class (via DynamicImplementation, for DSI-based skeletons). They also implement the corresponding operations interface, the methods of which must be implemented by the subclassing implementation object. The skeleton contains dispatching code and utility methods, which are inherited by implementation subclasses.

Compactly Stated:

In a nutshell, you write inheritance-based implementations by:
  1. Making your implementation class extend the skeleton class
  2. Implementing all the methods inherited from the given operations interface

Inheritance-based skeleton hierarchy
Inheritance-based skeleton hierarchy

Example

Let us look at a concrete example by writing an inheritance-based implementation class for the Weather Service from the previous lesson.
We will extend the POA_WeatherService skeleton and implement the methods from the WeatherServiceOperations interface shown previously:

package weather;
//Inheritance based Implementation
public class WeatherServiceImpl extends POA_WeatherService{
 public java.lang.String getReport(java.lang.String city) {
  return "Sunny with a chance of objects";
 }
}

The obvious benefit of this approach is simplicity, because an instance of the implementation is its own skeleton via inheritance.
In the next lesson, you will learn to use the alternative approach of writing delegation-based implementation classes.