Mapping Clients  «Prev  Next»
Lesson 6 Skeletons: Delegation-based implementation (TIE)
Objective Use delegation-based skeletons.

Delegation-based Implementation (TIE) using Corba

The inheritance-based approach to skeletons suffers from several drawbacks: It is conceptually unappealing, it may not work with already existing implementation classes, and it uses up Java's single inheritance for the class. The delegation-based approach is usually the preferred alternative.

Delegation-based (TIE) skeleton hierarchy
Delegation-based (TIE) skeleton hierarchy


The TIE class (so called because it ties together an implementation class and the skeleton) generated for an IDL interface is a subclass of the inheritance-based skeleton. The TIE class has a constructor that takes an instance of the corresponding operations interface. The TIE class delegates all the operations methods to the given operations instance.
Thus, to use the delegation-based (TIE) approach to write and use implementation objects, you:
  1. Write an implementation class that implements the operations interface.
  2. Use the implementation by passing an instance of it to the TIE class constructor to instantiate a TIE skeleton.


The TIE generated for the Weather Service example would look like the following:
package weather;
/** stream-based skeleton class */
import org.omg.PortableServer.POA;
public class POA_WeatherService_tie extends POA_WeatherService{
  private WeatherServiceOperations _delegate;
  public POA_WeatherService_tie(WeatherServiceOperations delegate){
    _delegate = delegate;
  public java.lang.String getReport(java.lang.String city){
    return _delegate.getReport(city);
  // More generated code ...

Notice how the getReport() method delegates to the operations instance. We can write an implementation class to be used with this, as follows:
package weather;
//Implementation to be used with TIE class
public class WeatherServiceOperationsImpl 
  implements WeatherServiceOperations
 public java.lang.String getReport(java.lang.
  String city)
  return "Sunny with a chance of objects";

To use this implementation class, the TIE will be instantiated with an instance of the implementation class:
POA_WeatherService_tie weatherTIE = 
new POA_WeatherService_tie new WeatherServiceOperationsImpl());

The TIE approach is clearly a bit more involved than the inheritance approach. It has many benefits, however, including cleaner structure and the ability to work with existing implementation classes that are already part of an inheritance hierarchy.
In the next lesson, you will learn about writing the basic server mainline that creates and manages the implementation objects and makes them available to clients.

Delegations Based implementatio-n - Exercise

Click on the Exercise link below to test your ability to code a server that accesses the Bookstore interface.
Delegations Based implementation - Exercise