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:
James Strachan 2007-03-13 13:24:23 +00:00
parent 3e09007cc1
commit a51a7d53e2
1 changed files with 15 additions and 1 deletions

View File

@ -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);