About corba server-side two-line statement do not understand, please help explain, thank you!

Category: Java SE
 
pzt2004
2013-08-20 05:48:27

Sponsored Links
/ / Complete the following procedure

package helloApp;

/ ** @ author javamxj (CSDN Blog) Date Created 2004 -12-27 * /

import org.omg.CosNaming. *;
import org.omg.CORBA. *;

/ *
server class contains the server's main () method, you can accomplish the following tasks:
create an ORB instance
HelloImpl create an instance (CORBA Hello object implementations) and Get a notification ORB
CORBA object reference naming context in which to register the new CORBA naming context in the naming context object
new object will be registered in the "Hello "Waiting for the new object name
call
* /

public class HelloServer {
public static void main (String args []) {
try {
/ * create and initialize the ORB * /
ORB orb = ORB.init (args, null);
System.out.println ("Start ORB Server ...");

/ * create an instance and its registration to the ORB * /
HelloImpl helloImpl = new HelloImpl ();
orb.connect (helloImpl);
System.out.println (" ; the instance to register ORB ");

/ * Get the root naming context * /
org.omg.CORBA.Object objRef = orb
. resolve_initial_references ("NameService");
NamingContext ncRef = NamingContextHelper.narrow (objRef);

/ * bind naming object reference * /
/ / NameComponent equivalent of a Map with names and values, Hello is an object, the index value of 123 is that it
NameComponent nc = new NameComponent ("Hello", "123");
NameComponent path [] = {nc};

/ / The NameComponent this Map ("Hello", "123") objects and instances helloImpl binding
ncRef.rebind (path, helloImpl);

/ * wait for a call from the client * /
java.lang.Object sync = new java.lang. Object ();
synchronized (sync) {
sync.wait ();
}
System.out.println ("Waiting CORBA client calls .. . ");
} catch (Exception e) {
System.err.println (" Error: "+ e);
e.printStackTrace (System.out);
}
}
}

/ / Will this statement role

/ * Wait for a call from the client * /
java.lang.Object sync = new java.lang.Object ();
synchronized (sync) {
sync.wait ();
}

/ / Why should I create an object, but did not see any place to use it that way.

Sponsored Links

Domain and server ip had changed since 8/23/2013. Suspend the user registration and posts for program maintenance.