Class RemoteCommand

java.lang.Object
com.sun.enterprise.admin.cli.CLICommand
com.sun.enterprise.admin.cli.remote.RemoteCommand
All Implemented Interfaces:
org.glassfish.hk2.api.PostConstruct

public class RemoteCommand extends CLICommand
A remote command handled by the asadmin CLI.
  • Constructor Details

    • RemoteCommand

      public RemoteCommand() throws org.glassfish.api.admin.CommandException
      Construct a new remote command object. The command and arguments are supplied later using the execute method in the superclass.
      Throws:
      org.glassfish.api.admin.CommandException
    • RemoteCommand

      public RemoteCommand(String name, ProgramOptions po, Environment env) throws org.glassfish.api.admin.CommandException
      Construct a new remote command object. The command and arguments are supplied later using the execute method in the superclass.
      Throws:
      org.glassfish.api.admin.CommandException
    • RemoteCommand

      public RemoteCommand(String name, ProgramOptions po, Environment env, String responseFormatType, OutputStream userOut) throws org.glassfish.api.admin.CommandException
      Construct a new remote command object. The command and arguments are supplied later using the execute method in the superclass. This variant is used by the RemoteDeploymentFacility class to control and capture the output.
      Throws:
      org.glassfish.api.admin.CommandException
  • Method Details

    • execute

      public int execute(String... argv) throws org.glassfish.api.admin.CommandException
      Description copied from class: CLICommand
      Execute this command with the given arguemnts. The implementation in this class saves the passed arguments in the argv field and calls the initializePasswords method. Then it calls the prepare, parse, and validate methods, finally returning the result of calling the executeCommand method. Note that argv[0] is the command name.
      Overrides:
      execute in class CLICommand
      Throws:
      org.glassfish.api.admin.CommandException - if execution of the command fails
      org.glassfish.api.admin.CommandValidationException - if there's something wrong with the options or arguments
    • setFileOutputDirectory

      public void setFileOutputDirectory(File dir)
      Set the directory in which any returned files will be stored. The default is the user's home directory.
    • prepare

      protected void prepare() throws org.glassfish.api.admin.CommandException, org.glassfish.api.admin.CommandValidationException
      Description copied from class: CLICommand
      The prepare method must ensure that the commandModel field is set.
      Overrides:
      prepare in class CLICommand
      Throws:
      org.glassfish.api.admin.CommandException
      org.glassfish.api.admin.CommandValidationException
    • prevalidate

      protected void prevalidate() throws org.glassfish.api.admin.CommandException
      Description copied from class: CLICommand
      The prevalidate method supplies missing options from the environment. It also supplies passwords from the password file or prompts for them if interactive.
      Overrides:
      prevalidate in class CLICommand
      Throws:
      org.glassfish.api.admin.CommandException - if execution of the command fails
      org.glassfish.api.admin.CommandValidationException - if there's something wrong with the options or arguments
    • validate

      protected void validate() throws org.glassfish.api.admin.CommandException, org.glassfish.api.admin.CommandValidationException
      If it's a help request, don't prompt for any missing options.
      Overrides:
      validate in class CLICommand
      Throws:
      org.glassfish.api.admin.CommandException - if execution of the command fails
      org.glassfish.api.admin.CommandValidationException - if there's something wrong with the options or arguments
    • inject

      protected void inject() throws org.glassfish.api.admin.CommandException
      Description copied from class: CLICommand
      Inject this instance with the final values of all the command parameters.
      Overrides:
      inject in class CLICommand
      Throws:
      org.glassfish.api.admin.CommandException - if execution of the command fails
      org.glassfish.api.admin.CommandValidationException - if there's something wrong with the options or arguments
    • checkHelp

      protected boolean checkHelp() throws org.glassfish.api.admin.CommandException, org.glassfish.api.admin.CommandValidationException
      We do all our help processing in executeCommand.
      Overrides:
      checkHelp in class CLICommand
      Throws:
      org.glassfish.api.admin.CommandException
      org.glassfish.api.admin.CommandValidationException
    • executeCommand

      protected int executeCommand() throws org.glassfish.api.admin.CommandException, org.glassfish.api.admin.CommandValidationException
      Runs the command using the specified arguments.
      Specified by:
      executeCommand in class CLICommand
      Returns:
      the exit code
      Throws:
      org.glassfish.api.admin.CommandException - if execution of the command fails
      org.glassfish.api.admin.CommandValidationException - if there's something wrong with the options or arguments
    • executeAndReturnOutput

      public String executeAndReturnOutput(String... args) throws org.glassfish.api.admin.CommandException, org.glassfish.api.admin.CommandValidationException
      Execute the command and return the output as a string instead of writing it out.
      Throws:
      org.glassfish.api.admin.CommandException
      org.glassfish.api.admin.CommandValidationException
    • executeAndReturnAttributes

      public Map<String,String> executeAndReturnAttributes(String... args) throws org.glassfish.api.admin.CommandException, org.glassfish.api.admin.CommandValidationException
      Execute the command and return the main attributes from the manifest instead of writing out the output.
      Throws:
      org.glassfish.api.admin.CommandException
      org.glassfish.api.admin.CommandValidationException
    • getUsage

      public String getUsage()
      Get the usage text. If we got usage information from the server, use it.
      Overrides:
      getUsage in class CLICommand
      Returns:
      usage text
    • getManPage

      public BufferedReader getManPage()
      Get the man page from the server. If the man page isn't available, e.g., because the server is down, try to find it locally by looking in the modules directory.
      Overrides:
      getManPage in class CLICommand