示例#1
0
  public static RjsConnection lookup(
      final Registry registry, final RemoteException registryException, final RMIAddress address)
      throws CoreException {
    if (address == null) {
      throw new NullPointerException();
    }

    final int[] clientVersion = AbstractRJComClient.version();
    clientVersion[2] = -1;
    final Server server;
    int[] version;
    try {
      if (registryException != null) {
        throw registryException;
      }
      server = (Server) registry.lookup(address.getName());
      version = server.getVersion();
    } catch (final NotBoundException e) {
      throw new CoreException(
          new Status(
              IStatus.ERROR,
              RConsoleCorePlugin.PLUGIN_ID,
              ICommonStatusConstants.LAUNCHING,
              "The specified R engine is not in the service registry (RMI).",
              e));
    } catch (final RemoteException e) {
      throw new CoreException(
          new Status(
              IStatus.ERROR,
              RConsoleCorePlugin.PLUGIN_ID,
              ICommonStatusConstants.LAUNCHING,
              NLS.bind(
                  "Cannot access the host/service registry (RMI) at ''{0}''.",
                  address.getRegistryAddress()),
              e));
    } catch (final ClassCastException e) {
      throw new CoreException(
          new Status(
              IStatus.ERROR,
              RConsoleCorePlugin.PLUGIN_ID,
              ICommonStatusConstants.LAUNCHING,
              NLS.bind(
                  "The specified R engine ({0}) is incompatibel to this client ({1}).",
                  RjsUtil.getVersionString(null), RjsUtil.getVersionString(clientVersion)),
              e));
    }
    if (version.length != 3 || version[0] != clientVersion[0] || version[1] != clientVersion[1]) {
      throw new CoreException(
          new Status(
              IStatus.ERROR,
              RConsoleCorePlugin.PLUGIN_ID,
              ICommonStatusConstants.LAUNCHING,
              NLS.bind(
                  "The specified R engine ({0}) is incompatibel to this client ({1}).",
                  RjsUtil.getVersionString(version), RjsUtil.getVersionString(clientVersion)),
              null));
    }
    return new RjsConnection(address, server);
  }