繁体   English   中英

处理Java RMI连接拒绝主机异常

[英]handeling java RMI connection refused to host exception

如果服务器未启动,我想向用户显示错误消息。 当用户正在启动程序时。 下面我提到了ServerConnector单例类,该类用于连接整个应用程序的服务器。

public class ServerConnector {



private static ServerConnector serverConnector;
    private RemoteFactory remoteFactory;

    private ServerConnector() throws NotBoundException, MalformedURLException,
            RemoteException {
        remoteFactory = (RemoteFactory) Naming
                .lookup("rmi://localhost:5050/RoomReservation");
    }

    public static ServerConnector getServerConnector()
            throws NotBoundException, MalformedURLException, RemoteException {
        if (serverConnector == null) {
            serverConnector = new ServerConnector();
        }
        return serverConnector;
    }

    public CustomerController getCustomerController() throws RemoteException {
        return remoteFactory.getCustomerController();
    }


}

在加载程序的GUI之前,有什么方法可以检查服务器是否已启动?

谢谢。

  • 捕获java.rmi.ConnectException 这意味着注册表尚未启动。

  • 捕获NotBoundException 这意味着服务器尚未绑定到注册表。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM