cityweatherreportserver_factory.java

来自「java EJB 编程源代码。」· Java 代码 · 共 42 行

JAVA
42
字号
import java.rmi.*;
import java.rmi.server.*;

public class cityWeatherReportServer_Factory extends UnicastRemoteObject implements cityWeatherReport_Factory
  {
   /* 实现cityWeatherReport_Factory接口 */

   public cityWeatherReportServer_Factory() throws RemoteException
     {
      /* 构造cityWeatherServer_Factory对象 */
      super();
     }

   public cityWeatherReportServer getcityWeatherReport(String cityName) throws RemoteException
     {
      /* 重载getcityWeatherReport()方法(函数) */
      cityWeatherReportServer cityweatherserver = new cityWeatherReportServer(cityName);
      return cityweatherserver;
     }

   public static void main(String[] args)
     {
      String RemoteSerHost = null;

      try
        {

         RemoteSerHost = "//127.0.0.1/cityWeatherReport_Factory";
         System.setSecurityManager(new RMISecurityManager()); // 创建RMI安全管理器实例

         /* 创建远程对象实例 */
         cityWeatherReportServer_Factory cws_factory = new cityWeatherReportServer_Factory();
         Naming.rebind(RemoteSerHost,cws_factory);
         System.out.println("\nWeatherReport Server已经启动...\n");  
        }
      catch(Exception e)
        {
         System.out.println("!服务器启动时抛出例外:" + e.toString());
        }
     }
  }

⌨️ 快捷键说明

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