⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 showserver.java

📁 java 结合corba 实现事件推送
💻 JAVA
字号:
package org;

import java.util.Properties;
import org.omg.CORBA.ORB;
import org.omg.CosNaming.NameComponent;
import org.omg.CosNaming.NamingContextExt;
import org.omg.CosNaming.NamingContextExtHelper;
import org.omg.PortableServer.POA;
import org.omg.PortableServer.POAHelper;
import calculator.Show;
import calculator.ShowImpl;
import calculator.ShowPOATie;

public class ShowServer {

	public static void main(String args[]) {
		try {

			Properties props = new Properties();
			
	        props.put("org.omg.CORBA.ORBInitialPort", "8080");
	        props.put("org.omg.CORBA.ORBInitialHost", "localhost");
			
			ORB orb = ORB.init(args, props);

			POA rootpoa = POAHelper.narrow(orb
					.resolve_initial_references("RootPOA"));
			rootpoa.the_POAManager().activate();

			ShowImpl showImpl = new ShowImpl();

			ShowPOATie tie = new ShowPOATie(showImpl, rootpoa);

			Show href = tie._this(orb);

			org.omg.CORBA.Object objRef = orb
					.resolve_initial_references("NameService");

			NamingContextExt ncRef = NamingContextExtHelper.narrow(objRef);

			String name = "Show";
			NameComponent path[] = ncRef.to_name(name);
			ncRef.rebind(path, href);

			System.out.println("HelloServer ready and waiting ...");

			orb.run();
		}

		catch (Exception e) {
			System.err.println("ERROR: " + e);
			e.printStackTrace(System.out);
		}

		System.out.println("HelloServer Exiting ...");

	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -