First experiences with CORBA Niko Neufeld The task
First experiences with CORBA Niko Neufeld
The task u Prepare a ring display for the RICH reconstruction/simulation u Want to use JAVA 2 D toolkit
Possible strategies u Dump data to file (from C++, read with Java) n u Link together Java and C++ n u difficult, huge executable, always same client Use a TCP socket n n u clumsy(!), ugly(!!), synchronization(!!!) elegant, client - server, standard (C) only primitive data types (basically bytes), must provide your own protocol CORBA n n standardized, Java and C++ fully supported free implementations available Niko Neufeld
CORBA / OMG u OMG (Object Management Group) n n u u comprises all major vendors except Microsoft defines and develops the standard and most OMG document are available for public download http: //www. omg. org Microsoft has a similar approach COM/OLE Interoperability is under way Niko Neufeld
CORBA intro u u u CORBA stands for Common Object Request Broker Architecture It is a standard for object/component cooperation A component is usually a (collection of) object(s) which performs a well defined task e. g. display a histogram. It is (ideally): n u It defines “services” for objects: n u standalone, “plug and play”able across networks and platforms naming, persistency, transactions etc. It is language/platform independent Niko Neufeld
CORBA - ORB u All requests from objects to objects are handled by the Object Request Broker (ORB) Niko Neufeld
Interface Definition Language (IDL) u u IDL describes the interfaces which objects show to the ORB It contains: n n modules = namespaces in C++ interfaces = abstract base classes in C++ operations = methods data types = standardized types basic: compatible to double, int, long, etc. l constructed: struct, sequence, string, any, union, enum l u These are mapped to the respective language types by the precompilers (idl, jidl) Niko Neufeld
IDL (trivial example) interface Y 2 K { const short y 2 k=2000 ; attribute short currentyear ; exception Y 2 Kbug {string yeah; }; void print(in short year) raises (Y 2 Kbug); }; idl y 2 k. idl produces y 2 k_skel. cpp and y 2 k. cpp and the header files Not shown here (lengthy - but no need to look into them) y 2 k_skel is used for the implementation of the server part and y 2 k. h for a possible client. Niko Neufeld
Generated IDL file //## Module: Photon //## Subsystem: Rich: : Detector //## Source file: C: Program FilesRational Rose 98 Evaluation EditionRichDetectorPhoton. idl #ifndef Photon_idl #define Photon_idl #include "RichDetectorPixel. idl" interface Photon : Trajectory { //##begin Photon. initial. Declarations preserve=yes //##end Photon. initial. Declarations // Attributes attribute double energy; attribute double theta. Cherenkov; // Operations void absorbed(); void scattered(in const Hep. Point 3 D &position, in const Hep. Point 3 D &direction); }; #endif Niko Neufeld
Working with CORBA Niko Neufeld
How to use it u u u Server must be running somewhere It produces a unique(!) Object reference for the object whose service it offers This reference can e. g. be stored as a string and passed to a possible client The client initializes the ORB, obtains the object reference and gets a reference to the object and can then call its methods And it really works! Niko Neufeld
What did I use? u JAVA 1. 2 on Linux n n u ORBacus 3. 1. 2 for C++ and Java n n n u www. blackdown. org/java-linux fully compliant SUN certified port of 1. 2 www. ooc. com/ob/ commercial software free for non-commercial use full CORBA IDL support, IDL to C++/Java mapping Linux 2. 0. 35 (dual P 2) n gcc/egcs, java Niko Neufeld
Some final remarks u u u I started out looking for a simple solution for C++ and Java interoperability CORBA works very nicely, it is a very high level way of communication I did not check performance issues One gets distribution, client-server, multi language (almost) for free There seem to be a lot more interesting possibilities Niko Neufeld
- Slides: 13