package initialRefs;
import util.Util;
import helloWorld2.Hello;
import helloWorld2.HelloImpl;
import org.omg.CORBA.ORB;
import org.omg.CORBA.Object;
import org.omg.CosNaming.NameComponent;
import org.omg.CosNaming.NamingContext;
import org.omg.CosNaming.NamingContextHelper;
import javax.rmi.PortableRemoteObject;
import com.sssw.jbroker.api.bootstrap.InitialReferences;
import com.sssw.jbroker.api.bootstrap.InitialReferencesService;
public class Server
{
public static void main(String[] args)
{
| InitialReferences initialRefs;
| InitialReferencesService insService;
|
| try {
| |
| | // create the jBroker ORB
| | ORB orb = ORB.init(args, null);
| |
| | // create a servant
| | Hello hello = new HelloImpl();
| |
| | // get the initial references object
| | insService = (InitialReferencesService) orb.
| | resolve_initial_references("InitialReferencesService");
| | initialRefs = insService.getInitialReferences("localhost", 2506);
| |
| | // get the root of the NameService
| | NamingContext root = NamingContextHelper.narrow(
| | initialRefs.get("NameService"));
| |
| | // publish the hello object reference
| | NameComponent nc = new NameComponent("hello", "");
| | NameComponent[] name = new NameComponent[] { nc };
| | root.rebind(name, (Object) PortableRemoteObject.toStub(hello));
| |
| | // wait for invocations
| | System.out.println("waiting for invocations ...");
| | orb.run();
| |
| } catch (Exception ex) {
| | ex.printStackTrace();
| }
}
}