Giter Club home page Giter Club logo

corba-example's Introduction

CORBA-Example

A simple CORBA implementation using Java

Instructions

1. Write the IDL file

The IDL file defines the interface that will be used by the client and server for communicating and passing objects.
When the IDL file gets compiled, it will produce a number of files, known as the stub and skeleton:

  • The stub is used by the client to communicate with the server
  • The skeleton is used by the server to communicate with the client
  • The stub and skeleton communicate with the ORB server to facilitate the remote procedure call

The module in the IDL file will correspond to the package and directory in which the Java code will be generated

Echo.idl

module EchoApp {
    interface Echo {
        string echoString();
    };
};

2. Generate the stub and skeleton code

There is an idlj program that comes with the JDK for generating the stub and skeleton code in Java

idlj –fall sum.idl

The following files are generated by the idlj program:

  • _EchoStub.java
  • Echo.java
  • EchoHelper.java
  • EchoHolder.java
  • EchoOperations.java
  • EchoPOA.java

3. Write the server code

The server program will inherit from the EchoPOA class that was generated as part of the idlj program.
The EchoPOA class implements the EchoOperations interface

  • This interface contains the methods we defined in the Echo.idl file, but standardized to Java.

We create an EchoServer.java class that extends the abstract EchoPoa class and then implement the methods contained in it

We create a main method in Server.java to communicate with the object request broker (ORB), registering the server with the ORB so clients are able to find it.

4. Write the client code

The client program Client.java needs to get a reference to the ORB then resolve the name of the server object it would like to invoke.

  • This is ECHO-SERVER in this case

After getting an instance of a Server object from the server, it can invoke methods on it just like a method within its own JVM.

5. Compile the code

  1. Compile the stub and skeleton from the directory that contains the IDL file.

    Windows

    javac EchoApp\*.java

    Linux

    javac EchoApp/*.java
  2. Generate a JAR file from the compiled stub and skeleton.

    Windows

    jar cvf echoapp.jar EchoApp\*.class

    Linux

    jar cvf echoapp.jar EchoApp/*.class
  3. Compile the server and client classes

    Windows

    javac -classpath .;echoapp.jar Server.java EchoServer.java Client.java

    Linux

    javac -classpath .:echoapp.jar Server.java EchoServer.java Client.java

6. Running the application

  1. Start the ORB server

    orbd -ORBInitialPort 1050 -ORBInitialHost localhost
  2. Start the server application

    java Server -ORBInitialPort 1050 -ORBInitialHost localhost
  3. Start the client application

    java Client -ORBInitialPort 1050 -ORBInitialHost localhost

If everything was compiled correctly the output should be:

Hello World!!!!!!!

corba-example's People

Contributors

johnngugi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.