예제 #1
0
파일: Client.java 프로젝트: pedia/zeroc-ice
  @Override
  public int run(String[] args) {
    Ice.Communicator communicator = communicator();
    AllTests.allTests(communicator, getWriter());

    //
    // Shutdown the IceBox server.
    //
    Ice.ProcessPrxHelper.uncheckedCast(
            communicator.stringToProxy("DemoIceBox/admin -f Process:default -p 9996"))
        .shutdown();
    return 0;
  }
예제 #2
0
  private void setServerProcessProxy(Ice.ObjectAdapter adminAdapter, Ice.Identity adminIdentity) {
    Ice.ObjectPrx admin = adminAdapter.createProxy(adminIdentity);
    Ice.LocatorPrx locator = adminAdapter.getLocator();
    String serverId = _initData.properties.getProperty("Ice.Admin.ServerId");

    if (locator != null && !serverId.isEmpty()) {
      Ice.ProcessPrx process = Ice.ProcessPrxHelper.uncheckedCast(admin.ice_facet("Process"));
      try {
        //
        // Note that as soon as the process proxy is registered, the communicator might be
        // shutdown by a remote client and admin facets might start receiving calls.
        //
        locator.getRegistry().setServerProcessProxy(serverId, process);
      } catch (Ice.ServerNotFoundException ex) {
        if (_traceLevels.location >= 1) {
          StringBuilder s = new StringBuilder(128);
          s.append("couldn't register server `");
          s.append(serverId);
          s.append("' with the locator registry:\n");
          s.append("the server is not known to the locator registry");
          _initData.logger.trace(_traceLevels.locationCat, s.toString());
        }

        throw new Ice.InitializationException(
            "Locator knows nothing about server `" + serverId + "'");
      } catch (Ice.LocalException ex) {
        if (_traceLevels.location >= 1) {
          StringBuilder s = new StringBuilder(128);
          s.append("couldn't register server `");
          s.append(serverId);
          s.append("' with the locator registry:\n");
          s.append(ex.toString());
          _initData.logger.trace(_traceLevels.locationCat, s.toString());
        }
        throw ex;
      }

      if (_traceLevels.location >= 1) {
        StringBuilder s = new StringBuilder(128);
        s.append("registered server `");
        s.append(serverId);
        s.append("' with the locator registry");
        _initData.logger.trace(_traceLevels.locationCat, s.toString());
      }
    }
  }