Skip to content

johnngugi/CORBA-Example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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!!!!!!!

About

A simple CORBA implementation using Java

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages