public class CommandExecutor.TimeoutCommandContext extends Object implements CommandContext
CommandContext.Scope, CommandContext.TIMEOUT_RESET_VALUE| Modifier and Type | Method and Description |
|---|---|
void |
addEventListener(CliEventListener listener)
Adds a listener for CLI events.
|
void |
bindClient(ModelControllerClient newClient)
Bind the controller to an existing, connected client.
|
org.jboss.dmr.ModelNode |
buildRequest(String line)
Builds a DMR request corresponding to the command or the operation.
|
void |
captureOutput(PrintStream captor)
Redirect output to the given print stream.
|
void |
clear(CommandContext.Scope scope)
Clear the content of a scope.
|
void |
clearScreen()
Clears the screen.
|
void |
connectController()
Connects the controller client using the default controller definition.
|
void |
connectController(String controller)
Connects to the controller specified.
|
void |
connectController(String host,
int port)
Connects the controller client using the host and the port.
|
void |
connectController(String controller,
String client)
Connects to the controller specified.
|
void |
disconnectController()
Closes the previously established connection with the controller client.
|
org.jboss.dmr.ModelNode |
execute(org.jboss.dmr.ModelNode mn,
String description)
Execute an operation.
|
org.jboss.dmr.ModelNode |
execute(Operation op,
String description)
Execute an operation.
|
Object |
get(CommandContext.Scope scope,
String key)
Returns the value the key was associated with using the set(key, value) method above.
|
String |
getArgumentsString()
Returns the current command's arguments as a string.
|
BatchManager |
getBatchManager()
Returns batch manager.
|
CommandLineParser |
getCommandLineParser()
Returns the current operation request parser.
|
int |
getCommandTimeout()
Returns the command execution timeout value.
|
CliConfig |
getConfig()
Returns the JBoss CLI configuration.
|
ConnectionInfo |
getConnectionInfo()
The ConnectionInfo bean is set after the connection is established to the server.
|
String |
getControllerHost()
Returns the host the controller client is connected to or
null if the connection hasn't been established yet.
|
int |
getControllerPort()
Returns the port the controller client is connected to.
|
File |
getCurrentDir()
Returns current default filesystem directory.
|
OperationRequestAddress |
getCurrentNodePath()
Returns the current prefix.
|
CommandLineCompleter |
getDefaultCommandCompleter()
Returns the default command line completer.
|
ControllerAddress |
getDefaultControllerAddress()
The default address of the default controller to connect to.
|
String |
getDefaultControllerHost()
Returns the default host the controller client will be connected to.
|
int |
getDefaultControllerPort()
Returns the default port the controller client will be connected to.
|
int |
getExitCode()
Returns value that should be used as the exit code of the JVM process.
|
CommandHistory |
getHistory()
Returns the history of all the commands and operations.
|
Future<?> |
getLastTask() |
ModelControllerClient |
getModelControllerClient()
Returns the model controller client or null if it hasn't been initialized.
|
NodePathFormatter |
getNodePathFormatter()
Returns the prefix formatter.
|
OperationCandidatesProvider |
getOperationCandidatesProvider()
Returns the provider of operation request candidates for tab-completion.
|
ParsedCommandLine |
getParsedCommandLine()
Parsed command line arguments.
|
int |
getTerminalHeight()
Returns the current terminal window height in case the console
has been initialized.
|
int |
getTerminalWidth()
Returns the current terminal window width in case the console
has been initialized.
|
String |
getVariable(String name)
Returns the value for the variable.
|
Collection<String> |
getVariables()
Returns a collection of all the defined variable names.
|
void |
handle(String line)
Executes a command or an operation.
|
void |
handleSafe(String line)
Executes a command or an operation.
|
void |
interact()
This method will start an interactive session.
|
boolean |
isBatchMode()
Checks whether the CLI is in the batch mode.
|
boolean |
isDomainMode()
Indicates whether the CLI is in the domain mode or standalone one (assuming established
connection to the controller).
|
boolean |
isResolveParameterValues()
Command argument or operation parameter values may contain system properties.
|
boolean |
isSilent()
Whether the info or error messages should be written to the terminal output.
|
boolean |
isTerminated()
Checks whether the session has been terminated.
|
boolean |
isWorkflowMode()
Checks whether the CLI is in a workflow mode.
|
void |
printColumns(Collection<String> col)
Prints a collection of strings as columns to the CLI's output.
|
void |
printLine(String message)
Prints a string to the CLI's output.
|
void |
registerRedirection(CommandLineRedirection redirection)
After this method returns command line handling will be redirected to
the passed in CommandLineRedirection instance.
|
void |
releaseOutput()
Stops redirecting output to the stream passed to
CommandContext.captureOutput(java.io.PrintStream). |
Object |
remove(CommandContext.Scope scope,
String key)
Removes the value the key was associated with using the set(key, value) method above.
|
void |
resetTimeout(CommandContext.TIMEOUT_RESET_VALUE value)
Reset the timeout value.
|
void |
set(CommandContext.Scope scope,
String key,
Object value)
Associates an object with key.
|
void |
setCommandTimeout(int numSeconds)
Set the command timeout to a number of seconds.
|
void |
setCurrentDir(File dir)
Changes the current default filesystem directory to the argument.
|
void |
setLastHandlerTask(Future<?> handlerTask)
When an handler execution occurs, multiple calls can be operated.
|
void |
setResolveParameterValues(boolean resolve)
Command argument or operation parameter values may contain system properties.
|
void |
setSilent(boolean silent)
Enables of disables the silent mode.
|
void |
setVariable(String name,
String value)
Initializes a variable with the given name with the given value.
|
void |
terminateSession()
Terminates the command line session.
|
BatchedCommand |
toBatchedCommand(String line)
Builds an operation request from the passed in command line.
|
public void setLastHandlerTask(Future<?> handlerTask)
handlerTask - The task to cancel if a timeout occurs.public Future<?> getLastTask()
public CliConfig getConfig()
CommandContextgetConfig in interface CommandContextpublic String getArgumentsString()
CommandContextgetArgumentsString in interface CommandContextpublic ParsedCommandLine getParsedCommandLine()
CommandContextgetParsedCommandLine in interface CommandContextpublic void printLine(String message)
CommandContextprintLine in interface CommandContextmessage - the message to printpublic void printColumns(Collection<String> col)
CommandContextprintColumns in interface CommandContextcol - the collection of strings to print as columns.public void clearScreen()
CommandContextclearScreen in interface CommandContextpublic void terminateSession()
CommandContextterminateSession in interface CommandContextpublic boolean isTerminated()
CommandContextisTerminated in interface CommandContextpublic void set(CommandContext.Scope scope, String key, Object value)
CommandContextset in interface CommandContextscope - Entry duration scopekey - the keyvalue - the value to be associated with the keypublic Object get(CommandContext.Scope scope, String key)
CommandContextget in interface CommandContextscope - Entry duration scopekey - the key to fetch the value forpublic void clear(CommandContext.Scope scope)
CommandContextclear in interface CommandContextscope - The scope to clear, can't be null.public Object remove(CommandContext.Scope scope, String key)
CommandContextremove in interface CommandContextscope - The entry duration scopekey - the key to be removedpublic ModelControllerClient getModelControllerClient()
CommandContextgetModelControllerClient in interface CommandContextpublic void connectController()
throws CommandLineException
CommandContextconnectController in interface CommandContextCommandLineException - in case the attempt to connect failedpublic void connectController(String controller, String client) throws CommandLineException
CommandContextconnectController in interface CommandContextcontroller - the controller to connect toclient - the address the client will bind toCommandLineException - in case the attempt to connect failedpublic void connectController(String controller) throws CommandLineException
CommandContextconnectController in interface CommandContextcontroller - the controller to connect toCommandLineException - in case the attempt to connect failedpublic void connectController(String host, int port) throws CommandLineException
CommandContextconnectController in interface CommandContexthost - the host to connect withport - the port to connect onCommandLineException - in case the attempt to connect failedpublic void bindClient(ModelControllerClient newClient)
CommandContextbindClient in interface CommandContextpublic void disconnectController()
CommandContextdisconnectController in interface CommandContextpublic String getDefaultControllerHost()
CommandContextgetDefaultControllerHost in interface CommandContextpublic int getDefaultControllerPort()
CommandContextgetDefaultControllerPort in interface CommandContextpublic ControllerAddress getDefaultControllerAddress()
CommandContextgetDefaultControllerAddress in interface CommandContextpublic String getControllerHost()
CommandContextgetControllerHost in interface CommandContextpublic int getControllerPort()
CommandContextgetControllerPort in interface CommandContextpublic CommandLineParser getCommandLineParser()
CommandContextgetCommandLineParser in interface CommandContextpublic OperationRequestAddress getCurrentNodePath()
CommandContextgetCurrentNodePath in interface CommandContextpublic NodePathFormatter getNodePathFormatter()
CommandContextgetNodePathFormatter in interface CommandContextpublic OperationCandidatesProvider getOperationCandidatesProvider()
CommandContextgetOperationCandidatesProvider in interface CommandContextpublic CommandHistory getHistory()
CommandContextgetHistory in interface CommandContextpublic boolean isBatchMode()
CommandContextisBatchMode in interface CommandContextpublic boolean isWorkflowMode()
CommandContextisWorkflowMode in interface CommandContextpublic BatchManager getBatchManager()
CommandContextgetBatchManager in interface CommandContextpublic BatchedCommand toBatchedCommand(String line) throws CommandFormatException
CommandContexttoBatchedCommand in interface CommandContextline - the command line which can be an operation request or a command that can be translated into an operation request.CommandFormatException - if the operation request couldn't be built.public org.jboss.dmr.ModelNode buildRequest(String line) throws CommandFormatException
CommandContextbuildRequest in interface CommandContextline - command or an operation to build a DMR request forCommandFormatException - thrown in case the line couldn't be
translated into a DMR requestpublic CommandLineCompleter getDefaultCommandCompleter()
CommandContextgetDefaultCommandCompleter in interface CommandContextpublic boolean isDomainMode()
CommandContextisDomainMode in interface CommandContextpublic void addEventListener(CliEventListener listener)
CommandContextaddEventListener in interface CommandContextlistener - the listenerpublic int getExitCode()
CommandContextgetExitCode in interface CommandContextpublic void handle(String line) throws CommandLineException
CommandContexthandle in interface CommandContextline - command or operation to handleCommandFormatException - in case there was an error handling the command or operationCommandLineExceptionpublic void handleSafe(String line)
CommandContexthandleSafe in interface CommandContextline - command or operation to handlepublic void interact()
CommandContextinteract in interface CommandContextpublic File getCurrentDir()
CommandContextgetCurrentDir in interface CommandContextpublic void setCurrentDir(File dir)
CommandContextsetCurrentDir in interface CommandContextdir - the new default directorypublic boolean isResolveParameterValues()
CommandContextisResolveParameterValues in interface CommandContextpublic void setResolveParameterValues(boolean resolve)
CommandContextsetResolveParameterValues in interface CommandContextresolve - true if system properties in the operation parameter values
should be resolved by the CLI before the request is sent to the controller,
false if system properties should be resolved on the server side.public boolean isSilent()
CommandContextisSilent in interface CommandContextpublic void setSilent(boolean silent)
CommandContextsetSilent in interface CommandContextsilent - true if the CLI should go into the silent mode,
false if the CLI should resume writing info
and error messages to the terminal output.public int getTerminalWidth()
CommandContextgetTerminalWidth in interface CommandContextpublic int getTerminalHeight()
CommandContextgetTerminalHeight in interface CommandContextpublic void setVariable(String name, String value) throws CommandLineException
CommandContextsetVariable in interface CommandContextname - name of the variablevalue - value for the variableCommandLineException - in case the name contains illegal characterspublic String getVariable(String name)
CommandContextgetVariable in interface CommandContextname - name of the variablepublic Collection<String> getVariables()
CommandContextgetVariables in interface CommandContextpublic void registerRedirection(CommandLineRedirection redirection) throws CommandLineException
CommandContextregisterRedirection in interface CommandContextredirection - command line redirection handlerCommandLineException - in case registration fails (e.g. in case
one has already been registeredpublic ConnectionInfo getConnectionInfo()
CommandContextgetConnectionInfo in interface CommandContextpublic void captureOutput(PrintStream captor)
CommandContextcaptureOutput in interface CommandContextcaptor - stream to which output should be written. Cannot be nullpublic void releaseOutput()
CommandContextCommandContext.captureOutput(java.io.PrintStream).releaseOutput in interface CommandContextpublic void setCommandTimeout(int numSeconds)
CommandContextsetCommandTimeout in interface CommandContextnumSeconds - The timeout value.public int getCommandTimeout()
CommandContextgetCommandTimeout in interface CommandContextpublic void resetTimeout(CommandContext.TIMEOUT_RESET_VALUE value)
CommandContextresetTimeout in interface CommandContextvalue - The enumerated timeout reset value.public org.jboss.dmr.ModelNode execute(org.jboss.dmr.ModelNode mn,
String description)
throws CommandLineException,
IOException
CommandContextexecute in interface CommandContextmn - The operation.description - Operation description, used in exception message.CommandLineException - If an exception occurs.IOException - If an IOException occurs.public org.jboss.dmr.ModelNode execute(Operation op, String description) throws CommandLineException, IOException
CommandContextexecute in interface CommandContextop - The operation.description - Operation description, used in exception message.CommandLineException - If an exception occurs.IOException - If an IOException occurs.Copyright © 2018 JBoss by Red Hat. All rights reserved.