102.

previous chapter table of contents next chapter
  

CORBA

Like Jini, CORBA is an infrastructure for distributed systems. CORBA was designed out of a different background than Jini, and there are some minor and major differences between the two.

  • CORBA allows for specification of objects that can be distributed. The concentration is on distributed objects rather than on distributed services.
  • CORBA is language-independent, using an Interface Definition Language (IDL) for specifying interfaces.
  • CORBA objects can be implemented in a number of languages, including C C++, SmallTalk, and Java
  • Current versions of CORBA pass remote object references, rather than complete object instances. Each CORBA object lives within a server, and the object can only act within this server. This is more restricted than Jini, where an object can have instance data and class files sent to a remote location to execute there. This limitation in CORBA may change in future with pass- by-value parameters to methods .

IDL is a language that allows the programmer to specify the interfaces of a distributed object system. The syntax is similar to C++ but does not include any implementation-level constructs, so it allows definitions of data types (such as structures and unions), constants, enumerated types, exceptions, and interfaces. Within interfaces, it allows the declaration of attributes and operations (methods). The complete IDL specification can be found on the Object Management Group (OMG) Web site ( http://www.omg.org/ ).

The book Java Programming with CORBA by Andreas Vogel and Keith Duddy ( http://www. wiley .com/compbooks/vogel ) contains an example of a room-booking service specified in CORBA IDL and implemented in Java. This defines interfaces for Meeting , a MeetingFactory factory to produce them, and a Room . A room may have a number of meetings in slots (hourly throughout the day), and there are support constants, enumerations, and typedefs to support this. In addition, exceptions may be thrown under various error conditions. The IDL that follows differs slightly from that given in the book, in that definitions of some data types that occur within interfaces have been "lifted" to a more global level, because the mapping from IDL to Java has changed slightly for elements nested within interfaces since that book was written.

The following is the modified IDL for the room-booking service:

 module corba { module RoomBooking {     interface Meeting {         // A meeting has two read-only attributes that describe         // the purpose and the participants of that meeting.         readonly attribute string purpose;         readonly attribute string participants;         oneway void destroy();     };     interface MeetingFactory {         // A meeting factory creates meeting objects.         Meeting CreateMeeting( in string purpose, in string participants);     };     // Meetings can be held between the usual business hours.     // For the sake of simplicity there are 8 slots at which meetings     // can take place.     enum Slot { am9, am10, am11, pm12, pm1, pm2, pm3, pm4 };     // since IDL does not provide means to determine the cardinality     // of an enum, a corresponding MaxSlots constant is defined.     const short MaxSlots = 8;     exception NoMeetingInThisSlot {};     exception SlotAlreadyTaken {};     interface Room {         // A Room provides operations to view, make, and cancel bookings.         // Making a booking means associating a meeting with a time slot         // (for this particular room).         // Meetings associates all meetings (of a day) with time slots         // for a room.         typedef Meeting Meetings[ MaxSlots ];         // The attribute name names a room.         readonly attribute string name;         // View returns the bookings of a room.         // For simplicity, the implementation handles only bookings         // for one day.         Meetings View();         void Book( in Slot a_slot, in Meeting a_meeting )             raises(SlotAlreadyTaken);         void Cancel( in Slot  a_slot )             raises(NoMeetingInThisSlot);     }; }; }; 
  


A Programmer[ap]s Guide to Jini Technology
A Programmer[ap]s Guide to Jini Technology
ISBN: 1893115801
EAN: N/A
Year: 2000
Pages: 189

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net