ServerChat.java
资源名称:chat.zip [点击查看]
上传用户:annion2008
上传日期:2021-03-11
资源大小:38k
文件大小:1k
源码类别:
中间件编程
开发平台:
Java
- import chat.servidor.*;
- import org.omg.CosNaming.*;
- import org.omg.CosNaming.NamingContextPackage.*;
- import org.omg.CORBA.*;
- import org.omg.PortableServer.*;
- import org.omg.PortableServer.POA;
- import java.util.Properties;
- public class ServerChat
- {
- public static void main(String[] args) {
- try {
- /* configures and initializes ORB */
- Properties props = new Properties();
- props.put("org.omg.CORBA.ORBInitialPort", "6666");
- ORB orb = ORB.init(args, props);
- POA rootpoa = POAHelper.narrow(orb.resolve_initial_references("RootPOA"));
- rootpoa.the_POAManager().activate();
- ServerChatServant serverChat = new ServerChatServant();
- org.omg.CORBA.Object ref = rootpoa.servant_to_reference(serverChat);
- ChatService chatService = ChatServiceHelper.narrow(ref);
- org.omg.CORBA.Object objRef = orb.resolve_initial_references("NameService");
- NamingContextExt ncRef = NamingContextExtHelper.narrow(objRef);
- String name = "ChatService";
- NameComponent path[] = ncRef.to_name(name);
- ncRef.rebind(path, ref);
- System.out.println("ChatService early and waiting...");
- orb.run();
- } catch (Exception e) {
- System.err.println("Error: " + e.getMessage());
- e.printStackTrace();
- } //catch
- } //main
- } //class ServerChat