Mapping Clients  «Prev  Next»
Lesson 8 Interface inheritance
Objective Describe how IDL interface inheritance maps to Java.

IDL Interface Inheritance maps to Java

Now that you have learned more about how Java interfaces and classes are generated from a given IDL interface, we will expand our picture of interface mapping by discussing how IDL interface inheritance affects the generated Java code. This is important because you will frequently need to work with such code.

Interface inheritance Mapping

IDL interface inheritance is reflected in the corresponding generated Java signature and operations interfaces. If the IDL interface Sub extends interface Base, then the generated Java interface SubOperations will extend BaseOperations and the generated Java interface Sub will extend the generated Java interface Base.
The child's stub and skeleton will also be generated to indicate via accessor methods that they support both the child's IDL type and the parent's IDL type.

Weather Service Example As an example, consider the following variation on our basic Weather Service. The IDL has two interfaces, the second of which inherits from the first:

Corba Interface Inheritance

1) We start with the IDL with interface inheritance and generated Java interfaces for the child
1) We start with the IDL with interface inheritance and generated Java interfaces for the child.

2) The operations interface for the child inherits from the operations interface for the parent.
2) The operations interface for the child inherits from the operations interface for the parent.

3) The signature interface for the child inhertis from the signature interface for the parent
3) The signature interface for the child inhertis from the signature interface for the parent


Interface Definition Language (IDL)

An IDL file defines the public application programming interface (API) that is exposed by objects in a server application. The type of a CORBA object is called an interface, which is similar in concept to a C++ class or a Java interface. IDL interfaces support multiple inheritance. An IDL interface may contain operations and attributes. Many people mistakingly assume that an attribute is similar in concept to an instance variable in C++ (a field in Java) and this is wrong. An attribute is simply syntactic sugar for a pair of get- and set-style operations. An attribute can be readonly, in which case it maps to just a get-style operation. The parameters of an operation have a specified direction, which can be in (meaning that the parameter is passed from the client to the server), out (the parameter is passed from the server back to the client) or inout (the parameter is passed in both directions). Operations can also have a return value. An operation can raise (throw) an exception if something goes wrong. There are over 30 predefined exception types, called system exceptions, that all operations can throw, although in practice system exceptions are raised by the CORBA runtime system much more frequently than by application code. In addition to the pre-defined system exceptions, new exception types can be defined in an IDL file. These are called user-defined exceptions. A raises clause on the signature of an operation specifies the user-defined exceptions that it might throw.
This IDL produces the Java code already shown for the Weather Service in previous lessons, as well as the additional code for the new Scoreable Weather Service. In particular, the signature and operations interfaces inherit from their Weather Service counterparts. Java code that uses these interface types can now take advantage of the inheritance that has been mapped from the IDL. In the next lesson, we will return to the work of writing a full CORBA system by learning how to write basic CORBA clients.

Idl Interface Inheritance Mapping - Quiz

Click on the Quiz link below to test your knowledge of IDL interface inheritance mapping.
IDL Interface Inheritance Mapping - Quiz

SEMrush Software