mirror of https://github.com/apache/activemq.git
added a helper method so a BrokerFilter can lookup all the active destinations for a specific wildcard which can be useful for implementing things like AMQ-452 to support virtual destinations
git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@419629 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
a5971e69ab
commit
06a5829c14
|
@ -16,8 +16,6 @@
|
|||
*/
|
||||
package org.apache.activemq.broker;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import org.apache.activemq.broker.region.Destination;
|
||||
import org.apache.activemq.broker.region.Subscription;
|
||||
import org.apache.activemq.command.ActiveMQDestination;
|
||||
|
@ -35,6 +33,9 @@ import org.apache.activemq.command.RemoveSubscriptionInfo;
|
|||
import org.apache.activemq.command.SessionInfo;
|
||||
import org.apache.activemq.command.TransactionId;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Allows you to intercept broker operation so that features such as security can be
|
||||
* implemented as a pluggable filter.
|
||||
|
@ -49,7 +50,6 @@ public class BrokerFilter implements Broker {
|
|||
this.next=next;
|
||||
}
|
||||
|
||||
|
||||
public Broker getAdaptor(Class type){
|
||||
if (type.isInstance(this)){
|
||||
return this;
|
||||
|
@ -61,6 +61,10 @@ public class BrokerFilter implements Broker {
|
|||
return next.getDestinationMap();
|
||||
}
|
||||
|
||||
public Set getDestinations(ActiveMQDestination destination) {
|
||||
return next.getDestinations(destination);
|
||||
}
|
||||
|
||||
public void acknowledge(ConnectionContext context, MessageAck ack) throws Exception {
|
||||
next.acknowledge(context, ack);
|
||||
}
|
||||
|
|
|
@ -16,9 +16,6 @@
|
|||
*/
|
||||
package org.apache.activemq.broker;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import org.apache.activemq.broker.region.Destination;
|
||||
import org.apache.activemq.broker.region.Subscription;
|
||||
import org.apache.activemq.command.ActiveMQDestination;
|
||||
|
@ -36,6 +33,10 @@ import org.apache.activemq.command.RemoveSubscriptionInfo;
|
|||
import org.apache.activemq.command.SessionInfo;
|
||||
import org.apache.activemq.command.TransactionId;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Dumb implementation - used to be overriden by listeners
|
||||
*
|
||||
|
@ -62,6 +63,10 @@ public class EmptyBroker implements Broker{
|
|||
return Collections.EMPTY_MAP;
|
||||
}
|
||||
|
||||
public Set getDestinations(ActiveMQDestination destination) {
|
||||
return Collections.EMPTY_SET;
|
||||
}
|
||||
|
||||
public void addConnection(ConnectionContext context,ConnectionInfo info) throws Exception{
|
||||
|
||||
}
|
||||
|
|
|
@ -54,6 +54,10 @@ public class ErrorBroker implements Broker {
|
|||
return Collections.EMPTY_MAP;
|
||||
}
|
||||
|
||||
public Set getDestinations(ActiveMQDestination destination) {
|
||||
return Collections.EMPTY_SET;
|
||||
}
|
||||
|
||||
public Broker getAdaptor(Class type){
|
||||
if (type.isInstance(this)){
|
||||
return this;
|
||||
|
|
|
@ -16,8 +16,6 @@
|
|||
*/
|
||||
package org.apache.activemq.broker;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import org.apache.activemq.broker.region.Destination;
|
||||
import org.apache.activemq.broker.region.Subscription;
|
||||
import org.apache.activemq.command.ActiveMQDestination;
|
||||
|
@ -35,6 +33,9 @@ import org.apache.activemq.command.RemoveSubscriptionInfo;
|
|||
import org.apache.activemq.command.SessionInfo;
|
||||
import org.apache.activemq.command.TransactionId;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Like a BrokerFilter but it allows you to switch the getNext().broker. This has more
|
||||
* overhead than a BrokerFilter since access to the getNext().broker has to synchronized
|
||||
|
@ -74,6 +75,10 @@ public class MutableBrokerFilter implements Broker {
|
|||
return getNext().getDestinationMap();
|
||||
}
|
||||
|
||||
public Set getDestinations(ActiveMQDestination destination) {
|
||||
return getNext().getDestinations(destination);
|
||||
}
|
||||
|
||||
public void acknowledge(ConnectionContext context, MessageAck ack) throws Exception {
|
||||
getNext().acknowledge(context, ack);
|
||||
}
|
||||
|
|
|
@ -134,6 +134,17 @@ abstract public class AbstractRegion implements Region {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide an exact or wildcard lookup of destinations in the region
|
||||
*
|
||||
* @return a set of matching destination objects.
|
||||
*/
|
||||
public Set getDestinations(ActiveMQDestination destination) {
|
||||
synchronized(destinationsMutex){
|
||||
return destinationMap.get(destination);
|
||||
}
|
||||
}
|
||||
|
||||
public Map getDestinationMap() {
|
||||
synchronized(destinationsMutex){
|
||||
return new HashMap(destinations);
|
||||
|
|
|
@ -26,6 +26,7 @@ import org.apache.activemq.command.MessageDispatchNotification;
|
|||
import org.apache.activemq.command.RemoveSubscriptionInfo;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* A Region is used to implement the different QOS options available to
|
||||
|
@ -115,4 +116,11 @@ public interface Region extends Service {
|
|||
|
||||
public void gc();
|
||||
|
||||
/**
|
||||
* Provide an exact or wildcard lookup of destinations in the region
|
||||
*
|
||||
* @return a set of matching destination objects.
|
||||
*/
|
||||
public Set getDestinations(ActiveMQDestination destination);
|
||||
|
||||
}
|
||||
|
|
|
@ -103,6 +103,21 @@ public class RegionBroker implements Broker {
|
|||
return answer;
|
||||
}
|
||||
|
||||
public Set getDestinations(ActiveMQDestination destination) {
|
||||
switch(destination.getDestinationType()) {
|
||||
case ActiveMQDestination.QUEUE_TYPE:
|
||||
return queueRegion.getDestinations(destination);
|
||||
case ActiveMQDestination.TOPIC_TYPE:
|
||||
return topicRegion.getDestinations(destination);
|
||||
case ActiveMQDestination.TEMP_QUEUE_TYPE:
|
||||
return tempQueueRegion.getDestinations(destination);
|
||||
case ActiveMQDestination.TEMP_TOPIC_TYPE:
|
||||
return tempTopicRegion.getDestinations(destination);
|
||||
default:
|
||||
return Collections.EMPTY_SET;
|
||||
}
|
||||
}
|
||||
|
||||
public Broker getAdaptor(Class type){
|
||||
if (type.isInstance(this)){
|
||||
return this;
|
||||
|
|
Loading…
Reference in New Issue