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

📄 accountserver.java

📁 corba的java的快速开发实例
💻 JAVA
字号:
package com.hcycom.corba.example.bank;

import org.omg.CORBA.*;
import org.omg.CosNaming.*;
import org.omg.PortableServer.*;
import org.omg.PortableServer.POA;
import org.omg.CosNaming.NamingContextPackage.*;

public class AccountServer {

	public static void main(String args[]) {
		try{
		  // create and initialize the ORB
		  ORB orb = ORB.init(args, null);

		  // create an implementation and register it with the ORB
		  AccountImpl impl = new AccountImpl(orb);

		  // get reference to rootpoa & activate the POAManager
		  POA rootpoa = POAHelper.narrow(
			orb.resolve_initial_references("RootPOA"));
		  rootpoa.the_POAManager().activate();

		  // get object reference from the servant
		  org.omg.CORBA.Object ref = 
			rootpoa.servant_to_reference(impl);
		  Account href = AccountHelper.narrow(ref);
		  
		  // get the root naming context
		  // NameService invokes the name service
		  org.omg.CORBA.Object objRef = 
			orb.resolve_initial_references("NameService");
		  // Use NamingContextExt which is part of the Interoperable
		  // Naming Service (INS) specification.
		  NamingContextExt ncRef = 
			NamingContextExtHelper.narrow(objRef);

		  // bind the Object Reference in Naming
		  String name = "Account";
		  NameComponent path[] = ncRef.to_name( name );
		  ncRef.rebind(path, href);

		  System.out.println(
			  "AccountServer ready to serve your request ....");

		  // wait for invocations from clients
		  orb.run();
		} catch (Exception e) {
			System.err.println("ERROR: " + e);
			e.printStackTrace(System.out);
		}
		System.out.println("AccountServer Exiting ....");
	}
}

⌨️ 快捷键说明

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