📄 cityweatherreportserver_factory.java
字号:
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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -