コード例 #1
0
  public boolean processCommand(String[] cmdArgs, ORB orb, PrintStream out) {
    if ((cmdArgs.length == 2) && cmdArgs[0].equals("-applicationName")) {
      String str = (String) cmdArgs[1];

      try {
        Repository repository =
            RepositoryHelper.narrow(
                orb.resolve_initial_references(ORBConstants.SERVER_REPOSITORY_NAME));

        try {
          int result = repository.getServerID(str);
          out.println();
          out.println(
              CorbaResourceUtil.getText("servertool.getserverid2", str, Integer.toString(result)));
          out.println();
        } catch (ServerNotRegistered e) {
          out.println(CorbaResourceUtil.getText("servertool.nosuchserver"));
        }
      } catch (Exception ex) {
        ex.printStackTrace();
      }

      return commandDone;
    } else return parseError;
  }
コード例 #2
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;
  }
コード例 #3
0
  static int getServerIdForAlias(ORB orb, String applicationName) throws ServerNotRegistered {
    try {
      Repository rep =
          RepositoryHelper.narrow(
              orb.resolve_initial_references(ORBConstants.SERVER_REPOSITORY_NAME));
      int serverid = rep.getServerID(applicationName);

      return rep.getServerID(applicationName);
    } catch (Exception ex) {
      throw (new ServerNotRegistered());
    }
  }
コード例 #4
0
 public static synchronized org.omg.CORBA.TypeCode type() {
   if (__typeCode == null) {
     __typeCode =
         org.omg
             .CORBA
             .ORB
             .init()
             .create_interface_tc(
                 com.sun.corba.se.spi.activation.RepositoryHelper.id(), "Repository");
   }
   return __typeCode;
 }
コード例 #5
0
  public boolean processCommand(String[] cmdArgs, ORB orb, PrintStream out) {
    try {
      Repository repository =
          RepositoryHelper.narrow(
              orb.resolve_initial_references(ORBConstants.SERVER_REPOSITORY_NAME));

      String[] applicationNames = repository.getApplicationNames();

      out.println(CorbaResourceUtil.getText("servertool.listappnames2"));
      out.println();
      for (int i = 0; i < applicationNames.length; i++) out.println("\t" + applicationNames[i]);
    } catch (Exception ex) {
      ex.printStackTrace();
    }

    return commandDone;
  }
コード例 #6
0
  public boolean processCommand(String[] cmdArgs, ORB orb, PrintStream out) {
    int serverId = illegalServerId;

    try {
      if (cmdArgs.length == 2) {
        if (cmdArgs[0].equals("-serverid")) serverId = (Integer.valueOf(cmdArgs[1])).intValue();
        else if (cmdArgs[0].equals("-applicationName"))
          serverId = ServerTool.getServerIdForAlias(orb, cmdArgs[1]);
      }

      // the server id has to be specified
      if (serverId == illegalServerId) return parseError;

      // deactivate server, hold it down and and unregister it
      // deactivate the server
      try {
        Activator activator =
            ActivatorHelper.narrow(
                orb.resolve_initial_references(ORBConstants.SERVER_ACTIVATOR_NAME));
        activator.uninstall(serverId);
      } catch (ServerHeldDown ex) {
      }

      // unregister the server from the repository
      Repository repository =
          RepositoryHelper.narrow(
              orb.resolve_initial_references(ORBConstants.SERVER_REPOSITORY_NAME));
      repository.unregisterServer(serverId);

      // print success message
      out.println(CorbaResourceUtil.getText("servertool.unregister2"));
    } catch (ServerNotRegistered ex) {
      out.println(CorbaResourceUtil.getText("servertool.nosuchserver"));
    } catch (Exception ex) {
      ex.printStackTrace();
    }

    return commandDone;
  }
コード例 #7
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;
  }
コード例 #8
0
  public boolean processCommand(String[] cmdArgs, ORB orb, PrintStream out) {
    int i = 0;
    String applicationName = "";
    String name = "";
    String classpath = "";
    String args = "";
    String vmargs = "";
    int serverId = 0;

    // parse register server command
    String arg;
    while (i < cmdArgs.length) {

      arg = cmdArgs[i++];

      if (arg.equals("-server")) {
        if (i < cmdArgs.length) name = cmdArgs[i++];
        else return parseError;
      } else if (arg.equals("-applicationName")) {
        if (i < cmdArgs.length) applicationName = cmdArgs[i++];
        else return parseError;
      } else if (arg.equals("-classpath")) {
        if (i < cmdArgs.length) classpath = cmdArgs[i++];
        else return parseError;
      } else if (arg.equals("-args")) {
        while ((i < cmdArgs.length) && !cmdArgs[i].equals("-vmargs")) {
          args = args.equals("") ? cmdArgs[i] : args + " " + cmdArgs[i];
          i++;
        }
        if (args.equals("")) return parseError;
      } else if (arg.equals("-vmargs")) {
        while ((i < cmdArgs.length) && !cmdArgs[i].equals("-args")) {
          vmargs = vmargs.equals("") ? cmdArgs[i] : vmargs + " " + cmdArgs[i];
          i++;
        }
        if (vmargs.equals("")) return parseError;
      } else return parseError;
    }

    // minimally the server class name has to be specified
    if (name.equals("")) return parseError;

    // register server and activate it
    try {
      // register the server with the repository
      Repository repository =
          RepositoryHelper.narrow(
              orb.resolve_initial_references(ORBConstants.SERVER_REPOSITORY_NAME));

      ServerDef server = new ServerDef(applicationName, name, classpath, args, vmargs);
      serverId = repository.registerServer(server);

      // activate the server
      Activator activator =
          ActivatorHelper.narrow(
              orb.resolve_initial_references(ORBConstants.SERVER_ACTIVATOR_NAME));
      activator.activate(serverId);
      activator.install(serverId);

      // print success message
      out.println(CorbaResourceUtil.getText("servertool.register2", serverId));
    } catch (ServerNotRegistered ex) {
    } catch (ServerAlreadyActive ex) {
    } catch (ServerHeldDown ex) {
      out.println(CorbaResourceUtil.getText("servertool.register3", serverId));
    } catch (ServerAlreadyRegistered ex) {
      out.println(CorbaResourceUtil.getText("servertool.register4", serverId));
    } catch (BadServerDefinition ex) {
      out.println(CorbaResourceUtil.getText("servertool.baddef", ex.reason));
    } catch (Exception ex) {
      ex.printStackTrace();
    }

    return commandDone;
  }