1 | public class HelloServer { |
2 | public static void main(String args[]) { |
3 | try{ |
4 | // create and initialize the ORB |
5 | ORB orb = ORB.init(args, null); |
6 | // create servant and register it with the ORB |
7 | HelloServant HelloRef = new HelloServant(); orb.connect(HelloRef); |
8 | // get the root naming context |
9 | org.omg.CORBA.Object objRef = |
10 | orb.resolve_initial_references("NameService"); |
11 | NamingContext ncRef = NamingContextHelper.narrow(objRef); |
12 | // bind the Object Reference in Naming |
13 | NameComponent nc = new NameComponent("Hello", ""); |
14 | NameComponent path[] = {nc}; ncRef.rebind(path, HelloRef); |
15 | // wait for invocations from clients |
16 | java.lang.Object sync = new java.lang.Object(); |
17 | synchronized (sync) { |
18 | sync.wait(); |
19 | } |
20 | . . . // catch exceptions |
21 | } |