1 / 101

CORBA

CORBA. This Lecture. Common Object Request Broker Architecture (CORBA) Start with Limo example to illustrate general principles (and IDL syntax) Naming Service. Recall: Sockets. Streams-based communication between any two computers on a network

cicily
Download Presentation

CORBA

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CORBA

  2. This Lecture • Common Object Request Broker Architecture (CORBA) • Start with Limo example to illustrate general principles (and IDL syntax) • Naming Service

  3. Recall: Sockets • Streams-based communication between any two computers on a network • No requirement that the both client and server use Java (language independence) • Connection, location, and lifecycle management written by application programmers • Application programmers must convert data and method calls into and out of stream format (marshalling)

  4. Recall: RMI • Layer on top of Sockets • Has solutions for all the Socket red stuff • Connection management and marshalling is in the stubs • Location management via the registry • Lifecycle management via activation • Both client and server must be Java • Distributed garbage collection, • Can pass (serializable) objects by value

  5. What is CORBA • Specification for distributed object communications • Defined and maintained by the Object Management Group (www.omg.org) • Location transparency and object activation are fundamental to the specification • Language independent and platform neutral • Large number of extensions (Services and Facilities) designed by industry working groups

  6. Industry consortium At this point, about 800 members Various types of members; Some vote Some just serve on task forces The Object Management Group OMG Board Architecture Board Task Forces

  7. History of CORBA • 1989: OMG founded by 8 members • 1991: CORBA 1.1 • Includes IDL and basic functionality definitions • No real specifications for interoperability • 1994: CORBA 2.0 • Interoperability (GIOP) and the BOA defined • Currently: CORBA 2.4 • Minor modifications to 2.0, the definition of the POA, and objects-by-value

  8. Reference Model Application Objects Facilities Object Request Broker (ORB) Services

  9. Process-Level Schematic Interface Repository Client Object Implementation Repository Static Stubs Dynamic Invocation Orb Functionality GIOP / IIOP (Wire protocol) Orb Functionality and Object Adapters Dyunaic Skeleton Interface static Skeletons Server Object

  10. The ORB • The ORB, and the associated object adapters, define the infrastructure for client-server programming • More conceptual than architectural • There is no distinct process you can point to and say “that’s the orb” • It’s a library you link into your code • A client uses an object reference and a method call (in the client language) • ORB handles the rest of the networking details

  11. IIOP  ORB Independence • The ORB is a message bus that takes client language message calls and translates them into IIOP invocations • The ORB is a message bus that takes IIOP invocations and translates them into server language method calls • Works across vendors • Code can be ported to a different vendor • Client and server don’t need to be using same vendor’s orb

  12. CORBAServices • Idea: standardize common servers and design decisions • These are not things in the environment (like printers) so much as objects that most developers, across most domains, use • Examples: Naming, Trader, Events, Lifecycle, Transaction, Properties • You can go out and buy an event service and plug it into your orb

  13. CORBAFacilities • Oriented towards the end-user, rather than the developer • Partially abstractions of standard environmental features • Printing Facility • Systems Management Facility • Also contains things like a document model (pretty much OpenDoc) and the Mobile Agent Facility

  14. Interface Definition Language • Remember-- CORBA wants to be platform and language independent • What does this mean ? • You can write a client in one language • You can have an already existing server written in another language • CORBA will connect them • The way CORBA achieves this is through IDL

  15. Define Interfaces in IDL • Rigorously defined language for specifying an API • Method definitions, but no computational constructs • C++ like syntax (and preprocessor) • CORBA spec contains a complete definition of IDL and a set of mappings from IDL to target languages • Other groups have proposed additional mappings

  16. Language Independence ? Server Interfaces Defined in IDL Skeleton Stub IDL Compilers use mappings to generate stubs and skeletons in target languages Skeleton Skeleton Skeleton Stub Stub Stub

  17. The CORBA Development Cycle • Write IDL definitions • Compile IDL to java • Javasoft has idltojava, Visigenic has idl2java, ... • This will give you stubs and skeletons • Write the server and client code in Java • Use javac to compile the programs • Configure the deployment environment

  18. Recall our Banking Program • We had a set of bank account objects, which could be found by using the owner’s name. • Each object function as a small server • Persistence was handled by a background thread • Deactivation handled by use of Unreferenced and the activation framework

  19. BankAccount public interface BankAccount extends Remote { public String getOwner() throws RemoteException; public float getBalance() throws RemoteException; public boolean withdrawCash(float amount) throws RemoteException; public boolean depositCash(float amount) throws RemoteException; }

  20. IDL for a Similar Server module grosso { module simplebank { exception NegativeAmountException{}; exception OverdraftException { boolean succeeded; }; interface BankAccount{ attribute string owner; readonly attribute float balance; void withdrawCash(in float amount) raises (NegativeAmountException, OverdraftException); void depositCash(in float amount) raises(NegativeAmountException); }; }; };

  21. The Structure of IDL • Abstract specification language • Syntax derived from C++ • C++ style comments • All declarations end in semicolons • Standard preprocessor commands (#ifdef, #define, #include, #pragma) • Case sensitive but with an exclusionary rule • Two constructs cannot upper-case to the same string • All identifiers start with a letter

  22. Basic Types in IDL

  23. Structs • Declared using the keyword struct • Can contain any other types (including structs and objects) struct Species{ kingdom kingdom; // an enumerated type defined earlier phylum phlya; // an enumerated type defined earlier string formal_name; }; struct BugDescription { species bug_species; string first_name; string last_name; unsigned short number_of_legs; unsigned short calories_when_used_as_salad_topping; };

  24. Exceptions • Almost exactly like structs • Also define types • Can be passed as arguments or returned as values • Can also be raised by methods enum Rationale { bug_never_existed, bug_escaped, bob_ate_it}; exception BugNotFound{ bug_description the_bug; rationale why_missing; };

  25. Template Types • Sequences and arrays are the standard containers • Usually typedef’d as well (must be typedef’d to be used as argument or return types in a method call) sequence <type[, max length]> variable_name type[int][int] variable_name typedef sequence<Book, 30> BookShelf; typedef Book[30] BookShelf; typedef sequence <Book> UnboundedBookShelf; typedef LastName string<30>

  26. Typedefs • Types are frequently aliased and renamed in IDL. • This is especially true for structs and template types typedef old_type_name new_type_name; typedef template_definition new_type_name ;

  27. Attributes • An attribute is simply shorthand for declaring an accessor/mutator pair • Nice part of this: exact syntax of accessor/mutator is specified in the language mapping (according to the local idiom) • Attributes can be readonly attribute string food; attribute long height, width, depth; readonly attribute string food;

  28. Method Calls • General syntax is a little more complex than in Java delivery-style return-type method-name (comma delimited sequence of arguments) raises (comma delimited sequence of exceoptions);

  29. Delivery Style • If omitted, defaults to synchronous delivery • Has at-most-once semantics • Caller blocks until method returns or exception is thrown • Can be specified as oneway • best-effort semantics • Cannot have any return values or raise exceptions • Message is sent and client immediately continues processing

  30. Arguments • Every argument must have a directional indicator • in: this argument is sent to the server, but need not be sent back • out: this argument is, in essence, a return value • inout: this argument is sent to the server. The server will also send back a value for this argument to assume

  31. Interfaces • Interfaces define Servers. • They define “object” in CORBA • Interfaces are like objects that extend Remote in RMI • Support multiple inheritance interface BankAccount { attribute string owner; readonly attribute float balance; void withdrawCash(in float amount) raises (NegativeAmountException, OverdraftException); void depositCash(in float amount) raises(NegativeAmountException); };

  32. Modules • A module is a grouping mechanism, much like a package in Java • Modules can contain other modules • Scoping of references is done with the :: operator • containing-module::inner-module::interface

  33. Event Channel IDL // CosEventComm.idl #pragma prefix "omg.org" module CosEventComm { exception Disconnected {}; interface PushConsumer { void push(in any data) raises(Disconnected); void disconnect_push_consumer(); }; interface PushSupplier { void disconnect_push_supplier(); }; interface PullSupplier { any pull() raises(Disconnected); any try_pull(out boolean has_event) raises(Disconnected); void disconnect_pull_supplier(); }; interface PullConsumer { void disconnect_pull_consumer(); }; };

  34. Event Channel IDL II // CosEventChannelAdmin.idl #include "CosEventComm.idl" #pragma prefix "omg.org" module CosEventChannelAdmin { exception AlreadyConnected {}; exception TypeError {}; interface ProxyPushConsumer : CosEventComm::PushConsumer { void connect_push_supplier(in CosEventComm::PushSupplier push_supplier) raises(AlreadyConnected); }; interface ProxyPullSupplier : CosEventComm::PullSupplier { void connect_pull_consumer(in CosEventComm::PullConsumer pull_consumer) raises(AlreadyConnected); }; interface ProxyPullConsumer : CosEventComm::PullConsumer { void connect_pull_supplier(in CosEventComm::PullSupplier pull_supplier) raises(AlreadyConnected); }; interface ProxyPushSupplier : CosEventComm::PushSupplier { void connect_push_consumer(in CosEventComm::PushConsumer push_consumer) raises(AlreadyConnected); };

  35. Event Channel IDL III interface ConsumerAdmin { ProxyPushSupplier obtain_push_supplier(); ProxyPullSupplier obtain_pull_supplier(); }; interface SupplierAdmin { ProxyPushConsumer obtain_push_consumer(); ProxyPullConsumer obtain_pull_consumer(); }; interface EventChannel { ConsumerAdmin for_consumers(); SupplierAdmin for_suppliers(); void destroy(); }; interface EventChannelFactory { exception AlreadyExists {}; exception ChannelsExist {}; EventChannel create(); EventChannel create_by_name(in string name) raises(AlreadyExists); EventChannel lookup_by_name(in string name); void destroy() raises(ChannelsExist); }; };

  36. Limos Revisited RemoteObject Remote RemoteServer UnicastRemoteObject Dispatcher Limo Serializable DispatcherImpl LimoImpl Passenger Location Driver

  37. Limo in IDL module grosso{ module corbalimo{ struct Location { short x; short y; }; struct Passenger{ Location starting_location; Location destination; }; struct Driver{ string name; }; interface Limo; // Forward declaration to break compiler // circularity interface Dispatcher{ Limo hailLimo(in Passenger new_passenger); void limoAvailable(in Limo limo); void limoUnavailable(in Limo limo); };

  38. Limo in IDL //.... interface Limo { attribute Dispatcher current_ispatcher; readonly attribute Location current_location; readonly attribute Driver current_driver; boolean getIsCarryingPassenger(out Passenger current_passenger); /* multiple return values */ boolean wantPassenger(in Passenger possible_passenger); boolean pickupPassenger(in Passenger new_passenger); }; }; };

  39. The CORBA Development Cycle • Write IDL definitions • Compile IDL to java • Javasoft has idltojava, Visigenic has idl2java, ... • This will give you stubs and skeletons • Write the server and client code in Java • Use javac to compile the programs • Configure the deployment environment

  40. Break Time

  41. Compiling is Simple • ORB vendors are required to provide an IDL to Java compiler that implements the standard mapping • Input: IDL • Output: Java source code • Warning: vendors frequently implement other mappings as well idltojava -fno-cpp -ftie limo.idl idl2java BankAccount.idl -strict -portable -VBJvmflag ”-Xbootclasspath:%CLASSPATH_WITHOUTINTERBASE%"

  42. The Mapping is more Complicated

  43. Conceptual Mappings

  44. Mapping Basic Types

  45. Mapping Constructed Types

  46. Holders • Problem: out, and inout, arguments do not correspond to anything in the java language • Solution: Wrap the value in a holder class which can read and write the argument to a stream • Method calls which have out, or inout, arguments take a holder class instead of the original type • Additional complexity for client side developer

  47. Holders in Limo interface Limo { attribute Dispatcher current_ispatcher; readonly attribute Location current_location; readonly attribute Driver current_driver; boolean getIsCarryingPassenger(out Passenger current_passenger); /* multiple return values */ boolean wantPassenger(in Passenger possible_passenger); boolean pickupPassenger(in Passenger new_passenger); }; becomes public interface Limo extends org.omg.CORBA.Object { public void current_ispatcher(grosso.corbalimo.Dispatcher current_ispatcher); public grosso.corbalimo.Dispatcher current_ispatcher(); public grosso.corbalimo.Location current_location(); public grosso.corbalimo.Driver current_driver(); public boolean getIsCarryingPassenger(grosso.corbalimo.PassengerHolder current_passenger ); public boolean wantPassenger(grosso.corbalimo.Passenger possible_passenger); public boolean pickupPassenger(grosso.corbalimo.Passenger new_passenger ); }

  48. PassengerHolder package grosso.corbalimo; final public class PassengerHolder implements org.omg.CORBA.portable.Streamable { public grosso.corbalimo.Passenger value; public PassengerHolder() { } public PassengerHolder(grosso.corbalimo.Passenger value) { this.value = value; } public void _read(org.omg.CORBA.portable.InputStream input) { value = grosso.corbalimo.PassengerHelper.read(input); } public void _write(org.omg.CORBA.portable.OutputStream output) { grosso.corbalimo.PassengerHelper.write(output, value); } public org.omg.CORBA.TypeCode _type() { return grosso.corbalimo.PassengerHelper.type(); } }

  49. Any • Generic type, similar to void * with reflection added. Can represent any IDL type (basic or constructed, object or non-object) • Used in IDL as a type • Corresponds to org.omg.CORBA.Any

  50. Any Methods boolean equal(Any a) ; Any extract_any() ; boolean extract_boolean(); char extract_char() ; char extract_wchar(); String extract_string(); String extract_wstring(); BigDecimal extract_fixed(); double extract_double(); float extract_float() ; short extract_short() ; short extract_ushort(); int extract_long(); int extract_ulong(); long extract_longlong(); long extract_ulonglong(); Object extract_Object(); byte extract_octet(); TypeCode extract_TypeCode(); TypeCode type() ; void type(TypeCode t); insert_any(Any a); insert_boolean(boolean b); insert_char(char c) ; insert_wchar(char c); insert_string(String s); insert_wstring(String s); insert_fixed(BigDecimal bD); insert_double(double d); insert_float(float f); insert_short(short s); insert_ushort(short s); insert_long(long l) ; insert_ulong(long l); long insert_longlong(long l); insert_ulonglong(long l) ; insert_Object(Object o); insert_Object(Object o, TypeCode t); insert_octet(byte b);

More Related