Class RemoteCLICommand
java.lang.Object
com.sun.enterprise.admin.cli.CLICommand
com.sun.enterprise.admin.cli.remote.RemoteCLICommand
- All Implemented Interfaces:
org.glassfish.hk2.api.PostConstruct
A remote command handled by the asadmin CLI.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected org.glassfish.api.admin.ParameterMapFields 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
ConstructorsConstructorDescriptionConstruct a new remote command object.RemoteCLICommand(String name, ProgramOptions po, Environment env) Construct a new remote command object.RemoteCLICommand(String name, ProgramOptions po, Environment env, String responseFormatType, OutputStream userOut) Construct a new remote command object. -
Method Summary
Modifier and TypeMethodDescriptionintExecute this command with the given arguemnts.org.glassfish.api.ActionReportexecuteAndReturnActionReport(String... args) Execute the command and return the main attributes from the manifest instead of writing out the output.executeAndReturnOutput(String... args) Execute the command and return the output as a string instead of writing it out.protected intRuns the command using the specified arguments.Get the man page from the server.getUsage()Get the usage text.protected voidinject()Inject this instance with the final values of all the command parameters.protected voidparse()The parse method sets the options and operands fields based on the content of the command line arguments.protected voidprepare()The prepare method must ensure that the commandModel field is set.protected voidThe prevalidate method supplies missing options from the environment.voidregisterListener(String regexpForName, org.glassfish.api.admin.AdminCommandEventBroker.AdminCommandListener listener) voidSet the directory in which any returned files will be stored.protected voidvalidate()If it's a help request, don't prompt for any missing options.Methods inherited from class com.sun.enterprise.admin.cli.CLICommand
checkHelp, expandManPage, getBooleanOption, getBriefCommandUsage, getCommand, getCommand, getCommandScope, getCommandUsage, getName, getOperandModel, getOption, getOptions, getPassword, getPassword, getProgramOptions, getSystemProperties, getSystemProperty, initializeLogger, initializePasswords, ok, postConstruct, printExceptionStackTrace, processProgramOptions, quote, readPassword, setCommandScope, toString, usageOptions
-
Field Details
-
reExecutedOptions
protected org.glassfish.api.admin.ParameterMap reExecutedOptions -
reExecutedOperands
-
-
Constructor Details
-
RemoteCLICommand
public RemoteCLICommand() throws org.glassfish.api.admin.CommandExceptionConstruct 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
-
RemoteCLICommand
public RemoteCLICommand(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
-
RemoteCLICommand
public RemoteCLICommand(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
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- Throws:
org.glassfish.api.admin.CommandException- if execution of the command failsorg.glassfish.api.admin.CommandValidationException- if there's something wrong with the options or arguments
-
setFileOutputDirectory
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.CommandValidationExceptionDescription copied from class:CLICommandThe prepare method must ensure that the commandModel field is set.- Overrides:
preparein classCLICommand- Throws:
org.glassfish.api.admin.CommandExceptionorg.glassfish.api.admin.CommandValidationException
-
prevalidate
protected void prevalidate() throws org.glassfish.api.admin.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:
org.glassfish.api.admin.CommandException- if execution of the command failsorg.glassfish.api.admin.CommandValidationException- if there's something wrong with the options or arguments
-
parse
protected void parse() throws org.glassfish.api.admin.CommandExceptionDescription copied from class:CLICommandThe parse method sets the options and operands fields based on the content of the command line arguments. If the program options say this is a help request, we set options and operands as if "--help" had been specified.- Overrides:
parsein classCLICommand- Throws:
org.glassfish.api.admin.CommandException- if execution of the command failsorg.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.CommandValidationExceptionIf it's a help request, don't prompt for any missing options.- Overrides:
validatein classCLICommand- Throws:
org.glassfish.api.admin.CommandException- if execution of the command failsorg.glassfish.api.admin.CommandValidationException- if there's something wrong with the options or arguments
-
inject
protected void inject() throws org.glassfish.api.admin.CommandExceptionDescription copied from class:CLICommandInject this instance with the final values of all the command parameters.- Overrides:
injectin classCLICommand- Throws:
org.glassfish.api.admin.CommandException- if execution of the command failsorg.glassfish.api.admin.CommandValidationException- if there's something wrong with the options or arguments
-
executeCommand
protected int executeCommand() throws org.glassfish.api.admin.CommandException, org.glassfish.api.admin.CommandValidationExceptionRuns the command using the specified arguments.- Specified by:
executeCommandin classCLICommand- Returns:
- the exit code
- Throws:
org.glassfish.api.admin.CommandException- if execution of the command failsorg.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.CommandExceptionorg.glassfish.api.admin.CommandValidationException
-
executeAndReturnActionReport
public org.glassfish.api.ActionReport executeAndReturnActionReport(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.CommandExceptionorg.glassfish.api.admin.CommandValidationException
-
getUsage
Get the usage text. If we got usage information from the server, use it.- Overrides:
getUsagein classCLICommand- Returns:
- usage text
-
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
-
registerListener
public void registerListener(String regexpForName, org.glassfish.api.admin.AdminCommandEventBroker.AdminCommandListener listener)
-