Common Object Request Broker Architecture CORBA - PowerPoint PPT Presentation

1 / 22
About This Presentation
Title:

Common Object Request Broker Architecture CORBA

Description:

Developed by the Object Management Group (OMG) consortium ... Hello.java - Java version of interface (extends org.omg.Corba.Object) ... – PowerPoint PPT presentation

Number of Views:342
Avg rating:3.0/5.0
Slides: 23
Provided by: joseph120
Category:

less

Transcript and Presenter's Notes

Title: Common Object Request Broker Architecture CORBA


1
Common Object Request Broker Architecture (CORBA)
  • Joe Komar

2
CORBA Overview
  • Standard distributed object architecture
  • Developed by the Object Management Group (OMG)
    consortium
  • Open software bus (Object Request Broker(ORB))
  • CORBA objects can invoke one another without
    knowing where the objects reside and in what
    language they are implemented

3
Interface Definition Language
  • Defines interfaces to CORBA objects
  • Mappings to Java, C, C, Smalltalk, COBOL, and
    Ada
  • Java IDL
  • ORB with JDK 1.2
  • Allows access to CORBA objects from Java
  • Compliant with CORBA/IIOP 2.0 spec and the
    IDL-to-Java Mapping

4
Overview of CORBA
Client
Server
Stubs
Skeletons
IIOP
ORB
ORB
Method Request
5
CORBA Concepts
  • Client obtains an object reference
  • Reference points to a stub
  • Stub uses the ORB mechanism to forward method
    invocations
  • Skeleton code transforms the call and parameters
    to implementation specific format and calls the
    object
  • Results returned via the same mechanisms

6
Interface Definition Language
  • All CORBA objects support an IDL interface
  • Interface defines the object type
  • Interface can inherit from one or more interfaces
  • Syntax is very similar to Java or C
  • IDL is mapped to specific languages to provide
    access from that language
  • idltojava compiler translates IDL to Java --
    interface, stub, skeleton, and others as needed

7
IDL Example
Module HelloApp interface Hello
string sayHello()
8
Java Specific CORBA Server
  • Write IDL (.idl file)
  • Use idltojava compiler and generate .java files
  • Write server code to implement interface
  • Server implementation compiled and linked to
    other files and the ORB library
  • Define a factory object interface and implement
    it for each object type (Only a server may create
    CORBA objects)

9
Java Specific Client
  • Clients create objects through the factory
  • Obtain object references
  • from a factory object -- e.g., invoke a
    create method which returns the object
    reference
  • from the nameservice
  • from a string specifically created from an object
    reference
  • Reference is then narrowed using a helper class
    generated by idltojava compiler

10
Transient Name Server
  • Java IDL Transient Nameservice
  • Type tnameserv at the operating system prompt
  • Stores object references by name in a tree
    structure
  • Clients lookup or resolve object references by
    name
  • All names are lost when tnameserv stops running

11
Hello World IDL
Module HelloApp interface Hello
string sayHello()
12
Idltojava Hello.idl
  • Generates the following files in the HelloApp
    subdirectory
  • _HelloImplBase.java - server skeleton
  • _HelloStub.java - client stub
  • Hello.java - Java version of interface (extends
    org.omg.Corba.Object)
  • HelloHelper.java - narrow() method
  • HelloHolder.java - public instance member of type
    Hello. Provides operations for out and inout
    arguments needed by CORBA

13
HelloServer.java
  • Implements all the methods of the interface
  • main() method must
  • Create an ORB instance
  • Create a servant instance and tells the ORB about
    it
  • Gets a CORBA object reference for a naming
    context
  • Registers the new object in the naming context
  • Waits for invocations of the new object

14
HelloServer.java code
import HelloApp. import org.omg.CosNaming. imp
ort org.omg.CosNaming.NamingContextPackage. impo
rt org.omg.CORBA. class HelloServant extends
_HelloImplBase public String sayHello()
return "\nHello world !!\n"
15
HelloServer Code
public class HelloServer public static
void main(String args) try
// create and initialize the ORB
ORB orb ORB.init(args, null) //
create servant and register it with the ORB
HelloServant helloRef new
HelloServant() orb.connect(helloRef)
// get the root naming context
org.omg.CORBA.Object objRef
orb.resolve_initial_references("NameService")
NamingContext ncRef
NamingContextHelper.narrow(objRef)
16
HelloServer Code
// bind the Object Reference in Naming
NameComponent nc new NameComponent("Hello",
"") NameComponent path nc
ncRef.rebind(path, helloRef)
// wait for invocations from clients
java.lang.Object sync new java.lang.Object()
synchronized (sync)
sync.wait() catch
(Exception e) System.err.println("ER
ROR " e) e.printStackTrace(System.
out)
17
HelloClient.java Implementation
  • Creates an ORB
  • Obtains a reference to the naming context
  • Looks up Hello in the naming context and
    receives a reference to that CORBA object
  • Invokes the objects method and prints results

18
HelloClient Code
import HelloApp. import org.omg.CosNaming. imp
ort org.omg.CORBA. public class HelloClient
public static void main(String args)

19
HelloClient Code
try // create and initialize the ORB
ORB orb ORB.init(args, null)
// get the root naming context
org.omg.CORBA.Object objRef orb.resolve_initial_
references("NameService")
NamingContext ncRef NamingContextHelper.narrow(o
bjRef) // resolve the Object
Reference in Naming NameComponent nc
new NameComponent("Hello", "")
NameComponent path nc Hello
helloRef HelloHelper.narrow(ncRef.resolve(path))

20
HelloClient Code
// call the Hello server object and
print results String hello
helloRef.sayHello()
System.out.println(hello) catch
(Exception e) System.out.println("ER
ROR " e) e.printStackTrace(Syste
m.out)
21
Building and Running the Example
  • idltojava Hello.idl -- to created files
  • java .java HelloApp\.java -- to compile all
    programs
  • tnameserv -ORBInitialPort 1050 -- to run the
    name server
  • java HelloServer -ORBInitialPort 1050 -- to start
    the server
  • java HelloClient -ORBInitialPort 1050 -- to run
    the client

22
Client/Server Summary
  • CORBA is the primary way to link Java to objects
    written in other languages
  • RMI can also be used if its all Java
  • DCOM is the primary competitor to CORBA, but runs
    on limited platforms
  • Sockets are too low level for enterprise use
  • CGI is very slow, with servlets being
    substantially faster, but still slow
Write a Comment
User Comments (0)
About PowerShow.com