文档介绍:×÷Õߣºasp2001
email: asp2001@
ÈÕÆÚ£º2000-8-12 9:38:37
Below is a simple example of a CORBA program
download the source file
produce a idl file like this
module HelloApp {
interface Hello {
string sayHello();
};
};
produce stub and skeleton files through
idltojava
idltojava is not include in the jdk. But you can download it from idldojava.
write a server program like this
//
import HelloApp.*;
..*;
..*;
..*;
import .*;
class HelloServant extends _HelloImplBase
{
public String sayHello()
{
return "\nHello world !!\n";
}
}
public class HelloServer {
public static void main(String args[])
{
try{
// create and initialize the ORB
ORB orb = (args, null);
// create servant and register it with the ORB
HelloServant helloRef = new HelloServant();
(helloRef);
// get the root naming context
objRef =
("NameService");
NamingContext ncRef = (objRef);
// bind the Object Reference in Naming
ponent nc = new ponent("Hello", "");
ponent path[] = {nc};
(path, helloRef);
// wait for invocations from clients
sync = new ();
synchronized (sync) {
();
}
} catch (Exception e) {