mirror of https://github.com/apache/activemq.git
added a helper method to access the current singleton broker
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@517687 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
3e09007cc1
commit
a51a7d53e2
|
@ -18,6 +18,7 @@
|
|||
package org.apache.activemq.broker;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -39,7 +40,20 @@ public class BrokerRegistry {
|
|||
return (BrokerService)brokers.get(brokerName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the first registered broker found
|
||||
*/
|
||||
public BrokerService findFirst() {
|
||||
synchronized(mutex) {
|
||||
Iterator iter = brokers.values().iterator();
|
||||
while (iter.hasNext()) {
|
||||
return (BrokerService) iter.next();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public void bind(String brokerName, BrokerService broker) {
|
||||
synchronized(mutex) {
|
||||
brokers.put(brokerName, broker);
|
||||
|
|
Loading…
Reference in New Issue