Sie sind auf Seite 1von 26

CORBA Common Object Request Broker Architecture

by Paul I. Muntean

Paul I. Muntean

CORBA

CORBA Overview
What is CORBA?
Common Object Request Broker Architecture Communication infrastructure for distributed objects Allows a heterogeneous, distributed collection of objects to collaborate transparently

What is CORBA good for?


Developing distributed applications Locating remote objects on a network Sending messages to those objects Common interface for transactions, security, etc.

Paul I. Muntean

CORBA

CORBA Overview
Motivation for CORBA
Computation is distributed Scalability: multiprocessing Take computation to data Heterogeneous architectures Users are distributed Multiple users interacting and communicating via distributed applications Data are distributed Administrative and ownership reasons Heterogeneous systems Shared by multiple applications Scalability

Paul I. Muntean

CORBA

Outline

Main Components of CORBA architecture Broker Pattern short review Get started with a basic CORBA application Exercises Conclusion

Paul I. Muntean

CORBA

Main Components of CORBA


ORB Core CORBA Objects OMG Interface Definition Language (OMG IDL) Stubs and Skeletons Dynamic Invocation Interface, Dynamic Skeleton Int. Object Adapter (Portable Object Adapter) Interface Repository ORB Interoperability Servant

Paul I. Muntean

CORBA

Servants are programming CORBA Objects language entity avirtual entity that exists in the capable server Provides a dynamic mechanism context of aof being for CORBA-based applications andlocated by containing The ORB allows client to access OMD anthat and having code ORB system IDL type applications to find objects client when it is executing. requests implements a The client application and invoke methods on them delivered to it. CORBA object. is starting the request Can be instantiated locally or across a network. It to the server handles passing requests, by between CORBA Serves as the glueone or more Generated by theThe DII defines a request IDL responses and exceptions Servants. ObjectThe DSI deals with requests sent implementation and the ORB Compiler. so that clients who know between takes care of itself. Request Demultiplexing protocol that a client object and a IIOP in a generic byobject reference andmanner. clients is a high-level Stub handles the the ,Operation Dispatching , services associated with theSkeleton code and many of the Activationserver levels Looks at thecan build operation object. marshalling of a request, type requested interface deactivationabove the transport and , Generating Object that is convertingrequests without having to layer, including data translates wire data its arguments and interpreting References translation, memory Common ProtocolsIDL dynamically. Architecture format structure into wire the semantics generated buffer management, dead-data rely on the to facilitate Common Object Request Broker CORBA into format. transmissioncode. and communication management. It is memory stub oflocks also between the requests and replies responsible for directing requests todata format correct object Paul I. Muntean CORBA 6 ORBs. GIOP, IIOP, ESIOP , instance within an ORB. (unmarshaling) IOR.

The compiler used to obtain the IDL stubs from the IDL file

Outline

Main Components of CORBA architecture Broker Pattern short review Get started with a basic CORBA application Exercises Conclusion

Paul I. Muntean

CORBA

Broker Pattern

Example taken from : Slide no. 48 of the lecture Architectural patterns 2 of prof. B Bruegge

Paul I. Muntean

CORBA

The Stub receives calls CORBAclient. It has Architecture from the the role of marshaling parameters.

POA or Portable Object Adapter. based on Broker Pattern Passes calls to requested object and method. It contains persistent or transient Skeletons .

ORB or Object Request Diagram adapted from the lecture ArchitecturalBroker. Used forB. Bruegge. patterns 2 of prof The skeleton is responsible ORB Core it is like the bridge in communication between for calling methods on the The Naming Service provides the principal mechanism through which most the Broker Pattern .It has the role client and server. clients of an ORB-based system locate objects that they intend to use (make Servant and Unmarshals of communicationIt is located in the ORB box as one of the services of it. with ORB s requests of). parameters for the Servant. located on other machines.
Paul I. Muntean CORBA 9

Outline

Main Components of CORBA architecture Broker Pattern Short review Get started with a basic CORBA application Exercises Conclusion

Paul I. Muntean

CORBA

10

Communication between the Client and Server

Communication between the Client and Server


1. 2. 3. 4. 5. The client calls the service say hello of the server. The ORB transmits the call to the servant-object, he must be activated. The service say hello of the server will be started and delivers an string as a parameter. The ORB transmits this string back to the client. The clients prints this string on his console.
CORBA 11

Paul I. Muntean

Steps needed for creating and running a CORBA application

1. 2. 3. 4. 5.

Writing of the IDL file. Write the client application. Write the server application. Compile the two applications and start the server. Run the client.

Example taken from :http://www.nt.fh-koeln.de/fachgebiete/inf/diplom/corba/html/kompilieren.html

Paul I. Muntean

CORBA

12

Writing the IDL file


Step 1: name Hello.idl. Descriptio Write in the file :module HelloApp { n of the //code }; CORBA Save the file. IDLModule

Start a text editor and save afterwards the file with the following

Here we write our own interface. Replace the text //code from the previous example with the following. interface Hello {//code 2 Step 2: }; Interface declaratio Save again the file n After using the IDLJ compiler the result will be a bunch of java files which will be implemented by the client and server.
Step 3: Method declaratio n

The methods describe the behavior of the services which the server is offering. We have in our example the service sayHello(). Insert in your code: string sayHello(); instead of //code2 Hello.idl file is now complete.

Paul I. Muntean

CORBA

13

Running the IDLJ compiler


1.1 Be sure that the path where you have the IDLJ compiler is in the CLASSPATH else add it. 1.1.1 Edit the IDL file in order to fit the requirements. 1.2 Open a console/shell, navigate to the folder where you have the idl file. 1.3 Write to the Console the command: IDLJ -fall Hello.idl 1.4 The result will be a bunch of java files which will be automatically generated. 1.5 The java files will be needed afterwards.

Paul I. Muntean

CORBA

14

Steps needed for creating and running a CORBA application

1. 2. 3. 4. 5.

Writing of the IDL file. Write the client application. Write the server application. Compile the two applications and start the server. Run the client.

Paul I. Muntean

CORBA

15

Write the client application


public class Client_hello { public static void main(String args[]) { String name_service = "Hello_server"; Properties properties = new Properties(); properties.put("org.omg.CORBA.ORBInitialHost",localhost"); properties.put( "org.omg.CORBA.ORBInitialPort",+ 900); try { System.out.println("Client>Creating and initializing the ORB"); ORB orb = ORB.init(args, null); System.out.println("Client>getting the root naming context"); org.omg.CORBA.Object objRef=orb.resolve_initial_references("NameService"); // it uses NamingConetExt Interoperable Naming Service NamingContextExt ncRef =NamingContextExtHelper.narrow(objRef); Resolving the object reference in NameComponent nc = new NameComponent(name_service,""); NameComponent path[] = { nc }; Interface_Hello hello =Interface_HelloHelper.narrow(ncRef.resolve(path)); calling the Hello service..."); String msg_received = hello.get_msg(); server returned the following message: "+ msg_received } catch (Exception e) {System.out.println("Exception:\n" + e); Notice: For running from Eclipse first the command tnameserv ~/NS_Ref must be given in the console window , before starting the server. In Unix machines you have to be administrator and use the command sudo tnameserv ORBInitialPort value to set the initial port. javac Client_hello.java written in the console window will compile the java file. java Client_hello -ORBInitialHost nameserverhost -ORBInitialPort nameserverport to start the application The fourth command can be used when we want to set the port and host which we want to use. Default port for Unix and Windows is 900.
16

Paul I. Muntean

CORBA

Steps needed for creating and running a CORBA application

1. 2. 3. 4. 5.

Writing of the IDL file. Write the Client application. Write the Server application. Compile the two applications and start the Server. Run the Client.

Paul I. Muntean

CORBA

17

Write the server application


public class Server_hello { public static void main(String args[]) { String name_service = "Hello_server"; Properties properties = System.getProperties(); try { System.out.println("Server>starting server..."); System.out.println("Server>creating and initializing the ORB"); ORB orb = ORB.init(args, properties); System.out.println("Server>getting reference to rootpoa");...... System.out.println("Server>activating the POA Manager");....... System.out.println("Server>Creating the servant");....... Hello_service hello_service = new Hello_service(); System.out.println("Server>obtain the reference from the servant");...... System.out.println("Server>getting the root naming context"); org.omg.CORBA.Object objRef = orb.resolve_initial_references("NameService"); NameComponent nc = new NameComponent(name_service, ""); NameComponent path[] = { nc }; ncRef.rebind(path, service_href); while (!msg_kbd.equals("quit") && !msg_kbd.equals("QUIT")) { msg_kbd = data_reader.readLine(); if (msg_kbd.equals("quit") || msg_kbd.equals("QUIT")) { } } } catch (Exception e) { System.out.println("Exception in server...\nException:\n" + e);

Notice: For running from Eclipse first the command tnameserv ~/NS_Ref must be given in the console window , before starting the server. In Unix machines you have to be administrator and use the command sudo tnameserv ORBInitialPort value to set the initial port. javac Client_hello.java written in the console window will compile the java file. java Client_hello -ORBInitialHost nameserverhost -ORBInitialPort nameserverport to start the application The fourth command can be used when we want to set the port and host which we want to use. Default port for Unix and Windows is 900.
18

Paul I. Muntean

CORBA

Steps needed for Creating and running a application which uses CORBA
1. 2. 3. 4. 5. Writing of the IDL file. Write the client application. Write the server application. Compile the two applications and start the server. Run the client.

Paul I. Muntean

CORBA

19

Get started with a basic CORBA application


4.Compile the two applications and start the Server 4.1 Start the Naming Server

4.2 Run the hello server. 5. Run the hello client and observe the outputted message. The application can run as a distributed application but also as stand alone.
Paul I. Muntean CORBA 20

Outline

Main Components of CORBA architecture Broker pattern short review Get started with a basic CORBA application Exercises Conclusion

Paul I. Muntean

CORBA

21

Exercises
Task 1: Learn how to use the IDLJ compiler. Download the Eclipse Application 1 from the web site (5 minutes)
Easy. Generate Java Code from a IDL file supplied together with the project observe if the files match with the ones given. (15 minutes) Medium. Implement your own hello service.

Homework
Task 2: Writing the required services for the server. Download the Idl file Math.IDL and the two java files for the Client and Server .
Easy. Generate the java files from the idl files. Hard. Write a Service class used by the server where services like: addition, subtraction, multiplication, transpose and quit(will stop the server) operations are implemented for basic matrix operations

Paul I. Muntean

CORBA

22

Outline

Main Components of CORBA Architecture Broker pattern short review Get started with a basic CORBA application Exercises Conclusion

Paul I. Muntean

CORBA

23

Conclusions

Wide language support Open Standard Wide Platform Support Usage of the Broker Pattern Advantages of using the Broker Pattern Others in File

Paul I. Muntean

CORBA

24

Questions

Paul I. Muntean

CORBA

25

References:
Books:

CORBA Networking with Java, George M. Doss,Wordware Publishing INC CORBA 3 Fundamentals and Programming Sec Ed. John Siegel ,John Wilesy & Sons, INC. CORBA A Guide to Common Object Request Broker Architecture, Ron Ben-Natan, McGraw-Hill
CORBA EXPLAINED SIMPLY, Ciaran McHale http://www.ciaranmchale.com/corba-explained-simply/development-ofcorba-applications.html CORBA Programming with J2SE 1.4 ,http://java.sun.com/developer/technicalArticles/releases/corba/ JavaTM IDL FAQ http://download.oracle.com/javase/1.3/docs/guide/idl/jidlFAQ.html#where%20can%20I%20download A Short Guide To Learning CORBA,Michael Le and Jun Suzuki http://netresearch.ics.uci.edu/bionet/resources/platform/corba/ What is CORBA? Tutorial ,http://www-cdfonline.fnal.gov/daq/CORBAXXX/tutorial.html Introduction to CORBA ,By jGuru.com http://java.sun.com/developer/onlineTraining/corba/corba.html#co5 Catalog of OMG IDL / Language Mappings Specifications http://www.omg.org/technology/documents/idl2x_spec_catalog.htm#Java2IDL Indroducing to IDL , by Jim Inscore,http://www.csse.uwa.edu.au/programming/javatut/idl/index.html Java and CORBA - a smooth blend,by David Reilly http://www.javacoffeebreak.com/articles/javaidl/javaidl.html#code Einfhrung und Beschreibung der unterschiedlichen Client-Server Anwendungen mittels CORBA, basierend auf der Programmiersprache Java, Cihan zkalfa,http://www.nt.fh-koeln.de/fachgebiete/inf/diplom/corba/html/kompilieren.html IIOP: Internet Inter-ORB Protocol,http://panuganty.tripod.com/articles/iiop.htm

Links:

Paul I. Muntean

CORBA

26

Das könnte Ihnen auch gefallen