Using Tie for CORBA Applications

In our previous examples, we created servant class extending a class (idlj generated). This type of servant implementation is referred to as inheritance model. The problem of this model is that servant cannot extend another class (if it is required) as Java supports only single inheritance for classes. To eliminate this problem, another model (called tie/delegation model) is introduced where servant need not inherit an IDL generated class and hence can extend another class if it is necessary. The drawback of tie model is that it introduces a level of indirection: one extra method call occurs when invoking a method.

In this section, we shall develop server-side of our calculator application using tie model. The servant class is created as follows:

class SimpleCalculator implements CalculatorOperations {



Not that this class simply implements an interface, the CalculatorOperations interface. Since, it does not extend any class, a slot is still there to extend another class. However, this class is an ordinary class and hence an object of this class cannot act as a servant in CORBA environment. The POA cannot bind this object and cannot create an IOR using servant_to_reference() method and hence, delete the following line from

org.omg.CORBA.Object ref = rootpoa.servant_to_reference(cal);

So, how do you publish a SimpleCalculator object in CORBA then? The object is tied with POA explicitly using a special class (called tie class). This class may be generated by the idlj compiler using -falltie option as follows:

idlj -falltie Calculator.idl

This command, in addition to other files, generates a tie file with name To tie our SimpleCalculator object with root POA, we create a CalculatorPOATie object as follows:

CalculatorPOATie tie = new CalculatorPOATie(cal, rootpoa);

Now get the IOR as follows:

Calculator ref = tie._this(orb);

This step also implicitly activates the object. Also add the following import statement:

import CalculatorApp.*;

The rest of the code is same as before. The server is now ready to work. Compile and start the server as before.

Source: Uttam Kumar Roy (2015), Advanced Java programming, Oxford University Press.

Leave a Reply

Your email address will not be published. Required fields are marked *