Class AbstractCommand
- java.lang.Object
-
- org.apache.activemq.console.command.AbstractCommand
-
- All Implemented Interfaces:
Command
- Direct Known Subclasses:
AbstractAmqCommand
,AbstractJmxCommand
,ConsumerCommand
,CreateCommand
,EncryptCommand
,ProducerCommand
,ShellCommand
,StartCommand
public abstract class AbstractCommand extends Object implements Command
-
-
Field Summary
Fields Modifier and Type Field Description static String
COMMAND_OPTION_DELIMETER
protected CommandContext
context
-
Constructor Summary
Constructors Constructor Description AbstractCommand()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
execute(List<String> tokens)
Execute a generic command, which includes parsing the options for the command and running the specific task.protected void
handleException(Exception exception, String serviceUrl)
protected void
handleOption(String token, List<String> tokens)
Handle the general options for each command, which includes -h, -?, --help, -D, --version.protected void
parseOptions(List<String> tokens)
Parse any option parameters in the command arguments specified by a '-' as the first character of the token.protected abstract void
printHelp()
Print the help messages for the specific taskprotected void
printHelpFromFile()
protected abstract void
runTask(List<String> tokens)
Run the specific task.void
setCommandContext(CommandContext context)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.activemq.console.command.Command
getName, getOneLineDescription
-
-
-
-
Field Detail
-
COMMAND_OPTION_DELIMETER
public static final String COMMAND_OPTION_DELIMETER
- See Also:
- Constant Field Values
-
context
protected CommandContext context
-
-
Method Detail
-
setCommandContext
public void setCommandContext(CommandContext context)
- Specified by:
setCommandContext
in interfaceCommand
-
execute
public void execute(List<String> tokens) throws Exception
Execute a generic command, which includes parsing the options for the command and running the specific task.
-
parseOptions
protected void parseOptions(List<String> tokens) throws Exception
Parse any option parameters in the command arguments specified by a '-' as the first character of the token.- Parameters:
tokens
- - command arguments- Throws:
Exception
-
handleOption
protected void handleOption(String token, List<String> tokens) throws Exception
Handle the general options for each command, which includes -h, -?, --help, -D, --version.- Parameters:
token
- - option token to handletokens
- - succeeding command arguments- Throws:
Exception
-
runTask
protected abstract void runTask(List<String> tokens) throws Exception
Run the specific task.- Parameters:
tokens
- - command arguments- Throws:
Exception
-
printHelp
protected abstract void printHelp()
Print the help messages for the specific task
-
printHelpFromFile
protected void printHelpFromFile()
-
-