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

📄 libraryserver.java

📁 简化的图书查询系统,服务器端和客户端都有。采用CORBA实现.
💻 JAVA
字号:
// A server for the Hello object

import LibraryApp.*;
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 LibraryServer {

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

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

      // create servant and register it with the ORB
      LibraryImpl libraryImpl = new LibraryImpl();
      libraryImpl.setORB(orb); 

      // get object reference from the servant
      org.omg.CORBA.Object ref = 
        rootpoa.servant_to_reference(libraryImpl);
      // and cast the reference to a CORBA reference
      Library href = LibraryHelper.narrow(ref);
	  
      // get the root naming context
      // NameService invokes the transient 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 = "Library";
      NameComponent path[] = ncRef.to_name( name );
      ncRef.rebind(path, href);

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

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

⌨️ 快捷键说明

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