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.spring;
19
20 import org.codehaus.activemq.broker.BrokerContainer;
21 import org.springframework.core.io.FileSystemResource;
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 * using a Spring XML deployment descriptor
28 *
29 * @version $Revision: 1.2 $
30 */
31 public class Main {
32
33 /***
34 * run the Message Broker as a standalone application
35 *
36 * @param args
37 */
38 public static void main(String args[]) {
39 try {
40 SpringBrokerContainerFactory factory = new SpringBrokerContainerFactory();
41 if (args.length <= 0) {
42 System.out.println("Usage: Main <xmlConfigFile>");
43 System.out.println("You must specify a deployment descriptor to run the ActiveMQ Message Broker");
44 return;
45 }
46 String file = args[0];
47
48 System.out.println("Loading Message Broker from file: " + file);
49 factory.setResource(new FileSystemResource(file));
50
51 BrokerContainer container = factory.createBrokerContainer("DefaultBroker");
52 container.start();
53
54
55 Object lock = new Object();
56 synchronized (lock) {
57 lock.wait();
58 }
59 }
60 catch (JMSException e) {
61 System.out.println("Caught: " + e);
62 e.printStackTrace();
63 Exception le = e.getLinkedException();
64 System.out.println("Reason: " + le);
65 if (le != null) {
66 le.printStackTrace();
67 }
68 }
69 catch (Exception e) {
70 System.out.println("Caught: " + e);
71 e.printStackTrace();
72 }
73 }
74 }