https://issues.apache.org/jira/browse/AMQ-3454 - remove copy of destinationMap in region getDestinationMap api, return a direct reference to the unerlying concurrent hash map, makes it more efficient to determine presence of a destination

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1207224 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Gary Tully 2011-11-28 14:30:46 +00:00
parent 33bb129bee
commit 4d17a70809
3 changed files with 3 additions and 5 deletions

View File

@ -254,7 +254,7 @@ public abstract class AbstractRegion implements Region {
public Map<ActiveMQDestination, Destination> getDestinationMap() {
destinationsLock.readLock().lock();
try{
return new HashMap<ActiveMQDestination, Destination>(destinations);
return destinations;
} finally {
destinationsLock.readLock().unlock();
}

View File

@ -67,9 +67,7 @@ public interface Region extends Service {
void removeDestination(ConnectionContext context, ActiveMQDestination destination, long timeout) throws Exception;
/**
* Returns a copy of the current destinations available in the region
*
* @return a copy of the regions currently active at the time of the call with the key the destination and the value the Destination.
* Returns a reference to the concurrent hash map that holds known destinations, do not modify
*/
Map<ActiveMQDestination, Destination> getDestinationMap();

View File

@ -133,7 +133,7 @@ public class RegionBroker extends EmptyBroker {
@Override
public Map<ActiveMQDestination, Destination> getDestinationMap() {
Map<ActiveMQDestination, Destination> answer = getQueueRegion().getDestinationMap();
Map<ActiveMQDestination, Destination> answer = new HashMap<ActiveMQDestination, Destination>(getQueueRegion().getDestinationMap());
answer.putAll(getTopicRegion().getDestinationMap());
return answer;
}