Skip to content
A simple CORBA implementation using Java
Java
Branch: master
Clone or download
Latest commit d87b142 Jun 29, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src Remove EchoApp files Jun 29, 2018
.gitignore Add new rule Jun 29, 2018
LICENSE Add license Jun 7, 2018
README.md Minor change Jun 29, 2018

README.md

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!!!!!!!
You can’t perform that action at this time.