001    /** 
002     * 
003     * Copyright 2004 Protique Ltd
004     * 
005     * Licensed under the Apache License, Version 2.0 (the "License"); 
006     * you may not use this file except in compliance with the License. 
007     * 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     **/
018    package org.activemq.broker.impl;
019    
020    import org.activemq.ActiveMQConnection;
021    import org.activemq.broker.BrokerContainer;
022    
023    import javax.jms.JMSException;
024    
025    /**
026     * A simple command line tool which runs a JMS Message Broker on the command line
027     *
028     * @version $Revision: 1.1.1.1 $
029     */
030    public class Main {
031    
032        /**
033         * run the Message Broker as a standalone application
034         *
035         * @param args
036         */
037        public static void main(String args[]) {
038            try {
039                String url = ActiveMQConnection.DEFAULT_BROKER_URL;
040                if (args.length > 0) {
041                    url = args[0];
042                }
043    
044                BrokerContainer container = new BrokerContainerImpl();
045                container.addConnector(url);
046    
047                if (args.length > 1) {
048                    container.addNetworkConnector(args[1]);
049                }
050    
051                container.start();
052    
053                // lets wait until we're killed.
054                Object lock = new Object();
055                synchronized (lock) {
056                    lock.wait();
057                }
058            }
059            catch (JMSException e) {
060                System.out.println("Caught: " + e);
061                e.printStackTrace();
062                Exception le = e.getLinkedException();
063                System.out.println("Reason: " + le);
064                if (le != null) {
065                    le.printStackTrace();
066                }
067            }
068            catch (Exception e) {
069                System.out.println("Caught: " + e);
070                e.printStackTrace();
071            }
072        }
073    }