001 /**
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements. See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License. You may obtain a copy of the License at
008 *
009 * http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017 package org.apache.activemq.console.util;
018
019 import java.io.BufferedReader;
020 import java.io.InputStreamReader;
021
022 import org.apache.activemq.broker.util.CommandMessageListener;
023
024 /**
025 * A simple interactive console which can be used to communicate with a running
026 * broker assuming that the classpath is fully setup
027 *
028 * @version $Revision: 564977 $
029 */
030 public final class SimpleConsole {
031
032 private SimpleConsole() {
033 }
034
035 public static void main(String[] args) {
036 CommandMessageListener listener = new CommandMessageListener(null);
037
038 try {
039 BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
040 while (true) {
041 String line = reader.readLine();
042 if (line == null || "quit".equalsIgnoreCase(line)) {
043 break;
044 }
045 line = line.trim();
046 if (line.length() == 0) {
047 continue;
048 }
049
050 System.out.println(listener.processCommandText(line));
051 }
052 } catch (Exception e) {
053 System.out.println("Caught: " + e);
054 e.printStackTrace();
055 }
056 }
057 }