Example #1
0
  public boolean processCommand(String[] cmdArgs, ORB orb, PrintStream out) {
    int serverId = illegalServerId;
    boolean listOneServer = false;
    ServerDef serverDef;

    // determine if list single server or all servers
    listOneServer = (cmdArgs.length != 0);
    if ((cmdArgs.length == 2) && cmdArgs[0].equals("-serverid"))
      serverId = (Integer.valueOf(cmdArgs[1])).intValue();

    if ((serverId == illegalServerId) && listOneServer) return parseError;

    // process the list server command
    try {
      Repository repository =
          RepositoryHelper.narrow(
              orb.resolve_initial_references(ORBConstants.SERVER_REPOSITORY_NAME));

      if (listOneServer) {

        try {
          serverDef = repository.getServer(serverId);
          out.println();
          printServerDef(serverDef, serverId, out);
          out.println();
        } catch (ServerNotRegistered e) {
          out.println(CorbaResourceUtil.getText("servertool.nosuchserver"));
        }

      } else {
        int[] servers = repository.listRegisteredServers();
        out.println(CorbaResourceUtil.getText("servertool.list2"));

        sortServers(servers);
        for (int i = 0; i < servers.length; i++) {
          try {
            serverDef = repository.getServer(servers[i]);
            out.println(
                "\t   "
                    + servers[i]
                    + "\t\t"
                    + serverDef.serverName
                    + "\t\t"
                    + serverDef.applicationName);
          } catch (ServerNotRegistered e) {
          }
        }
      }
    } catch (Exception ex) {
      ex.printStackTrace();
    }

    return commandDone;
  }
Example #2
0
  public boolean processCommand(String[] cmdArgs, ORB orb, PrintStream out) {
    ServerDef serverDef;

    // process the list active servers command
    try {
      Repository repository =
          RepositoryHelper.narrow(
              orb.resolve_initial_references(ORBConstants.SERVER_REPOSITORY_NAME));

      Activator activator =
          ActivatorHelper.narrow(
              orb.resolve_initial_references(ORBConstants.SERVER_ACTIVATOR_NAME));

      int[] servers = activator.getActiveServers();

      out.println(CorbaResourceUtil.getText("servertool.list2"));

      ListServers.sortServers(servers);
      for (int i = 0; i < servers.length; i++) {
        try {
          serverDef = repository.getServer(servers[i]);
          out.println(
              "\t   "
                  + servers[i]
                  + "\t\t"
                  + serverDef.serverName
                  + "\t\t"
                  + serverDef.applicationName);
        } catch (ServerNotRegistered e) {
        }
      }
    } catch (Exception ex) {
      ex.printStackTrace();
    }

    return commandDone;
  }