1 /***
2 *
3 * Copyright 2004 Protique Ltd
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 **/
18 package org.codehaus.activemq.broker.impl;
19
20 import org.codehaus.activemq.ActiveMQConnection;
21 import org.codehaus.activemq.broker.BrokerContainer;
22
23 import javax.jms.JMSException;
24
25 /***
26 * A simple command line tool which runs a JMS Message Broker on the command line
27 *
28 * @version $Revision: 1.11 $
29 */
30 public class Main {
31
32 /***
33 * run the Message Broker as a standalone application
34 *
35 * @param args
36 */
37 public static void main(String args[]) {
38 try {
39 String url = ActiveMQConnection.DEFAULT_URL;
40 if (args.length > 0) {
41 url = args[0];
42 }
43
44 BrokerContainer container = new BrokerContainerImpl();
45 container.addConnector(url);
46
47 if (args.length > 1) {
48 container.addNetworkConnector(args[1]);
49 }
50
51 container.start();
52
53
54 Object lock = new Object();
55 synchronized (lock) {
56 lock.wait();
57 }
58 }
59 catch (JMSException e) {
60 System.out.println("Caught: " + e);
61 e.printStackTrace();
62 Exception le = e.getLinkedException();
63 System.out.println("Reason: " + le);
64 if (le != null) {
65 le.printStackTrace();
66 }
67 }
68 catch (Exception e) {
69 System.out.println("Caught: " + e);
70 e.printStackTrace();
71 }
72 }
73 }