CORBA wrapper for easier development
corbawrapper is a Java project.
CORBA is an architecture designed by OMG to facilitate the communication of systems that are deployed on diverse platforms, but there is 2 repulsives facts to choose this technology :
- The chosen port can be blocked by firewalls, so people prefer to use webservices like REST which use HTTP protocol.
- The syntax is hard to understand.
In spite of those disadvantages, CORBA use interoperable components, and its IIOP protocol is stream based. I cannot configure your firewalls for CORBA, but I can create a wrapper in order to use CORBA easily.
Generate your IDL with : >idlj -fall Hello.idl
module HelloApp {
interface Hello {
string sayHello();
oneway void shutdown();
};
};
Thanks to your IDL contract file and the ildj command line you will generate several java files : Hello.java, HelloHelper.java, HelloHolder.java, HelloOperations.java, HelloPOA.java, _HelloStub.java.
Please see Sun/Oracle documentation for more information about generated files.
Now create your Hello implementation class
public class HelloImpl extends HelloPOA{
@Override
public String sayHello() {
return "Hello";
}
@Override
public void shutdown() {
// TODO Auto-generated method stub
}
}
import fr.ekinci.corbawrapper.CorbaServer;
import HelloApp.HelloHelper;
import HelloApp.HelloImpl;
public class CorbaServerDemo {
public static void main(String args[]) throws Exception {
CorbaServer server = new CorbaServer("127.0.0.1", 1050);
server.addService("Hello", new HelloImpl(), HelloHelper.class);
server.run();
}
}
import fr.ekinci.corbawrapper.CorbaClient;
import HelloApp.Hello;
import HelloApp.HelloHelper;
public class CorbaClientDemo {
public static void main(String args[]) throws Exception {
CorbaClient client = new CorbaClient("127.0.0.1", 1050);
Hello hello = client.<Hello, HelloHelper>lookup("Hello", HelloHelper.class);
System.out.println(hello.sayHello());
}
}
First launch your ORDB (server-side command):
- For Linux : orbd -ORBInitialPort 1050 -ORBInitialHost localhost&
- For Windows : start orbd -ORBInitialPort 1050 -ORBInitialHost localhost
Note about ORBD:
- If you are under Linux, you may encounter a problem when you are using RMI or CORBA protocols on the server side, in order to resolve this problem, change your /etc/hosts file localhost IP (127.0.0.1) with the real one.
- If you are under Linux and if your ORBD is already running, for stoping process you may see its PID with "ps aux" command, then kill its PID.
To learn more about CORBA :