root/src/java/src/com/omniti/reconnoiter/broker/BrokerFactory.java

Revision e8b241b833cdda315cc463b322a89ba888c5e781, 1.5 kB (checked in by Theo Schlossnagle <jesus@omniti.com>, 5 years ago)

juggle files around for cleaner builds.

  • Property mode set to 100644
Line 
1 /*
2  * Copyright (c) 2009, OmniTI Computer Consulting, Inc.
3  * All rights reserved.
4  * The software in this package is published under the terms of the GPL license
5  * a copy of which can be found at:
6  * https://labs.omniti.com/reconnoiter/trunk/src/java/LICENSE
7  */
8
9 package com.omniti.reconnoiter.broker;
10
11 import org.apache.activemq.broker.BrokerService;
12
13 import com.omniti.reconnoiter.StratconConfig;
14
15 public class BrokerFactory {
16   private static BrokerService amqBroker = null;
17  
18   public static IMQBroker getBroker(StratconConfig config) {
19     // TODO if the broker is null default the AMQAdapter
20     String broker = config.getBroker();
21    
22     if (broker == null)
23       return new AMQBroker(config);
24    
25     if (broker.compareToIgnoreCase("rabbitmq") == 0) {
26       return new RabbitBroker(config);
27     }
28     else if (broker.compareToIgnoreCase("activemq") == 0) {
29       return new AMQBroker(config);
30     }
31     return new AMQBroker(config);
32   }
33  
34
35   public static BrokerService getAMQBrokerService() {
36     if(amqBroker == null) System.err.println("Cannot broker messages");
37     return amqBroker;
38   }
39   public static BrokerService getAMQBrokerService(String stomp) {
40     if(amqBroker != null) return amqBroker;
41     try {
42       amqBroker = new BrokerService();
43       amqBroker.setUseJmx(false);
44       amqBroker.addConnector("vm://localhost");
45       amqBroker.addConnector(stomp);
46       amqBroker.start();
47     } catch(Exception e) {
48       System.err.println("Cannot broker messages: " + e);
49     }
50     return amqBroker;
51   }
52
53 }
Note: See TracBrowser for help on using the browser.