Programming with CORBA Hongtao Shi 04/23/01. §CORBA Overview §Advantages of CORBA §Interface Definition Language §Application: Address Book Outline.

Slides:



Advertisements
Similar presentations
Slides for Chapter 20: CORBA Case Study From Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edition 4, © Addison-Wesley 2005.
Advertisements

Common Object Request Broker Architecture (CORBA) By: Sunil Gopinath David Watkins.
CORBA Architecture Nitin Prabhu. Outline CORBA Object Model CORBA Architecture Static Invocation Dynamic Invocation CORBA Communication Model.
1 Distributed Systems Distributed Objects & Remote Invocation CORBA Dr. Sunny Jeong. Mr. Colin Zhang With Thanks.
Seminarium on Component-based Software Engineering Jan Willem Klinkenberg CORBA.
Netprog CORBA Intro1 CORBA Common Object Request Broker Architecture Based partially on Notes by D. Hollinger and Java Network Programming and Distributed.
Advanced Java Class Network Programming. Network Protocols Overview Levels of Abstraction –HTTP protocol: spoken by Web Servers and Web Clients –TCP/IP:
A brief look at CORBA. What is CORBA Common Object Request Broker Architecture developed by OMG Combine benefits of OO and distributed computing Distributed.
OCT 1 Master of Information System Management Organizational Communications and Distributed Object Technologies Lecture 11: CORBA.
CORBA Case Study By Jeffrey Oliver March March 17, 2003CORBA Case Study by J. T. Oliver2 History The CORBA (Common Object Request Broker Architecture)
CS 501: Software Engineering Fall 2000 Lecture 16 System Architecture III Distributed Objects.
Distributed Service Architectures Yitao Duan 03/19/2002.
Copyright © George Coulouris, Jean Dollimore, Tim Kindberg This material is made available for private study and for direct.
Notes from “Distributed Systems Concepts and Design” by Coulouris
OCT 1 Master of Information System Management Organizational Communications and Distributed Object Technologies Lecture 13: CORBA.
II. Middleware for Distributed Systems
CORBA Sowmya Prabha Nagaraja CS616 Presentation. Overview Introduction The Object Management Group (OMG) Common Object Request Broker Architecture (CORBA)
Introduction to CORBA Organizational Communications and Technologies Prithvi N. Rao H. John Heinz III School of Public Policy and Management Carnegie Mellon.
CORBA & JAVA A Good Partnership For Distributed Computing.
By Dr. Jiang B. Liu 11. Java IDL and CORBA  Generic ORB Core  idltojava development tool  CORBA Object Service (COS) name service - nameserv  Java.
CORBA Chapter 17 Coulouris text. Today’s Topics CORBA History and goals CORBA RMI CORBA services The Distributed Whiteboard Revisited.
Common Object Request Broker Architecture (CORBA) CS-328.
Copyright © 2003 ProsoftTraining. All rights reserved. Distributed Object Computing Using Java and CORBA.
Understanding the CORBA Model. What is CORBA?  The Common Object Request Broker Architecture (CORBA) allows distributed applications to interoperate.
CORBA Celsina Bignoli Enterprise Computing Corporation have similar computing environments: –mixed set of HW platforms –a mixed set.
Distributed Objects and Remote Invocation: RMI and CORBA Most concepts are drawn from Chapter 17 © Pearson Education Rajkumar Buyya, Xingchen Chu, Rodrigo.
From Coulouris, Dollimore, Kindberg and Blair Distributed Systems: Concepts and Design Edition 5, © Addison-Wesley 2012 Slides for Chapter 8: Distributed.
CORBA Distributed Technology CASE STUDY Juan C. Navarro.
Cli/Serv.: rmiCORBA/131 Client/Server Distributed Systems v Objectives –introduce rmi and CORBA , Semester 1, RMI and CORBA.
Information Management NTU Interprocess Communication and Middleware.
Copyright (c) Qusay H. Mahmoud 1 The Naming Service (Client’s View) A tree-like directory for object references Much like a file system: provides directory.
1 Cisco Unified Application Environment Developers Conference 2008© 2008 Cisco Systems, Inc. All rights reserved.Cisco Public Introduction to Etch Scott.
IBM TSpaces Lab 1 Introduction. Summary TSpaces Overview Basic Definitions Basic primitive operations Reading/writing tuples in tuplespace HelloWorld.
Objekt orienteret Netværkskommunikation CORBA Introduction & CORBA Programming.
Abhishek Bachchan Vishal Patangia
Introduction to CORBA University of Mazandran Science & Tecnology By : Esmaill Khanlarpour January
CORBA/IDL Common Object Resource Broker Architecture (CORBA) Interface Definition Language (IDL) Object Management Group (OMG) ( Specification.
CORBA – Command Line CSCI 201L Jeffrey Miller, Ph.D. HTTP :// WWW - SCF. USC. EDU /~ CSCI 201 USC CSCI 201L.
RMI-IIOP.  RMI-IIOP combines RMI-style ease of use with CORBA cross-language interoperability  Java™ Remote Method Invocation (RMI) provides a simple.
Distributed Programming CSCI 201L Jeffrey Miller, Ph.D. HTTP :// WWW - SCF. USC. EDU /~ CSCI 201 USC CSCI 201L.
RMI remote method invocation. Traditional network programming The client program sends data to the server in some intermediary format and the server has.
CORBA Details Three Tier Architecture CORBA API Holders and Helpers COS Naming and Naming Contexts Transient and Persistent Objects Properties Callbacks.
Distributed Objects and Middleware. Sockets and Ports Source: G. Coulouris et al., Distributed Systems: Concepts and Design.
Vakgroep Informatietechnologie - IBCN CORBA & RMI Design of Distributed Software.
Slides for Chapter 17: CORBA Case Study From Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edition 3, © Addison-Wesley 2001.
CORBA Common Object Request Broker Architecture. Basic Architecture A distributed objects architecture. Logically, an object client makes method calls.
Slide 1 Objektorienteret Netværkskommunikation CORBA Introduction.
Java Programming: Advanced Topics 1 Networking Programming Chapter 11.
CORBA – Eclipse CSCI 201L Jeffrey Miller, Ph.D. HTTP :// WWW - SCF. USC. EDU /~ CSCI 201 USC CSCI 201L.
The World Leader in Making Software Work Together ™ Copyright IONA Technologies 1999 Building CORBA Applications (On OS/390 ?) Dusty Rivers Enterprise.
CS 501: Software Engineering Fall 1999 Lecture 12 System Architecture III Distributed Objects.
CORBA_1/001 Department of Computer Science Southern Illinois University Edwardsville Spring, 2010 Dr. Hiroshi Fujinoki CORBA:
CS551 - Lecture 11 1 CS551 Object Oriented Middleware (III) (Chap. 5 of EDO) Yugi Lee STB #555 (816)
Objektorienteret Middleware (OOMI)
 Common Object Request Broker Architecture  An industry standard developed by OMG to help in distributed programming.
Objektorienteret Netværkskommunikation (ITONK1) CORBA Introduction.
Slide 1 of 15 © Ingeniørhøjskolen i Århus CORBA Programming: Presentation of a simple “Hello World” CORBA client and server application.
Introduction to Distributed Systems and CORBA Slides for CSCI 3171 Lectures E. W. Grundke.
(C) 2003 University of ManchesterCS31010 Lecture 14: CORBA.
IDL Models The Inheritance Model: Using the Inheritance Model, you implement the IDL interface using an implementation class that also extends the compiler-generated.
Topic 5: CORBA RMI Dr. Ayman Srour
CORBA Antonio Vasquez, John Shelton, Nidia, Ruben.
CORBA Barış COŞKUN Çağatay DİKİCİ. INTRODUCTION Computer networks are heterogenous In 1989 OMG(Object Management Group) was formed to address the problems.
Common Object Request Broker Architecture (CORBA)
CORBA Alegria Baquero.
What is RMI? Remote Method Invocation
CORBA (Common Object Request Broker Architecture)
CORBA Alegria Baquero.
Building a CORBA Server
Copyright 1999 B.Ramamurthy
Presentation transcript:

Programming with CORBA Hongtao Shi 04/23/01

§CORBA Overview §Advantages of CORBA §Interface Definition Language §Application: Address Book Outline

CORBA Overview Acronym for Common Object Request Broker Architecture Not a language, definition of an application framework What is CORBA?

Platform-independent, language-independent architecture for writing distributed, object- oriented applications Object Management Group: More than 800 leading member companies Note: (1)Not a competitor of RMI (2)More powerful framework if combined with RMI

CORBA Framework (Major Parts) §Interface Definition Language (IDL): Programming language independent §Object Request Broker (ORB): Creation and transmission of message, reference to remote object §Internet Inter-ORB Protocol (IIOP): TCP/IP version of generic GIOP for ORB to send message back and forth

Why Distributed Applications? The data used by the application are distributed. The computation is distributed. The users of the application are distributed.

Fundamental Realities of Distributed Systems Co-locatedDistributed Communication FastSlow Failures Objects Objects fail fail together separately Network can partition Concurrent access Only with multiple threads Yes Security Yes No

§2-tier Applications ClientObject Most Distributed Object Framework: ClientStub SkeletonObject Request Reply N-tier Applications

N-tier Using CORBA as Framework Client IDL ORB Stub Interface ORB Object (w/in an application) ORB IDL Interface Skeleton ORB Request and Reply IIOP IIOP: Internet Inter-ORB Protocol

Location of Remote CORBA Object §Using an object location service, such as OMG Naming Service §Recreating an object reference from its ‘stringified’ form (ORB’s interface: object_to_string() and string_to_object()) §Receiving an object reference from another CORBA object, referred to as a factory object

Root Context Bill Jones Mary Smith Checking Saving Naming Service:

CORBA Products The CORBA products that support the Java programming language include: The Java 2 ORB: The Java 2 ORB comes with Sun's Java 2 SDK. VisiBroker for Java: A popular Java ORB from Inprise Corporation. VisiBroker is also embedded in other products, e.g., the Netscape Communicator browser. Netscape Communicator:Netscape browsers have a version of VisiBroker embedded in them. Applets can issue request on CORBA objects without downloading ORB classes into the browser. They are already there. OrbixWeb: A popular Java ORB from Iona Technologies. WebSphere:A popular application server with an ORB from IBM.

Advantages of CORBA §Language Independence: OMG has defined mappings for Java, C, C++, SmallTalk, Ada, Lisp, COBOL, Python and IDLscript §Location Transparency: Relocation no impact on the other §Support for Heterogeneous Network: Small, handheld devices to mainframes §Interoperability: Objects within different vendor’s ORBs can communicate.

Interoperability results from two key parts of the specification: (1)OMG Interface Definition Language (OMG IDL), ISO International Standard for several years (2)Standardized protocols GIOP and IIOP

Tools You Can Use §Java 2 SDK: CORBA/IIOP 2.0 compliant product, JavaIDL §SDK 1.3: Bundled with an IDL to Java compiler, idlj §Previous Version: Download idltojava compiler or RMI-IIOP package which includes the idlj compiler

Related Classes: (1)Test.idl //starting point (2)idlj -fall Test.idl //Two more options: //idlj -fclient Test.idl and //idlj -fserver Test.idl (3)Test.java //empty interface in java //extending TestOperations.java //and org.omg.CORBA.Object (4)TestOperations.java //This interface defines the IDL //to Java mapped operations of //the IDL interface

Related Classes (cntd’) (5)_TestStub.java //the client stub which //implements interface Test (6)_TestImplBase.java //the server skeleton which //implements interface Test (7)TestHelper.java //downcasting object references //to type Test (8)TestHolder.java //a container for streaming //objects of type Test to and //from input and output streams

Interface Definition Language (IDL) IDL Data Types Modules Interfaces Attributes Operations Exceptions Inheritance

IDL Data Types § integer(unsigned short, long, etc.) § float § char/string § boolean § struct § union § enum § array § sequence

//Example of struct interface Log {struct date {unsigned short month; unsigned short day; unsigned short year; }; struct logMessage {string msg; date msgDate; };

//Example of enum enum Color(red, yellow, green, blue, purple); //Example of array interface Log {//…interface same as before typedef logMessage logMessageArray[10]; void submitLogMsg(in logMessage msg); void submitLogMsgs(in out logMessageArray msgArray); };

Note: An array could be multi-dimensional. Index starts with zero. A typedef must be created to identify array type and size. Sequence can be bounded or unbounded, which is different from arrays.

Modules IDL interfaces may be defined within modules, providing naming space that contains and isolates any names within it. e.g. module OnlineBroker {interface Account { //... }; Note: need scope resolution operator to access the interface from outside the interface

Interfaces Define the functionality of an object in a distributed system Everything defined in an interface must be public. Attributes module OnlineBroker {interface Account { readonly attribute string accountNumber; attribute string accountHolderName; }; //get and set methods connected to the attributes };

Operations module OnlineBroker {interface Account { readonly attribute string accountNumber; attribute string accountHolderName; boolean buy(in string symbol, inout long quantity); boolean sell(in string symbol, out string cusip); }; Note: No overloading is permitted!

Exceptions module OnlineBroker {interface Account {readonly attribute string accountNumber; attribute string accountHolderName; exception InvalidSymbol() {string symbol; }; string sell(in string symbol) raises (InvalidSymbol); };

Inheritance IDL interface can inherit from other interfaces. Implicitly inherit from the Object interface Multiple inheritance possible, commas delimited module OnlineBroker {// interface Account same as before interface MarginAccount : Account {readonly attribute double margin; void RequestAdditionalMargin(in double additionalAmt); };

Application: Address Book §Define the Interface (name=> , =>name, register a new user) §Create the CORBA Object and Server §Create the CORBA Client §Run the Server and the Client name David Reilly

1. Interface Definition Language // Address book system module module address_book_system { // Specify interface to our address book interface address_book { // Unknown user exception exception unknown_user {}; // User already exists exception exception user_exists {}; // Lookup name from address string name_from_ (in string ) raises (unknown_user); // Lookup from full name string _from_name(in string name) raises (unknown_user); // Record a new name and void record_user(in string name, in string ) raises (user_exists); }; };

2. From IDL to Java: idlj -fall address_book.idl A package contains skeleton source code for your CORBA client and server. A second package covers two exceptions. \address_book_system\ _address_bookStub.java address_book.java address_bookHolder.java address_bookHelper.java address_bookPackage _address_bookImplBase.java address_bookPackage\ unknown_user.java unknown_userHelper.java unknown_userHolder.java user_exists.java user_existsHelper.java user_existsHolder.java

3. Implementing a CORBA Servant package address_book_system; import address_book_system.address_bookPackage.*; import java.util.Hashtable; import java.util.Enumeration; // // AddressBookServant // This servant class is responsible for implementing // three methods // // * String name_from_ ( String ); // * String _from_name ( String name ); // * void record_user ( String name, String );

Implementing a CORBA Servant(cntd’) class AddressBookServant extends _address_bookImplBase { private Hashtable name2 ; public AddressBookServant() // Create a new hashtable to store name & {name2 = new Hashtable(); } // Get the name of this user public String name_from_ ( String ) throws unknown_user { if (name2 .contains( )) { // Begin search for that name for (Enumeration e = name2 .keys(); e.hasMoreElements();) { String name = (String) e.nextElement(); String e_mail = (String) name2 .get(name); // Match on ? if ( .compareTo(e_mail) == 0) { return name; } } } } // User not found - throw unknown user exception throw new unknown_user(); }

Implementing a CORBA Servant(cntd’) // Get the of this person public String _from_name ( String name ) throws unknown_user { // If user exists if (name2 .containsKey(name)) { // Return address return (String) name2 .get(name); } // User doesn't exist throw new unknown_user(); } // Add a new user to the system public void record_user ( String name, String ) throws user_exists { // Is the user already listed if (name2 .containsKey( name ) || name2 .contains( ) ) { // If so, throw exception throw new user_exists(); } // Add to our hash table name2 .put (name, ); } }

4. Writing a CORBA Server package address_book_system; import org.omg.CORBA.*; import org.omg.CosNaming.*; import org.omg.CosNaming.NamingContextPackage.*; // AddressBookServer // This server is responsible for creating an object // request broker (ORB), and registering an AddressBookServant // with a naming service public class AddressBookServer { public static void main(String args[]) { try { // Create a new object request broker ORB orb = ORB.init(args, null); // Create a new address book... AddressBookServant servant = new AddressBookServant();

Writing a CORBA Server(cntd’) //... and connect it to our orb orb.connect(servant); // Object Request Broker Initialised System.out.println ("Address book ORB initialised"); // Obtain reference for our nameservice org.omg.CORBA.Object object = orb.resolve_initial_references("NameService"); // Since we have only an object reference, we must // cast it to a NamingContext. We use a helper // class for this purpose NamingContext namingContext = NamingContextHelper.narrow(object);

Writing a CORBA Server(cntd’) // Add a new naming component for our interface NameComponent list[] = { new NameComponent("address_book", "") }; // Now notify naming service of our new interface namingContext.rebind(list, servant); // Wait for clients for (;;){} } catch (Exception e) { System.err.println ("ORB Error - " + e); e.printStackTrace(System.out); System.exit(0); } } }

5. Writing a CORBA client package address_book_system; import address_book_system.address_bookPackage.*; import org.omg.CORBA.*; import org.omg.CosNaming.*; import java.io.*; // // AddressBookClient // // This client demonstrates the AddressBook server and servant. // A menu is presented to the user, allow he or she to add users, // and look up their names & addresses.

Writing a CORBA client(cntd’) public class AddressBookClient { public static void main(String args[]) throws IOException { try { // Create an object request broker ORB orb = ORB.init(args, null); // Obtain object reference for name service... org.omg.CORBA.Object object = orb.resolve_initial_references("NameService"); //... and narrow it to a NameContext NamingContext namingContext = NamingContextHelper.narrow(object); // Create a name component array NameComponent nc_array[] = { new NameComponent("address_book","") };

Writing a CORBA client(cntd’) // Get an address book object reference... org.omg.CORBA.Object objectReference = namingContext.resolve(nc_array); //... and narrow it to get an address book address_book AddressBook = address_bookHelper.narrow(objectReference); // DataInputStream for system.in DataInputStream din = new DataInputStream (System.in);

Writing a CORBA client(cntd’) for (;;) { try { // Print menu System.out.println ("1- Add user"); System.out.println ("2- Look up "); System.out.println ("3- Look up name"); System.out.println ("4- Exit"); System.out.print ("Command :"); // Read a line from user String command = din.readLine(); // Convert to number Integer num = new Integer (command); int choice = num.intValue(); // Variables we'll need for service calls String name; String ;

Writing a CORBA client(cntd’) switch (choice) {case 1: System.out.print ("Name:"); name = din.readLine(); System.out.print (" "); = din.readLine(); // Call AddressBook service AddressBook.record_user(name, ); break; case 2: System.out.println ("Name:"); name = din.readLine(); // Call AddressBook service = ddressBook. _from_name(name); System.out.println (" of " + name + " is ” + ); break;

Writing a CORBA client(cntd’) case 3: System.out.println (" "); = din.readLine(); // Call AddressBook service name = AddressBook.name_from_ ( ); System.out.println ("Name of " + + " is ” + name); break; case 4: System.exit(0); } } catch (user_exists already_there) { System.out.println ("User already exists - cannot be added to address book"); }

Writing a CORBA client(cntd’) catch (unknown_user bad_user) { System.out.println ("User doesn't exist"); } } } catch (Exception e) { System.err.println ("CORBA error - " + e); } } }

Start the server: java address_book_system.AddressBookServer -ORBInitialPort ORBInitialHost myhost Start the client: java address_book_system.AddressBookClient -ORBInitialPort ORBInitialHost myhost

Running the client: 1- Add user 2- Look up 3- Look up name 4- Exit Command :1 Name: David Reilly 1- Add user 2- Look up 3- Look up name 4- Exit Command :2 Name: David Reilly of David Reilly is

References: §Professional Java Server Programming by Wrox § § §