com.sun.enterprise.admin.cli.remote
Class RemoteCommand

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

public class RemoteCommand
extends CLICommand

A remote command handled by the asadmin CLI.


Field Summary
 
Fields inherited from class com.sun.enterprise.admin.cli.CLICommand
argv, commandModel, CONNECTION_ERROR, env, ERROR, INVALID_COMMAND_ERROR, logger, metadataErrors, name, operands, options, passwords, programOpts, SUCCESS, WARNING
 
Constructor Summary
RemoteCommand()
          Construct a new remote command object.
RemoteCommand(String name, ProgramOptions po, Environment env)
          Construct a new remote command object.
RemoteCommand(String name, ProgramOptions po, Environment env, String responseFormatType, OutputStream userOut)
          Construct a new remote command object.
 
Method Summary
protected  boolean checkHelp()
          We do all our help processing in executeCommand.
 Map<String,String> executeAndReturnAttributes(String... args)
          Execute the command and return the main attributes from the manifest instead of writing out the output.
 String executeAndReturnOutput(String... args)
          Execute the command and return the output as a string instead of writing it out.
protected  int executeCommand()
          Runs the command using the specified arguments.
 BufferedReader getManPage()
          Get the man page from the server.
 String getUsage()
          Get the usage text.
protected  void prepare()
          The prepare method must ensure that the commandModel field is set.
 void setFileOutputDirectory(File dir)
          Set the directory in which any returned files will be stored.
protected  void validate()
          If it's a help request, don't prompt for any missing options.
 
Methods inherited from class com.sun.enterprise.admin.cli.CLICommand
execute, getBooleanOption, getBriefCommandUsage, getCommand, getCommandUsage, getName, getOperandModel, getOption, getPassword, getProgramOptions, getSystemProperties, getSystemProperty, initializeLogger, initializePasswords, inject, ok, parse, postConstruct, prevalidate, printExceptionStackTrace, processProgramOptions, quote, readPassword, toString, usageOptions
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RemoteCommand

public RemoteCommand()
              throws CommandException
Construct a new remote command object. The command and arguments are supplied later using the execute method in the superclass.

Throws:
CommandException

RemoteCommand

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

Throws:
CommandException

RemoteCommand

public RemoteCommand(String name,
                     ProgramOptions po,
                     Environment env,
                     String responseFormatType,
                     OutputStream userOut)
              throws 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:
CommandException
Method Detail

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 CommandException,
                       CommandValidationException
Description copied from class: CLICommand
The prepare method must ensure that the commandModel field is set.

Overrides:
prepare in class CLICommand
Throws:
CommandException
CommandValidationException

validate

protected void validate()
                 throws CommandException,
                        CommandValidationException
If it's a help request, don't prompt for any missing options.

Overrides:
validate in class CLICommand
Throws:
CommandException - if execution of the command fails
CommandValidationException - if there's something wrong with the options or arguments

checkHelp

protected boolean checkHelp()
                     throws CommandException,
                            CommandValidationException
We do all our help processing in executeCommand.

Overrides:
checkHelp in class CLICommand
Throws:
CommandException
CommandValidationException

executeCommand

protected int executeCommand()
                      throws CommandException,
                             CommandValidationException
Runs the command using the specified arguments.

Specified by:
executeCommand in class CLICommand
Returns:
the exit code
Throws:
CommandException - if execution of the command fails
CommandValidationException - if there's something wrong with the options or arguments

executeAndReturnOutput

public String executeAndReturnOutput(String... args)
                              throws CommandException,
                                     CommandValidationException
Execute the command and return the output as a string instead of writing it out.

Throws:
CommandException
CommandValidationException

executeAndReturnAttributes

public Map<String,String> executeAndReturnAttributes(String... args)
                                              throws CommandException,
                                                     CommandValidationException
Execute the command and return the main attributes from the manifest instead of writing out the output.

Throws:
CommandException
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


Copyright © 2012. All Rights Reserved.