SlideShare a Scribd company logo
1 of 12
Download to read offline
Common Object
            Request Broker
            Architecture
            (CORBA)




CORBA
CORBA is similar in high level concepts to
RMI RMI is basically a simplified form of
CORBA
Adds cross-platform, multiple language
interfaces, more bells and whistles
Widely used standard
CORBA

    At the top level the architecture is similar
    to RMI
                   Client
                       Stub            Object Request Broker (ORB)


                                   Skeleton
                                         Server




 ORB and IIOP

The Internet Inter-ORB Protocol (IIOP) is a protocol by which
ORBs communicate (Similar to JRMP in RMI)
CORBA
 The Object Request Broker (ORB) is the “bus” that
 connects objects across the network. It’s a virtual bus;
 some network software that runs on each machine
 It locates the object on the network, communicates the
 message, and waits for results
 Not all ORBs are alike—there are some standardization
 moves around, but it’s not generally true that a client
 using one ORB can talk to a remote object using a
 different ORB
 Major vendors: Java 2 ORB, VisiBroker, WebSphere
 ORB, Iona (Orbix).




CORBA Services

 CORBA has a standard, the IIOP, that
 (supposedly) allows you to communicate with
 CORBA objects running on another vendor’s
 ORB over TCP/IP
 The CORBA infrastructure also provides
 services for naming, transactions, object
 creation, etc. These are CORBA services
 implemented in CORBA.
Stub & Skeleton Creation
       In RMI we had an RMI compiler run on the .class
       file we wanted to be remote. It’s different under
       CORBA
       The interface is written in Interface Definition
       Language, IDL. IDL is language-neutral (by
       being a different language than anything else)
       though highly reminiscent of C++ (multiple
       inheritance, similar syntax, etc.)
       IDL has a set of primitive data types similar to
       most languages—integer, float, string, byte, etc.




     CORBA Development Process
1.    Write an IDL file which describes the interface to the
      distributed object.
2.    Run idlj on the IDL file. This generates Java code
      that implements the stub and the skeleton
3.    Run nameserver
4.    Implement the servant (implement the IDL interface)
5.    Implement the server (register the servant with the
      naming service and wait for requests)
6.    Implement the client
7.    Run the server
8.    Run the client
Interface Definition Language (IDL)
    Compile the IDL code with idlj. This creates java
    source code files in the Tracker package. Note
    the use of the IDL primitive type “string”
    idlj -fclient -fserver –oldImplBase Tracker.idl



                module Tracker {
                 interface Time {
                  string getTime();
                 };
                };




Interface Definition Language (IDL) (Contd.)


    A pure description language.
       enables developers to describe an interface they wish
       to use remotely in a language-independent fashion.
    Language specific compiler required for each
    participating language (e.g., idlj for Java).
       creates files required by each language for CORBA
       related tasks.
Idlj: IDL to Java Compile output
 Idlj generates some horror-story java code in the
 Tracker directory.
   _TimeStub (the stub for the client)
   Time (the interface for the distributed object)
   TimeHelper (Kitchen sink functionality)
   TimeHolder (Serialization & communications; out &
   inout parameters)
   TimeOperations (initial server implementation)
   _TimeImplBase (base class for servant)




Start the nameserver

 CORBA uses a technique similar to that of the
 RMI registry. Servers register with the name
 server, and clients ask the name server where to
 find the server.
 orbd –ORBInitialPort <myPort>
  Example: orbd –ORBInitialPort 900
 This is a replacement for the older
 tnsnameserver
 Note that myPort must match up with the
 properties used to find the name server in the
 client and server
Client-side Code
    Very similar to RMI
      Get reference to remote object
      Cast it to what you want
      Call methods on the object via the local proxy
      object
     On the other hand, there are more annoyances
      due to CORBAs multi-language background




Client.java:
package ex1;
import Tracker.*; // The package containing our stubs.
import org.omg.CosNaming.*; // Client will use the naming service.
import org.omg.CORBA.*; // All CORBA applications need these classes.

public class Client {
 public static void main (String args[]) {
  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 (objRef);
   // Resolve the object reference in naming
   NameComponent nc = new NameComponent ("TimeServer", "");
   NameComponent path[] = {nc};
   Time timeRef = TimeHelper.narrow (ncRef.resolve (path));
   // Call the time server object and print results
   String time = "Time on the Server is " + timeRef.getTime ();
   System.out.println (time);
  } catch (Exception e) {
   e.printStackTrace ();
  }
 }
}
Server-side Code

   On the server-side, there is the “Server”
   code, and the “Servant” code. The servant
   code is the object implementation. The
   server code holds one or more servants.




The servant Code
package ex1;
 // The package containing our stubs.
import Tracker.*;
// Server will use the naming service.
import org.omg.CosNaming.*;
// The package containing special exceptions thrown by the name service.
import org.omg.CosNaming.NamingContextPackage.*;
// All CORBA applications need these classes.
import org.omg.CORBA.*;
import java.util.*;
import java.text.*;

class TimeServer extends _TimeImplBase
{
   public String getTime ()
   {
   SimpleDateFormat formatter = new SimpleDateFormat ("MMMMM dd,
   yyyyy GGG, hh:mm:ss:SSS aaa"); Date date = new Date (); return
   formatter.format ( date );
   }
}
The Server Code

    The server code does the following:
          Creates a new Servant object
          Registers the Servant with the naming service
          Listens for incoming requests (Makes sure we
          don’t exit)




package ex1;
                                The Server Code
// The package containing our stubs.
import Tracker.*;
// Server will use the naming service.
import org.omg.CosNaming.*;
// The package containing special exceptions thrown by the name service.
import org.omg.CosNaming.NamingContextPackage.*;
// All CORBA applications need these classes.
import org.omg.CORBA.*;

public class Server {
 public static void main (String args[]) {
  try {
   // Create and initialize the ORB
   ORB orb = ORB.init (args, null);
   // Create the servant and register it with the ORB
   TimeServer timeRef = new TimeServer ();
   orb.connect (timeRef);
   // Get the root naming context
   org.omg.CORBA.Object objRef = orb.resolve_initial_references ("NameService");
   NamingContext ncRef = NamingContextHelper.narrow (objRef);
   // Bind the object reference in naming
   NameComponent nc = new NameComponent ("TimeServer", "");
   NameComponent path[] = {nc};
   ncRef.rebind (path, timeRef);
   // Wait forever for current thread to die
   Thread.currentThread ().join ();
  } catch (Exception e) {
   e.printStackTrace ();
  }
 }
}
Overview of Compilation Process

                              Time.idl


                             IDL Compiler
   _TimeStub                                           _TimeImplBase
                              Classes &
                              interfaces
                                                           Time server
Time client                                                application
application                  Java compiler


              Client byte                    Server byte
              code                           code




                            RMI In One Slide
Service Interface
                                     -Implements Remote-
                                        (Written in Java)


                                      Service Implementation
                                  (Extends UnicastRemoteObject
                                   Implements Service Interface)


                                                    rmic


                  Generated Stub                           Generated Skeleton
Client                                                                                             Server
needs                                                                                              needs
                          Client::                                             Server:
         •Lookup Service by name from rmiregistry                     •Create Service Instance
          •Use remote reference to access service                  •Register Service with rmiregistry


                                                                                bind
                             lookup                 rmiregistry




                                 CORBA In One Slide
Service Interface
                                  (written in IDL)

                                                   idlj

                Generated Stub                            Generated Skeleton

                                                                                                Service
                                      Generated                                                 needs
                                     Helper Class
                                                                            CORBA Service
                                                                            Extends Skeleton
Client
needs
                        Client::                                             Server:
                     •Create ORB                                          •Create ORB
     •Lookup Service by name from naming service                    •Create Service Instance
        •Use remote reference to access service               •Register Service with naming service


                                                 orbd                       bind
                          lookup
                                                 -OR-
                                              tnameserv




    Reference
         CORBA, The MOVE Institute: Naval Postgraduate School.

More Related Content

What's hot (20)

Corba
CorbaCorba
Corba
 
Distributed objects & components of corba
Distributed objects & components of corbaDistributed objects & components of corba
Distributed objects & components of corba
 
Corba
CorbaCorba
Corba
 
Common Object Request Broker Architecture - CORBA
Common Object Request Broker Architecture - CORBACommon Object Request Broker Architecture - CORBA
Common Object Request Broker Architecture - CORBA
 
Lecture4 corba
Lecture4   corbaLecture4   corba
Lecture4 corba
 
Corba model ppt
Corba model pptCorba model ppt
Corba model ppt
 
CORBA Component Model
CORBA Component Model CORBA Component Model
CORBA Component Model
 
Corba and-java
Corba and-javaCorba and-java
Corba and-java
 
RMI and CORBA Why both are valuable tools
RMI and CORBA Why both are valuable toolsRMI and CORBA Why both are valuable tools
RMI and CORBA Why both are valuable tools
 
Chapter10
Chapter10Chapter10
Chapter10
 
CORBA
CORBACORBA
CORBA
 
Corba
CorbaCorba
Corba
 
Corba by Example
Corba by ExampleCorba by Example
Corba by Example
 
Common Object Request Broker Architecture
Common Object Request Broker ArchitectureCommon Object Request Broker Architecture
Common Object Request Broker Architecture
 
82159587 case-study-on-corba
82159587 case-study-on-corba82159587 case-study-on-corba
82159587 case-study-on-corba
 
C O R B A Unit 4
C O R B A    Unit 4C O R B A    Unit 4
C O R B A Unit 4
 
19.cobra
19.cobra19.cobra
19.cobra
 
CORBA & RMI in java
CORBA & RMI in javaCORBA & RMI in java
CORBA & RMI in java
 
Rmi, corba and java beans
Rmi, corba and java beansRmi, corba and java beans
Rmi, corba and java beans
 
Unit 15 cobra case
Unit   15 cobra caseUnit   15 cobra case
Unit 15 cobra case
 

Viewers also liked

Distributed Objects: CORBA/Java RMI
Distributed Objects: CORBA/Java RMIDistributed Objects: CORBA/Java RMI
Distributed Objects: CORBA/Java RMIelliando dias
 
Brain chips ppt
Brain chips pptBrain chips ppt
Brain chips ppt9440999171
 
Outsourcing your share point hosting the cloud’s fine print magnified
Outsourcing your share point hosting the cloud’s fine print magnifiedOutsourcing your share point hosting the cloud’s fine print magnified
Outsourcing your share point hosting the cloud’s fine print magnifiedSherWeb
 
global child care powerpoint
global child care powerpointglobal child care powerpoint
global child care powerpointWendySteph
 
Finished proposal
Finished proposalFinished proposal
Finished proposalSammo_644
 
мамочка и я
мамочка и ямамочка и я
мамочка и яklepa.ru
 
The Vineyards Hotel Spa and iMA Training complex (iMAplex)
The Vineyards Hotel Spa and iMA Training complex (iMAplex)The Vineyards Hotel Spa and iMA Training complex (iMAplex)
The Vineyards Hotel Spa and iMA Training complex (iMAplex)James Knight
 
Новости недвижимости Майами - Февраль 2016
Новости недвижимости Майами - Февраль 2016Новости недвижимости Майами - Февраль 2016
Новости недвижимости Майами - Февраль 2016The Reznik Group
 
The Shaklee difference
The Shaklee difference The Shaklee difference
The Shaklee difference Cindy McAsey
 
Unraveling Our Data
Unraveling Our DataUnraveling Our Data
Unraveling Our DataChar Simser
 
2016 Monitor Awards Gold Winners: P&C Insurance
2016 Monitor Awards Gold Winners: P&C Insurance2016 Monitor Awards Gold Winners: P&C Insurance
2016 Monitor Awards Gold Winners: P&C InsuranceCorporate Insight
 

Viewers also liked (20)

Distributed Objects: CORBA/Java RMI
Distributed Objects: CORBA/Java RMIDistributed Objects: CORBA/Java RMI
Distributed Objects: CORBA/Java RMI
 
Brain chips ppt
Brain chips pptBrain chips ppt
Brain chips ppt
 
Brain chips
Brain chipsBrain chips
Brain chips
 
Ejb3
Ejb3Ejb3
Ejb3
 
Outsourcing your share point hosting the cloud’s fine print magnified
Outsourcing your share point hosting the cloud’s fine print magnifiedOutsourcing your share point hosting the cloud’s fine print magnified
Outsourcing your share point hosting the cloud’s fine print magnified
 
Dominios
DominiosDominios
Dominios
 
Dacnetmou final
Dacnetmou finalDacnetmou final
Dacnetmou final
 
Plants
PlantsPlants
Plants
 
global child care powerpoint
global child care powerpointglobal child care powerpoint
global child care powerpoint
 
Finished proposal
Finished proposalFinished proposal
Finished proposal
 
Concept paperpakistancio summit2013
Concept paperpakistancio summit2013Concept paperpakistancio summit2013
Concept paperpakistancio summit2013
 
мамочка и я
мамочка и ямамочка и я
мамочка и я
 
The Vineyards Hotel Spa and iMA Training complex (iMAplex)
The Vineyards Hotel Spa and iMA Training complex (iMAplex)The Vineyards Hotel Spa and iMA Training complex (iMAplex)
The Vineyards Hotel Spa and iMA Training complex (iMAplex)
 
Новости недвижимости Майами - Февраль 2016
Новости недвижимости Майами - Февраль 2016Новости недвижимости Майами - Февраль 2016
Новости недвижимости Майами - Февраль 2016
 
Stom alum
Stom alumStom alum
Stom alum
 
12 pensaments
12 pensaments12 pensaments
12 pensaments
 
Data entry
Data entryData entry
Data entry
 
The Shaklee difference
The Shaklee difference The Shaklee difference
The Shaklee difference
 
Unraveling Our Data
Unraveling Our DataUnraveling Our Data
Unraveling Our Data
 
2016 Monitor Awards Gold Winners: P&C Insurance
2016 Monitor Awards Gold Winners: P&C Insurance2016 Monitor Awards Gold Winners: P&C Insurance
2016 Monitor Awards Gold Winners: P&C Insurance
 

Similar to Corba

corbaintroductionandexample-140703005744-phpapp02.pdf
corbaintroductionandexample-140703005744-phpapp02.pdfcorbaintroductionandexample-140703005744-phpapp02.pdf
corbaintroductionandexample-140703005744-phpapp02.pdfBesAli1
 
85305524 i-t-case-study
85305524 i-t-case-study85305524 i-t-case-study
85305524 i-t-case-studyhomeworkping3
 
Introduction to Remote Method Invocation (RMI)
Introduction to Remote Method Invocation (RMI)Introduction to Remote Method Invocation (RMI)
Introduction to Remote Method Invocation (RMI)eLink Business Innovations
 
Session 1 Tp1
Session 1 Tp1Session 1 Tp1
Session 1 Tp1phanleson
 
Javarmi 130925082348-phpapp01
Javarmi 130925082348-phpapp01Javarmi 130925082348-phpapp01
Javarmi 130925082348-phpapp01heenamithadiya
 
Remote Method Innovation (RMI) In JAVA
Remote Method Innovation (RMI) In JAVARemote Method Innovation (RMI) In JAVA
Remote Method Innovation (RMI) In JAVAPrankit Mishra
 
ADVANCED JAVA MODULE III & IV.ppt
ADVANCED JAVA MODULE III & IV.pptADVANCED JAVA MODULE III & IV.ppt
ADVANCED JAVA MODULE III & IV.pptrani marri
 
The use of Symfony2 @ Overblog
The use of Symfony2 @ OverblogThe use of Symfony2 @ Overblog
The use of Symfony2 @ OverblogXavier Hausherr
 
Mike Taulty OData (NxtGen User Group UK)
Mike Taulty OData (NxtGen User Group UK)Mike Taulty OData (NxtGen User Group UK)
Mike Taulty OData (NxtGen User Group UK)ukdpe
 
corba-151024114450-lva1-app6891.pptx
corba-151024114450-lva1-app6891.pptxcorba-151024114450-lva1-app6891.pptx
corba-151024114450-lva1-app6891.pptxAasimAbdul
 
Remote Method Invocation (Java RMI)
Remote Method Invocation (Java RMI)Remote Method Invocation (Java RMI)
Remote Method Invocation (Java RMI)Sonali Parab
 

Similar to Corba (20)

internet
internetinternet
internet
 
Distributed objects
Distributed objectsDistributed objects
Distributed objects
 
Rmi
RmiRmi
Rmi
 
corbaintroductionandexample-140703005744-phpapp02.pdf
corbaintroductionandexample-140703005744-phpapp02.pdfcorbaintroductionandexample-140703005744-phpapp02.pdf
corbaintroductionandexample-140703005744-phpapp02.pdf
 
Chapter2
Chapter2Chapter2
Chapter2
 
85305524 i-t-case-study
85305524 i-t-case-study85305524 i-t-case-study
85305524 i-t-case-study
 
Introduction to Remote Method Invocation (RMI)
Introduction to Remote Method Invocation (RMI)Introduction to Remote Method Invocation (RMI)
Introduction to Remote Method Invocation (RMI)
 
DS
DSDS
DS
 
Session 1 Tp1
Session 1 Tp1Session 1 Tp1
Session 1 Tp1
 
Javarmi 130925082348-phpapp01
Javarmi 130925082348-phpapp01Javarmi 130925082348-phpapp01
Javarmi 130925082348-phpapp01
 
Java rmi
Java rmiJava rmi
Java rmi
 
6. The grid-COMPUTING OGSA and WSRF
6. The grid-COMPUTING OGSA and WSRF6. The grid-COMPUTING OGSA and WSRF
6. The grid-COMPUTING OGSA and WSRF
 
Remote Method Innovation (RMI) In JAVA
Remote Method Innovation (RMI) In JAVARemote Method Innovation (RMI) In JAVA
Remote Method Innovation (RMI) In JAVA
 
ADVANCED JAVA MODULE III & IV.ppt
ADVANCED JAVA MODULE III & IV.pptADVANCED JAVA MODULE III & IV.ppt
ADVANCED JAVA MODULE III & IV.ppt
 
Cp7 rpc
Cp7 rpcCp7 rpc
Cp7 rpc
 
Rmi ppt-2003
Rmi ppt-2003Rmi ppt-2003
Rmi ppt-2003
 
The use of Symfony2 @ Overblog
The use of Symfony2 @ OverblogThe use of Symfony2 @ Overblog
The use of Symfony2 @ Overblog
 
Mike Taulty OData (NxtGen User Group UK)
Mike Taulty OData (NxtGen User Group UK)Mike Taulty OData (NxtGen User Group UK)
Mike Taulty OData (NxtGen User Group UK)
 
corba-151024114450-lva1-app6891.pptx
corba-151024114450-lva1-app6891.pptxcorba-151024114450-lva1-app6891.pptx
corba-151024114450-lva1-app6891.pptx
 
Remote Method Invocation (Java RMI)
Remote Method Invocation (Java RMI)Remote Method Invocation (Java RMI)
Remote Method Invocation (Java RMI)
 

More from vantinhkhuc (20)

Url programming
Url programmingUrl programming
Url programming
 
Servlets intro
Servlets introServlets intro
Servlets intro
 
Servlet sessions
Servlet sessionsServlet sessions
Servlet sessions
 
Security overview
Security overviewSecurity overview
Security overview
 
Md5
Md5Md5
Md5
 
Lecture17
Lecture17Lecture17
Lecture17
 
Lecture11 b
Lecture11 bLecture11 b
Lecture11 b
 
Lecture10
Lecture10Lecture10
Lecture10
 
Lecture9
Lecture9Lecture9
Lecture9
 
Lecture6
Lecture6Lecture6
Lecture6
 
Jsse
JsseJsse
Jsse
 
Jsf intro
Jsf introJsf intro
Jsf intro
 
Jsp examples
Jsp examplesJsp examples
Jsp examples
 
Jpa
JpaJpa
Jpa
 
Ejb examples
Ejb examplesEjb examples
Ejb examples
 
Ajax
AjaxAjax
Ajax
 
Ejb intro
Ejb introEjb intro
Ejb intro
 
Chc6b0c6a1ng 12
Chc6b0c6a1ng 12Chc6b0c6a1ng 12
Chc6b0c6a1ng 12
 
Ch06
Ch06Ch06
Ch06
 
Bai4
Bai4Bai4
Bai4
 

Corba

  • 1. Common Object Request Broker Architecture (CORBA) CORBA CORBA is similar in high level concepts to RMI RMI is basically a simplified form of CORBA Adds cross-platform, multiple language interfaces, more bells and whistles Widely used standard
  • 2. CORBA At the top level the architecture is similar to RMI Client Stub Object Request Broker (ORB) Skeleton Server ORB and IIOP The Internet Inter-ORB Protocol (IIOP) is a protocol by which ORBs communicate (Similar to JRMP in RMI)
  • 3. CORBA The Object Request Broker (ORB) is the “bus” that connects objects across the network. It’s a virtual bus; some network software that runs on each machine It locates the object on the network, communicates the message, and waits for results Not all ORBs are alike—there are some standardization moves around, but it’s not generally true that a client using one ORB can talk to a remote object using a different ORB Major vendors: Java 2 ORB, VisiBroker, WebSphere ORB, Iona (Orbix). CORBA Services CORBA has a standard, the IIOP, that (supposedly) allows you to communicate with CORBA objects running on another vendor’s ORB over TCP/IP The CORBA infrastructure also provides services for naming, transactions, object creation, etc. These are CORBA services implemented in CORBA.
  • 4. Stub & Skeleton Creation In RMI we had an RMI compiler run on the .class file we wanted to be remote. It’s different under CORBA The interface is written in Interface Definition Language, IDL. IDL is language-neutral (by being a different language than anything else) though highly reminiscent of C++ (multiple inheritance, similar syntax, etc.) IDL has a set of primitive data types similar to most languages—integer, float, string, byte, etc. CORBA Development Process 1. Write an IDL file which describes the interface to the distributed object. 2. Run idlj on the IDL file. This generates Java code that implements the stub and the skeleton 3. Run nameserver 4. Implement the servant (implement the IDL interface) 5. Implement the server (register the servant with the naming service and wait for requests) 6. Implement the client 7. Run the server 8. Run the client
  • 5. Interface Definition Language (IDL) Compile the IDL code with idlj. This creates java source code files in the Tracker package. Note the use of the IDL primitive type “string” idlj -fclient -fserver –oldImplBase Tracker.idl module Tracker { interface Time { string getTime(); }; }; Interface Definition Language (IDL) (Contd.) A pure description language. enables developers to describe an interface they wish to use remotely in a language-independent fashion. Language specific compiler required for each participating language (e.g., idlj for Java). creates files required by each language for CORBA related tasks.
  • 6. Idlj: IDL to Java Compile output Idlj generates some horror-story java code in the Tracker directory. _TimeStub (the stub for the client) Time (the interface for the distributed object) TimeHelper (Kitchen sink functionality) TimeHolder (Serialization & communications; out & inout parameters) TimeOperations (initial server implementation) _TimeImplBase (base class for servant) Start the nameserver CORBA uses a technique similar to that of the RMI registry. Servers register with the name server, and clients ask the name server where to find the server. orbd –ORBInitialPort <myPort> Example: orbd –ORBInitialPort 900 This is a replacement for the older tnsnameserver Note that myPort must match up with the properties used to find the name server in the client and server
  • 7. Client-side Code Very similar to RMI Get reference to remote object Cast it to what you want Call methods on the object via the local proxy object On the other hand, there are more annoyances due to CORBAs multi-language background Client.java: package ex1; import Tracker.*; // The package containing our stubs. import org.omg.CosNaming.*; // Client will use the naming service. import org.omg.CORBA.*; // All CORBA applications need these classes. public class Client { public static void main (String args[]) { 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 (objRef); // Resolve the object reference in naming NameComponent nc = new NameComponent ("TimeServer", ""); NameComponent path[] = {nc}; Time timeRef = TimeHelper.narrow (ncRef.resolve (path)); // Call the time server object and print results String time = "Time on the Server is " + timeRef.getTime (); System.out.println (time); } catch (Exception e) { e.printStackTrace (); } } }
  • 8. Server-side Code On the server-side, there is the “Server” code, and the “Servant” code. The servant code is the object implementation. The server code holds one or more servants. The servant Code package ex1; // The package containing our stubs. import Tracker.*; // Server will use the naming service. import org.omg.CosNaming.*; // The package containing special exceptions thrown by the name service. import org.omg.CosNaming.NamingContextPackage.*; // All CORBA applications need these classes. import org.omg.CORBA.*; import java.util.*; import java.text.*; class TimeServer extends _TimeImplBase { public String getTime () { SimpleDateFormat formatter = new SimpleDateFormat ("MMMMM dd, yyyyy GGG, hh:mm:ss:SSS aaa"); Date date = new Date (); return formatter.format ( date ); } }
  • 9. The Server Code The server code does the following: Creates a new Servant object Registers the Servant with the naming service Listens for incoming requests (Makes sure we don’t exit) package ex1; The Server Code // The package containing our stubs. import Tracker.*; // Server will use the naming service. import org.omg.CosNaming.*; // The package containing special exceptions thrown by the name service. import org.omg.CosNaming.NamingContextPackage.*; // All CORBA applications need these classes. import org.omg.CORBA.*; public class Server { public static void main (String args[]) { try { // Create and initialize the ORB ORB orb = ORB.init (args, null); // Create the servant and register it with the ORB TimeServer timeRef = new TimeServer (); orb.connect (timeRef); // Get the root naming context org.omg.CORBA.Object objRef = orb.resolve_initial_references ("NameService"); NamingContext ncRef = NamingContextHelper.narrow (objRef); // Bind the object reference in naming NameComponent nc = new NameComponent ("TimeServer", ""); NameComponent path[] = {nc}; ncRef.rebind (path, timeRef); // Wait forever for current thread to die Thread.currentThread ().join (); } catch (Exception e) { e.printStackTrace (); } } }
  • 10. Overview of Compilation Process Time.idl IDL Compiler _TimeStub _TimeImplBase Classes & interfaces Time server Time client application application Java compiler Client byte Server byte code code RMI In One Slide
  • 11. Service Interface -Implements Remote- (Written in Java) Service Implementation (Extends UnicastRemoteObject Implements Service Interface) rmic Generated Stub Generated Skeleton Client Server needs needs Client:: Server: •Lookup Service by name from rmiregistry •Create Service Instance •Use remote reference to access service •Register Service with rmiregistry bind lookup rmiregistry CORBA In One Slide
  • 12. Service Interface (written in IDL) idlj Generated Stub Generated Skeleton Service Generated needs Helper Class CORBA Service Extends Skeleton Client needs Client:: Server: •Create ORB •Create ORB •Lookup Service by name from naming service •Create Service Instance •Use remote reference to access service •Register Service with naming service orbd bind lookup -OR- tnameserv Reference CORBA, The MOVE Institute: Naval Postgraduate School.