Mapping Clients  «Prev 

Constructing Sample Corba Client

IDL Interfaces

The OMG Interface Definition Language (IDL) is used to define interfaces through which a client is informed of the services supported by an object implementation. OMG IDL is purely a descriptive language so that an interface is defined in a languageneutral way. It enables potential clients to identify the available operations and their invocation methods for a particular object implementation. An interface definition written in OMG IDL completely defines the interface and fully specifies the operation signatures, embracing a set of named operations and the parameters to those operations. Hence in CORBA, the OMG IDL definitions are used to create the stubs and skeletons, as well as to populate the Interface Repository.
To specify the parameter types and return types for operations, OMG IDL provides a set of data types that are similar to those found in a number of programming languages. It supports built-in data types such as long, short, float, double, char and boolean. The sizes, byte ordering and interpretation of all these basic types are precisely defined to ensure interoperability across heterogeneous platforms. OMG IDL also supports constructed types such as struct and discriminated union, and template types such as string and sequence whose exact characteristics are defined at declaration time.

Object Reference Types

More importantly, interfaces are used as object reference types to describe CORBA objects. An operation can take object references as arguments and return the appropriate object references. In addition, OMG IDL provides interface inheritance, allowing derived interfaces to inherit the operations and types defined in the base interfaces. All IDL interfaces are implicitly derived from a root interface called Object defined in the CORBA module, which provides services common to all ORB objects.
CORBA objects, expressed in OMG IDL, are mapped into particular programming languages or object systems according to the specifications of the object interfaces. A client uses the IDL interface specifications, but the actual call is done in the native programming language, as a result of mapping of the IDL interfaces to the programming language. As expected, the mapping of OMG IDL to a particular programming language is the same for all ORB implementations. This includes definition of the language-specific data types and procedure interfaces to access objects through the ORB.
OMG IDL obeys the same lexical rules as C++. It has similar syntax and the grammar is actually a subset of the C++ grammar with additions necessary for distributed invocations. The C++ concept of class roughly corresponds to the concept of an IDL interface.
1) Initialize the ORB
Initialize the ORB
package weather;
import jacorb.naming.NameServer;
import org.omg.CosNaming.*;
public class SimpleWeatherClient{
  public static void main(String args[]){
    try{
      WeatherServic wServcie;
      org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.int(args, null);
      org.omg.CORBA.Ojbect wRef = (Module 5)//Lookup reference

2) Obtain an object reference to the remote object
Obtain an object reference to the remote object

Corba Programming C++
3) Narrow the generic reference to the interface-specific type reference
Narrow the generic reference to the interface-specific type reference

4) Use the interface type reference (invoke methods)
Use the interface type reference (invoke methods)