distributed programming corba l.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Distributed Programming - CORBA PowerPoint Presentation
Download Presentation
Distributed Programming - CORBA

Loading in 2 Seconds...

play fullscreen
1 / 65

Distributed Programming - CORBA - PowerPoint PPT Presentation


  • 347 Views
  • Uploaded on

Distributed Programming - CORBA Marc Conrad D104 (Park Square Building) Marc.Conrad@beds.ac.uk These slides: CORBA and the OMG An example CORBA implementation Client ORB Server The Common Object Request Broker Architecture CORBA The Common Object Request Broker Architecture

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Distributed Programming - CORBA' - sandra_john


Download Now 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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
distributed programming corba
Distributed Programming - CORBA
  • Marc Conrad
    • D104 (Park Square Building)
    • Marc.Conrad@beds.ac.uk
    • These slides:
      • CORBA and the OMG
      • An example CORBA implementation

Marc Conrad University of Bedfordshire

the common object request broker architecture

Client

ORB

Server

The Common Object Request Broker Architecture

CORBA

Marc Conrad University of Bedfordshire

the common object request broker architecture3
The Common Object Request Broker Architecture
  • CORBA is not a programming language but an architecture.
  • CORBA is an (elegant and sophisticated) way to describe and link the use of objects in a distributed environment.
  • The "dirty work", the implementation of the behaviour of the objects is out of the scope of CORBA.

Marc Conrad University of Bedfordshire

the common object request broker architecture4
The Common Object Request BrokerArchitecture
  • CORBA is in the context of Object Oriented Design, Analysis, Programming.

BUT: The objects can be located on different machines all over the world and implemented in a variety of languages!

Marc Conrad University of Bedfordshire

the common object request broker architecture5
The Common Object Request Broker Architecture
  • The Object Request Broker (ORB) is itself an object which provides the services for accessing remote objects and transmitting data.
  • Note that the implementation of the ORB depends on the specific vendor. The CORBA standard only defines the interface.

Marc Conrad University of Bedfordshire

the common object request broker architecture6
The Common Object Request Broker Architecture
  • Task: Compare with XML-RPC and RMI!

Marc Conrad University of Bedfordshire

the common object request broker architecture7
The Common Object Request BrokerArchitecture
  • CORBA is a standard which has been developed by the OMG, the Object Management Group.
  • The OMG is the world's largest computer industry consortium with over 800 members.
    • See http://www.omg.org/cgi-bin/apps/membersearch.pl

Marc Conrad University of Bedfordshire

the history of the omg
The History of the OMG
  • Founded 1989 by eleven companies as non profit organisation.
  • Aims on standards for object oriented software production.
  • Other projects:
    • MDA: http://www.omg.org/mda/
      • (Model Driven Architecture)
    • UML: http://www.omg.org/uml/
      • (Unified Modeling Language)
    • MOF: http://www.omg.org/mof/
      • (MetaObject Facility)

Marc Conrad University of Bedfordshire

omg technology
OMG technology
  • The framework within which all OMG adopted technology fits is the OMA – the Object Management Architecture:
    • http://www.omg.org/oma/
  • So, learning CORBA is also on learning about Object Oriented technologies from a language independent view.

Marc Conrad University of Bedfordshire

omg goals
OMG goals
  • The goals of the OMG are promotion of the object-oriented approach to software engineering and development of a common architectural framework for writing distributed object-oriented applications based on interface specifications for the object in the application.

Marc Conrad University of Bedfordshire

the common object request broker architecture11
The Common Object Request BrokerArchitecture
  • Common also means something else:
    • CORBA is an architecture which integrates code written in languages as Java, C++, C, Smalltalk, COBOL, Lisp, Python.

We focus here mainly on Java

Marc Conrad University of Bedfordshire

corba some tlas t hree l etter a cronyms
CORBA – Some TLAs (Three Letter Acronyms)
  • OMG - Object Management Group
  • ORB - Object Request Broker
  • IDL - Interface Definition Language
  • IOR - Interoperable Object Reference
  • POA - Portable Object Adapter
  • IIOP - Internet Inter-ORB Protocol

Marc Conrad University of Bedfordshire

corba development process

2. Identify

1. Write Code

3. Communicate

Client

Clientkdfjshkdsahfkdashfkajshfkdsjhkjsahfkdshfkhasdfkashfkdjsahfkshdfkhsafkjshfkdsfhakjdhfksjdhfakhsfkjsdfkdasjfkdasjksdajfkdsafhksajhkdjfhkasjkdsahksdjfksakdjsfksakshfdkjfdkdsfh

Client

Serverkdfjshkdsahfkdashfkajshfkdsjhkjsahfkdshfkhasdfkashfkdjsahfkshdfkhsafkjshfkdsfhakjdhfksjdhfakhsfkjsdfkdasjfkdasjksdajfkdsafhksajhk assfksakshfdkjf

10010101101110101

Server

CORBA Development Process

0. Specify Service

IDLkdfjshkdsahfkdashfkajshfkdsjhkjsahfkdshfkhasdfkashfkdjsahfkshdfkhsafkjshfkdsfhakjdhfksjdhfakhsfkjsdfkdasjfkdasjksdajfkdsafhksajhk assfksakshfdkjf

Server

Marc Conrad University of Bedfordshire

the interface definition language idl
The Interface Definition Language (IDL)
  • The IDL provides a class definition.
  • It defines the behaviour but not the implementation!
  • The IDL is then translated (mapped) to a specific programming language.

Marc Conrad University of Bedfordshire

or to rephrase the previous slide more professionally
Or, to rephrase the previous slide more professionally:
  • OMG IDL is a purely declarative language designed for specifying programming-language-independent operational interfaces for distributed applications. OMG specifies a mapping from IDL to several different programming languages, including C, C++, Smalltalk, COBOL, Ada, and Java. When mapped, each statement in OMG IDL is translated to a corresponding statement in the programming language of choice.

from: http://java.sun.com/j2se/1.3/docs/guide/idl/tutorial/GSIDL.html

?

Marc Conrad University of Bedfordshire

the corba development process
The CORBA Development Process
  • Write some IDL that describes the interfaces to the object or objects that will be used or implemented.
  • Compile the IDL file.
  • Identify the IDL compiler generated classes and interfaces.
  • Write additional code.
  • Run the application.

Marc Conrad University of Bedfordshire

idl and java
IDL and Java
  • We discuss in this lecture the IDL to Java mapping, that means using an IDL for producing Java classes which are used in a Java environment.
  • The idlj from the jdk maps the IDL to Java.
  • Other languages which are similarly supported are C++, Lisp, Smalltalk, ...

Marc Conrad University of Bedfordshire

idl overview
IDL Overview.

(diagram: Java Programming with CORBA, OMG press, page 143)

Marc Conrad University of Bedfordshire

idl example
IDL Example

A module is a namespace similar to a Java packages:

module Example {

interface Hello {

string sayHello();

};

};

Declares the application interface. The idlj maps interfaces to Java classes.

Operations are mapped to (Java, C++, ...) methods.

This is an example of an IDL which provides one method, namely sayHello(). This code is saved in a file Hello.idl

Marc Conrad University of Bedfordshire

corba development process20

2. Identify

1. Write Code

3. Communicate

Client

Clientkdfjshkdsahfkdashfkajshfkdsjhkjsahfkdshfkhasdfkashfkdjsahfkshdfkhsafkjshfkdsfhakjdhfksjdhfakhsfkjsdfkdasjfkdasjksdajfkdsafhksajhkdjfhkasjkdsahksdjfksakdjsfksakshfdkjfdkdsfh

Client

Serverkdfjshkdsahfkdashfkajshfkdsjhkjsahfkdshfkhasdfkashfkdjsahfkshdfkhsafkjshfkdsfhakjdhfksjdhfakhsfkjsdfkdasjfkdasjksdajfkdsafhksajhk assfksakshfdkjf

10010101101110101

Server

CORBA Development Process

0. Specify Service

IDLkdfjshkdsahfkdashfkajshfkdsjhkjsahfkdshfkhasdfkashfkdjsahfkshdfkhsafkjshfkdsfhakjdhfksjdhfakhsfkjsdfkdasjfkdasjksdajfkdsafhksajhk assfksakshfdkjf

Server

Marc Conrad University of Bedfordshire

mapping hello idl to java here with idlj
Mapping Hello.idl to Java(Here: with idlj)
  • Go to a command line prompt and type in the following command:idlj –fall –oldImplBase Hello.idl

Name of Compiler

Name of the idl file

Option to generate also files only relevant for Server

Means: Do not use POA (we’ll discuss this later)

Marc Conrad University of Bedfordshire

mapping hello idl to java here with idlj22
Mapping Hello.idl to Java(Here: with idlj)
  • These Files are generated in the folder Example:

Marc Conrad University of Bedfordshire

mapping hello idl to java here with idlj23
_HelloImplBase.java

_HelloStub.java

Hello.java

HelloHelper.java

HelloHolder.java

HelloOperations.java

This abstract class is the server skeleton, providing basic CORBA functionality for the server. It implements the Hello.java interface. The server class HelloServant extends _HelloImplBase.

Mapping Hello.idl to Java(Here: with idlj)

Marc Conrad University of Bedfordshire

mapping hello idl to java here with idlj24
_HelloImplBase.java

_HelloStub.java

Hello.java

HelloHelper.java

HelloHolder.java

HelloOperations.java

This class is the client stub, providing CORBA functionality for the client. It implements the Hello.java interface

Mapping Hello.idl to Java(Here: with idlj)

Marc Conrad University of Bedfordshire

mapping hello idl to java here with idlj25
_HelloImplBase.java

_HelloStub.java

Hello.java

HelloHelper.java

HelloHolder.java

HelloOperations.java

This signature interface contains the Java version of our IDL interface. The Hello.java interface extends org.omg.CORBA.Object, providing standard CORBA object functionality. This class “is” the distributed CORBA object.

Mapping Hello.idl to Java(Here: with idlj)

Marc Conrad University of Bedfordshire

mapping hello idl to java here with idlj26
_HelloImplBase.java

_HelloStub.java

Hello.java

HelloHelper.java

HelloHolder.java

HelloOperations.java

This operations interface contains the single method sayHello(). The IDL-to-Java mapping puts all of the operations defined on the IDL interface into this file.

Mapping Hello.idl to Java(Here: with idlj)

Marc Conrad University of Bedfordshire

mapping hello idl to java here with idlj27
_HelloImplBase.java

_HelloStub.java

Hello.java

HelloHelper.java

HelloHolder.java

HelloOperations.java

This final class provides auxiliary functionality, notably the narrow() method required to cast CORBA object references to their proper types.

Mapping Hello.idl to Java(Here: with idlj)

Marc Conrad University of Bedfordshire

mapping hello idl to java here with idlj28
_HelloImplBase.java

_HelloStub.java

Hello.java

HelloHelper.java

HelloHolder.java

HelloOperations.java

This final class holds a public instance member of type Hello. It provides operations for out and inout arguments, which CORBA allows, but which do not map easily to Java's semantics.

Note that CORBA allows call-by-value method parameters which are not directly available in Java.

Mapping Hello.idl to Java(Here: with idlj)

Marc Conrad University of Bedfordshire

writing the server
Writing the Server.

Server

Servant

  • For the implementation of the Server we have to implement two classes:
    • The Servant, i.e. the object which has been specified by the Hello.idl
    • The Server itself, i.e. the program running in the background which reacts on client requests.

Marc Conrad University of Bedfordshire

writing the servant
import Example.*;

public class HelloServant extends _HelloImplBase {

public String sayHello()

{

return "\nHello world !!\n";

}

}

Writing the Servant

Marc Conrad University of Bedfordshire

writing the servant31
import Example.*;

public class HelloServant extends _HelloImplBase {

public String sayHello()

{

return "\nHello world !!\n";

}

}

Makes the classes accessible which have been generated by the idlj compiler.

Writing the Servant

Marc Conrad University of Bedfordshire

writing the servant32
import Example.*;

public class HelloServant extends _HelloImplBase {

public String sayHello()

{

return "\nHello world !!\n";

}

}

Note that _HelloImplBase is one of the classes which has been generated by idlj -fall.

Writing the Servant

Marc Conrad University of Bedfordshire

writing the servant33
import Example.*;

public class HelloServant extends _HelloImplBase {

public String sayHello()

{

return "\nHello world !!\n";

}

}

This class extends _HelloImplBase, that means it has to implement the interface provided by _HelloImplBase, which has been produced by Hello.idl via idlj.

Writing the Servant

Marc Conrad University of Bedfordshire

writing the servant34
import Example.*;

public class HelloServant extends _HelloImplBase {

public String sayHello()

{

return "\nHello world !!\n";

}

}

This was the file Hello.idl:

module Example {

interface Hello {

string sayHello();

};

};

Writing the Servant

Marc Conrad University of Bedfordshire

writing the servant35
import Example.*;

public class HelloServantextends _HelloImplBase {

public String sayHello()

{

return "\nHello world !!\n";

}

}

This was the file Hello.idl:

Example {

interface Hello {

string sayHello();

};

};

Writing the Servant

Marc Conrad University of Bedfordshire

writing the servant36
import Example.*;

public class HelloServant extends _HelloImplBase {

public String sayHello()

{

return "\nHello world !!\n";

}

}

This was the file Hello.idl:

Example {

interface Hello {

string sayHello();

};

};

Writing the Servant

Marc Conrad University of Bedfordshire

writing the servant37
import Example.*;

public class HelloServant extends _HelloImplBase {

public String sayHello()

{

return "\nHello world !!\n";

}

}

This was the file Hello.idl:

Example {

interface Hello {

string sayHello();

};

};

Writing the Servant

Marc Conrad University of Bedfordshire

writing the servant38
import Example.*;

public class HelloServant extends _HelloImplBase {

public String sayHello()

{

return "\nHello world !!\n";

}

}

This is the Implementation of the Hello.idl object.

Writing the Servant

Marc Conrad University of Bedfordshire

implementing the server
Implementing the Server
  • The Server has to perform the following tasks:
    • Initialise the ORB
    • Instantiate a HelloServant object.
    • Register this object in the ORB.
    • Publish the object to the rest of the world.
    • Wait for client requests.

Marc Conrad University of Bedfordshire

implementing the server40
import java.io.*; import org.omg.CORBA.*; import Example.*;

public class HelloServer {

public static void main(String args[])

{

try{

ORB orb = ORB.init(args, null);

HelloServant helloRef = new HelloServant();

orb.connect(helloRef);

String str = orb.object_to_string(helloRef);

String filename = "A://HelloIOR";

FileOutputStream fos = new FileOutputStream(filename);

PrintStream ps = new PrintStream(fos);

ps.print(str); ps.close();

java.lang.Object sync = new java.lang.Object();

synchronized (sync) {

sync.wait();

}

} catch (Exception e) {

System.err.println("ERROR: " + e);

e.printStackTrace(System.out);

}

}

}

The file HelloServer.java

Implementing the Server

Marc Conrad University of Bedfordshire

implementing the server41
import java.io.*; import org.omg.CORBA.*; import Example.*;

public class HelloServer {

public static void main(String args[])

{

try{

ORB orb = ORB.init(args, null);

HelloServant helloRef = new HelloServant();

orb.connect(helloRef);

String str = orb.object_to_string(helloRef);

String filename = "A://HelloIOR";

FileOutputStream fos = new FileOutputStream(filename);

PrintStream ps = new PrintStream(fos);

ps.print(str); ps.close();

java.lang.Object sync = new java.lang.Object();

synchronized (sync) {

sync.wait();

}

} catch (Exception e) {

System.err.println("ERROR: " + e);

e.printStackTrace(System.out);

}

}

}

We import:

the java.io for file input/output

CORBA for the ORB stuff

the files generated by the idlj.

Implementing the Server

Marc Conrad University of Bedfordshire

implementing the server42
import java.io.*; import org.omg.CORBA.*; import Example.*;

public class HelloServer {

public static void main(String args[])

{

try{

ORB orb = ORB.init(args, null);

HelloServant helloRef = new HelloServant();

orb.connect(helloRef);

String str = orb.object_to_string(helloRef);

String filename = "A://HelloIOR";

FileOutputStream fos = new FileOutputStream(filename);

PrintStream ps = new PrintStream(fos);

ps.print(str); ps.close();

java.lang.Object sync = new java.lang.Object();

synchronized (sync) {

sync.wait();

}

} catch (Exception e) {

System.err.println("ERROR: " + e);

e.printStackTrace(System.out);

}

}

}

The Server runs as an application and has only a main method.

Implementing the Server

Marc Conrad University of Bedfordshire

implementing the server43
import java.io.*; import org.omg.CORBA.*; import Example.*;

public class HelloServer {

public static void main(String args[])

{

try{

ORB orb = ORB.init(args, null);

HelloServant helloRef = new HelloServant();

orb.connect(helloRef);

String str = orb.object_to_string(helloRef);

String filename = "A://HelloIOR";

FileOutputStream fos = new FileOutputStream(filename);

PrintStream ps = new PrintStream(fos);

ps.print(str); ps.close();

java.lang.Object sync = new java.lang.Object();

synchronized (sync) {

sync.wait();

}

} catch (Exception e) {

System.err.println("ERROR: " + e);

e.printStackTrace(System.out);

}

}

}

Initialise the ORB. Here we are using the ORB provided by the JDK.

Implementing the Server

Marc Conrad University of Bedfordshire

implementing the server44
import java.io.*; import org.omg.CORBA.*; import Example.*;

public class HelloServer {

public static void main(String args[])

{

try{

ORB orb = ORB.init(args, null);

HelloServant helloRef = new HelloServant();

orb.connect(helloRef);

String str = orb.object_to_string(helloRef);

String filename = "A://HelloIOR";

FileOutputStream fos = new FileOutputStream(filename);

PrintStream ps = new PrintStream(fos);

ps.print(str); ps.close();

java.lang.Object sync = new java.lang.Object();

synchronized (sync) {

sync.wait();

}

} catch (Exception e) {

System.err.println("ERROR: " + e);

e.printStackTrace(System.out);

}

}

}

Make an instance of the Servant class, and ...

Implementing the Server

Marc Conrad University of Bedfordshire

implementing the server45
import java.io.*; import org.omg.CORBA.*; import Example.*;

public class HelloServer {

public static void main(String args[])

{

try{

ORB orb = ORB.init(args, null);

HelloServant helloRef = new HelloServant();

orb.connect(helloRef);

String str = orb.object_to_string(helloRef);

String filename = "A://HelloIOR";

FileOutputStream fos = new FileOutputStream(filename);

PrintStream ps = new PrintStream(fos);

ps.print(str); ps.close();

java.lang.Object sync = new java.lang.Object();

synchronized (sync) {

sync.wait();

}

} catch (Exception e) {

System.err.println("ERROR: " + e);

e.printStackTrace(System.out);

}

}

}

…tell the ORB about it.

Implementing the Server

Marc Conrad University of Bedfordshire

implementing the server46
import java.io.*; import org.omg.CORBA.*; import Example.*;

public class HelloServer {

public static void main(String args[])

{

try{

ORB orb = ORB.init(args, null);

HelloServant helloRef = new HelloServant();

orb.connect(helloRef);

String str = orb.object_to_string(helloRef);

String filename = "A://HelloIOR";

FileOutputStream fos = new FileOutputStream(filename);

PrintStream ps = new PrintStream(fos);

ps.print(str); ps.close();

java.lang.Object sync = new java.lang.Object();

synchronized (sync) {

sync.wait();

}

} catch (Exception e) {

System.err.println("ERROR: " + e);

e.printStackTrace(System.out);

}

}

}

We generate a “stringified” reference of the object (and write it to a file).

Implementing the Server

Marc Conrad University of Bedfordshire

implementing the server47
import java.io.*; import org.omg.CORBA.*; import Example.*;

public class HelloServer {

public static void main(String args[])

{

try{

ORB orb = ORB.init(args, null);

HelloServant helloRef = new HelloServant();

orb.connect(helloRef);

String str = orb.object_to_string(helloRef);

String filename = "A://HelloIOR";

FileOutputStream fos = new FileOutputStream(filename);

PrintStream ps = new PrintStream(fos);

ps.print(str); ps.close();

java.lang.Object sync = new java.lang.Object();

synchronized (sync) {

sync.wait();

}

} catch (Exception e) {

System.err.println("ERROR: " + e);

e.printStackTrace(System.out);

}

}

}

Keep the server alive.

Implementing the Server

Marc Conrad University of Bedfordshire

implementing the server48
import java.io.*; import org.omg.CORBA.*; import Example.*;

public class HelloServer {

public static void main(String args[])

{

try{

ORB orb = ORB.init(args, null);

HelloServant helloRef = new HelloServant();

orb.connect(helloRef);

String str = orb.object_to_string(helloRef);

String filename = "A://HelloIOR";

FileOutputStream fos = new FileOutputStream(filename);

PrintStream ps = new PrintStream(fos);

ps.print(str); ps.close();

java.lang.Object sync = new java.lang.Object();

synchronized (sync) {

sync.wait();

}

} catch (Exception e) {

System.err.println("ERROR: " + e);

e.printStackTrace(System.out);

}

}

}

Catch any errors.

Implementing the Server

Marc Conrad University of Bedfordshire

implementing the server49
import java.io.*; import org.omg.CORBA.*; import Example.*;

public class HelloServer {

public static void main(String args[])

{

try{

ORB orb = ORB.init(args, null);

HelloServant helloRef = new HelloServant();

orb.connect(helloRef);

String str = orb.object_to_string(helloRef);

String filename = "A://HelloIOR";

FileOutputStream fos = new FileOutputStream(filename);

PrintStream ps = new PrintStream(fos);

ps.print(str); ps.close();

java.lang.Object sync = new java.lang.Object();

synchronized (sync) {

sync.wait();

}

} catch (Exception e) {

System.err.println("ERROR: " + e);

e.printStackTrace(System.out);

}

}

}

Initialise the ORB

Instantiate a HelloServant object.

Register this object in the ORB.

Publish the object to the rest of the world

Wait for client requests.

Implementing the Server

Marc Conrad University of Bedfordshire

implementing the client
Implementing the Client
  • A client has to perform the following tasks:
    • Initialise the ORB.
    • Obtaining an object reference.
    • Narrowing (casting) the reference.
    • Using the object.

Marc Conrad University of Bedfordshire

implementing the client51
import java.io.*; import org.omg.CORBA.*; import Example.*;

public class HelloClient {

public static void main(String args[])

{

try{

ORB orb = ORB.init(args, null);

String filename = "A://HelloIOR";

FileInputStream fis = new FileInputStream(filename);

java.io.DataInputStream dis = new java.io.DataInputStream(fis) ;

String ior = dis.readLine() ;

org.omg.CORBA.Object obj = orb.string_to_object(ior) ;

Hello helloRef = HelloHelper.narrow(obj);

String str = helloRef.sayHello();

System.out.println(str);

} catch (Exception e) {

System.out.println("ERROR : " + e) ;

e.printStackTrace(System.out);

}

}

}

The file HelloClient.java

Implementing the Client.

Marc Conrad University of Bedfordshire

implementing the client52
import java.io.*; import org.omg.CORBA.*; import Example.*;

public class HelloClient {

public static void main(String args[])

{

try{

ORB orb = ORB.init(args, null);

String filename = "A://HelloIOR";

FileInputStream fis = new FileInputStream(filename);

java.io.DataInputStream dis = new java.io.DataInputStream(fis) ;

String ior = dis.readLine() ;

org.omg.CORBA.Object obj = orb.string_to_object(ior) ;

Hello helloRef = HelloHelper.narrow(obj);

String str = helloRef.sayHello();

System.out.println(str);

} catch (Exception e) {

System.out.println("ERROR : " + e) ;

e.printStackTrace(System.out);

}

}

}

Initialising the ORB.

Implementing the Client.

Marc Conrad University of Bedfordshire

implementing the client53
import java.io.*; import org.omg.CORBA.*; import Example.*;

public class HelloClient {

public static void main(String args[])

{

try{

ORB orb = ORB.init(args, null);

String filename = "A://HelloIOR";

FileInputStream fis = new FileInputStream(filename);

java.io.DataInputStream dis =

new java.io.DataInputStream(fis) ;

String ior = dis.readLine() ;

org.omg.CORBA.Object obj = orb.string_to_object(ior) ;

Hello helloRef = HelloHelper.narrow(obj);

String str = helloRef.sayHello();

System.out.println(str);

} catch (Exception e) {

System.out.println("ERROR : " + e) ;

e.printStackTrace(System.out);

}

}

}

Reading the stringified object reference from the file.

Implementing the Client.

Marc Conrad University of Bedfordshire

implementing the client54
import java.io.*; import org.omg.CORBA.*; import Example.*;

public class HelloClient {

public static void main(String args[])

{

try{

ORB orb = ORB.init(args, null);

String filename = "A://HelloIOR";

FileInputStream fis = new FileInputStream(filename);

java.io.DataInputStream dis = new java.io.DataInputStream(fis) ;

String ior = dis.readLine() ;

org.omg.CORBA.Object obj = orb.string_to_object(ior) ;

Hello helloRef = HelloHelper.narrow(obj);

String str = helloRef.sayHello();

System.out.println(str);

} catch (Exception e) {

System.out.println("ERROR : " + e) ;

e.printStackTrace(System.out);

}

}

}

Generating an object reference from the string

Implementing the Client.

Marc Conrad University of Bedfordshire

implementing the client55
import java.io.*; import org.omg.CORBA.*; import Example.*;

public class HelloClient {

public static void main(String args[])

{

try{

ORB orb = ORB.init(args, null);

String filename = "A://HelloIOR";

FileInputStream fis = new FileInputStream(filename);

java.io.DataInputStream dis = new java.io.DataInputStream(fis) ;

String ior = dis.readLine() ;

org.omg.CORBA.Object obj = orb.string_to_object(ior) ;

Hello helloRef = HelloHelper.narrow(obj);

String str = helloRef.sayHello();

System.out.println(str);

} catch (Exception e) {

System.out.println("ERROR : " + e) ;

e.printStackTrace(System.out);

}

}

}

Casting the object to the expected type.

Implementing the Client.

Marc Conrad University of Bedfordshire

implementing the client56
import java.io.*; import org.omg.CORBA.*; import Example.*;

public class HelloClient {

public static void main(String args[])

{

try{

ORB orb = ORB.init(args, null);

String filename = "A://HelloIOR";

FileInputStream fis = new FileInputStream(filename);

java.io.DataInputStream dis = new java.io.DataInputStream(fis) ;

String ior = dis.readLine() ;

org.omg.CORBA.Object obj = orb.string_to_object(ior) ;

Hello helloRef = HelloHelper.narrow(obj);

String str = helloRef.sayHello();

System.out.println(str);

} catch (Exception e) {

System.out.println("ERROR : " + e) ;

e.printStackTrace(System.out);

}

}

}

Using the object.

Implementing the Client.

Marc Conrad University of Bedfordshire

implementing the client57
import java.io.*; import org.omg.CORBA.*; import Example.*;

public class HelloClient {

public static void main(String args[])

{

try{

ORB orb = ORB.init(args, null);

String filename = "A://HelloIOR";

FileInputStream fis = new FileInputStream(filename);

java.io.DataInputStream dis = new java.io.DataInputStream(fis) ;

String ior = dis.readLine() ;

org.omg.CORBA.Object obj = orb.string_to_object(ior) ;

Hello helloRef = HelloHelper.narrow(obj);

String str = helloRef.sayHello();

System.out.println(str);

} catch (Exception e) {

System.out.println("ERROR : " + e) ;

e.printStackTrace(System.out);

}

}

}

Initialising the ORB.

Retrieving an object reference.

Narrowing the object.

Using the object.

Implementing the Client.

Marc Conrad University of Bedfordshire

running the application
Running the Application
  • Run the Server
    • (Send the disk with the stringified object reference via Royal Mail to the remote machine)
    • Better: link the object to a naming service
  • Run the Client
    • (There is no additional naming service required as stringified object references are used)

Marc Conrad University of Bedfordshire

corba development process59

2. Identify

1. Write Code

3. Communicate

Client

Clientkdfjshkdsahfkdashfkajshfkdsjhkjsahfkdshfkhasdfkashfkdjsahfkshdfkhsafkjshfkdsfhakjdhfksjdhfakhsfkjsdfkdasjfkdasjksdajfkdsafhksajhkdjfhkasjkdsahksdjfksakdjsfksakshfdkjfdkdsfh

Client

Serverkdfjshkdsahfkdashfkajshfkdsjhkjsahfkdshfkhasdfkashfkdjsahfkshdfkhsafkjshfkdsfhakjdhfksjdhfakhsfkjsdfkdasjfkdasjksdajfkdsafhksajhk assfksakshfdkjf

10010101101110101

Server

CORBA Development Process

0. Specify Service

IDLkdfjshkdsahfkdashfkajshfkdsjhkjsahfkdshfkhasdfkashfkdjsahfkshdfkhsafkjshfkdsfhakjdhfksjdhfakhsfkjsdfkdasjfkdasjksdajfkdsafhksajhk assfksakshfdkjf

Server

Marc Conrad University of Bedfordshire

a stringified reference
A stringified reference
  • Here is an example of an stringified object reference, generated by the example code:
  • IOR:000000000000001649444c3a4578616d706c652f48656c6c6f3a312e30000000000000010000000000000058000101000000000f3139342e38302e3231352e32323300000682000000000018afabcaff0000000225163ffd0000000800000000000000000000000100000001000000140000000000010020000000000001010000000000

Observe, that the stringified object reference is in plain text. It can be passed by email or a sheet of paper.

Marc Conrad University of Bedfordshire

the corba services
Instead of sending a stringified object reference we can use CORBA services for obtaining object references:

The CORBA naming service, which finds objects by name, similar to a "white page" phone book.

The CORBA trading service, which finds references that match search criteria, similar to a "yellow page" service.

Question: How do we find the naming service without a naming service?

The CORBA services

Marc Conrad University of Bedfordshire

corba services
CORBA Services
  • The initial references to instances of those services can be found via operations which are part of the ORB interface ("bootstrapping"), namely:
    • list_initial_services()
    • resolve_initial_references()
  • The association between an ORB and services is outside the CORBA definition.

Marc Conrad University of Bedfordshire

corba development process63

2. Identify

1. Write Code

3. Communicate

Client

Clientkdfjshkdsahfkdashfkajshfkdsjhkjsahfkdshfkhasdfkashfkdjsahfkshdfkhsafkjshfkdsfhakjdhfksjdhfakhsfkjsdfkdasjfkdasjksdajfkdsafhksajhkdjfhkasjkdsahksdjfksakdjsfksakshfdkjfdkdsfh

Client

Serverkdfjshkdsahfkdashfkajshfkdsjhkjsahfkdshfkhasdfkashfkdjsahfkshdfkhsafkjshfkdsfhakjdhfksjdhfakhsfkjsdfkdasjfkdasjksdajfkdsafhksajhk assfksakshfdkjf

10010101101110101

Server

CORBA Development Process

0. Specify Service

IDLkdfjshkdsahfkdashfkajshfkdsjhkjsahfkdshfkhasdfkashfkdjsahfkshdfkhsafkjshfkdsfhakjdhfksjdhfakhsfkjsdfkdasjfkdasjksdajfkdsafhksajhk assfksakshfdkjf

Server

Marc Conrad University of Bedfordshire

slide64
IIOP
  • See http://www.omg.org/library/iiop4.html if you really want to know.

Marc Conrad University of Bedfordshire

summary
Summary
  • The IDL provides class definitions for objects.
  • A Compiler compiles the IDL into several files.
  • The server and the client are then implemented by using these files.
  • The ORB plays a crucial role in running the application both for the server and for the client.

Marc Conrad University of Bedfordshire