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.
-
-
Field Summary
-
Fields inherited from class com.sun.enterprise.admin.cli.CLICommand
argv, ASADMIN, commandModel, CONNECTION_ERROR, env, ERROR, INVALID_COMMAND_ERROR, lineReader, logger, metadataErrors, name, operands, options, passwords, programOpts, SUCCESS, terminal, WARNING
-
-
Constructor Summary
Constructors Constructor Description 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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected booleancheckHelp()We do all our help processing in executeCommand.intexecute(String... argv)Execute this command with the given arguemnts.Map<String,String>executeAndReturnAttributes(String... args)Execute the command and return the main attributes from the manifest instead of writing out the output.StringexecuteAndReturnOutput(String... args)Execute the command and return the output as a string instead of writing it out.protected intexecuteCommand()Execute the command using the options in options and the operands in operands.BufferedReadergetManPage()Get the man page from the server.StringgetUsage()Get the usage text.protected voidinject()Inject this instance with the final values of all the command parameters.protected voidprepare()The prepare method must ensure that the commandModel field is set.protected voidprevalidate()The prevalidate method supplies missing options from the environment.voidsetFileOutputDirectory(File dir)Set the directory in which any returned files will be stored.protected voidvalidate()The validate method can be used by a subclass to validate that the type and quantity of parameters and operands matches the requirements for this command.-
Methods inherited from class com.sun.enterprise.admin.cli.CLICommand
buildLineReader, buildTerminal, closeTerminal, execute, expandManPage, getBooleanOption, getBriefCommandUsage, getCommand, getCommand, getCommandScope, getCommandUsage, getName, getOperandModel, getOption, getOptions, getPassword, getPassword, getProgramOptions, getSystemProperties, getSystemProperty, initializeLogger, initializePasswords, newLineReaderBuilder, ok, parse, postConstruct, printExceptionStackTrace, processProgramOptions, quote, readPassword, setCommandScope, toString, usageOptions
-
-
-
-
Constructor Detail
-
RemoteCommand
public RemoteCommand() throws CommandExceptionConstruct 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.- Parameters:
name-po-env-- Throws:
CommandException- See Also:
RemoteCLICommand(String, ProgramOptions, Environment)
-
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.- Parameters:
name-po-env-responseFormatType-userOut-- Throws:
CommandException- See Also:
RemoteCLICommand(String, ProgramOptions, Environment, String, OutputStream)
-
-
Method Detail
-
execute
public int execute(String... argv) throws CommandException
Description copied from class:CLICommandExecute 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:
executein classCLICommand- Parameters:
argv- Arguments to execute command with- Returns:
- exit code of the command
- Throws:
CommandException- if execution of the command failsCommandValidationException- 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.- Parameters:
dir-
-
prepare
protected void prepare() throws CommandException, CommandValidationExceptionDescription copied from class:CLICommandThe prepare method must ensure that the commandModel field is set.- Overrides:
preparein classCLICommand- Throws:
CommandExceptionCommandValidationException
-
prevalidate
protected void prevalidate() throws CommandExceptionDescription copied from class:CLICommandThe prevalidate method supplies missing options from the environment. It also supplies passwords from the password file or prompts for them if interactive.- Overrides:
prevalidatein classCLICommand- Throws:
CommandException- if execution of the command failsCommandValidationException- if there's something wrong with the options or arguments
-
validate
protected void validate() throws CommandException, CommandValidationExceptionDescription copied from class:CLICommandThe validate method can be used by a subclass to validate that the type and quantity of parameters and operands matches the requirements for this command.- Overrides:
validatein classCLICommand- Throws:
CommandException- if execution of the command failsCommandValidationException- if there's something wrong with the options or arguments
-
inject
protected void inject() throws CommandExceptionDescription copied from class:CLICommandInject this instance with the final values of all the command parameters.- Overrides:
injectin classCLICommand- Throws:
CommandException- if execution of the command failsCommandValidationException- if there's something wrong with the options or arguments
-
checkHelp
protected boolean checkHelp() throws CommandException, CommandValidationExceptionWe do all our help processing in executeCommand.- Overrides:
checkHelpin classCLICommand- Returns:
- Throws:
CommandExceptionCommandValidationException
-
executeCommand
protected int executeCommand() throws CommandException, CommandValidationExceptionDescription copied from class:CLICommandExecute the command using the options in options and the operands in operands.- Specified by:
executeCommandin classCLICommand- Returns:
- the exit code
- Throws:
CommandException- if execution of the command failsCommandValidationException- 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.- Parameters:
args-- Returns:
- Throws:
CommandValidationExceptionCommandException
-
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.- Parameters:
args-- Returns:
- Throws:
CommandExceptionCommandValidationException
-
getUsage
public String getUsage()
Get the usage text. If we got usage information from the server, use it.- Overrides:
getUsagein classCLICommand- 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:
getManPagein classCLICommand- Returns:
-
-