org.apache.activemq.console
public class: ConsoleCommandHandler [javadoc |
source]
java.lang.Object
org.apache.activemq.console.ConsoleCommandHandler
All Implemented Interfaces:
CommandHandler
A default implementation of the @{link CommandHandler} interface
Methods from java.lang.Object: |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method from org.apache.activemq.console.ConsoleCommandHandler Detail: |
public void processCommand(TextMessage request,
TextMessage response) throws Exception {
ByteArrayOutputStream out = new ByteArrayOutputStream();
CommandContext ctx = new CommandContext();
ctx.setFormatter(new CommandShellOutputFormatter(out));
// lets turn the text into a list of arguments
String requestText = request.getText();
List< String > tokens = tokenize(requestText);
command.setCommandContext(ctx);
command.execute(tokens);
out.flush();
byte[] bytes = out.toByteArray();
String answer = new String(bytes);
response.setText(answer);
}
|
protected List<String> tokenize(String text) {
List< String > answer = new ArrayList< String >();
StringTokenizer iter = new StringTokenizer(text);
while (iter.hasMoreTokens()) {
answer.add(iter.nextToken());
}
return answer;
}
|