Package org.apache.activemq.filter
Class DestinationMap
- java.lang.Object
-
- org.apache.activemq.filter.DestinationMap
-
- Direct Known Subclasses:
DefaultAuthorizationMap
,PolicyMap
,RedeliveryPolicyMap
public class DestinationMap extends Object
A Map-like data structure allowing values to be indexed byActiveMQDestination
and retrieved by destination - supporting both * and > style of wildcard as well as composite destinations.
This class assumes that the index changes rarely but that fast lookup into the index is required. So this class maintains a pre-calculated index for destination steps. So looking up the values for "TEST.*" or "*.TEST" will be pretty fast.
Looking up of a value could return a single value or a List of matching values if a wildcard or composite destination is used.
-
-
Field Summary
Fields Modifier and Type Field Description protected static String
ANY_CHILD
protected static String
ANY_DESCENDENT
-
Constructor Summary
Constructors Constructor Description DestinationMap()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description DestinationMapEntry
chooseValue(ActiveMQDestination destination)
Returns the value which matches the given destination or null if there is no matching value.protected Set
findWildcardMatches(ActiveMQDestination key)
protected Set
findWildcardMatches(ActiveMQDestination key, boolean deep)
Set
get(ActiveMQDestination key)
Looks up the value(s) matching the given Destination key.protected Class<? extends DestinationMapEntry>
getEntryClass()
Returns the type of the allowed entries which can be set via thesetEntries(List)
method.int
getQueueRootChildCount()
DestinationMapNode
getQueueRootNode()
protected DestinationMapNode
getRootNode(ActiveMQDestination key)
Returns the root node for the given destination typeDestinationMapNode
getTempQueueRootNode()
DestinationMapNode
getTempTopicRootNode()
int
getTopicRootChildCount()
DestinationMapNode
getTopicRootNode()
boolean
isEmpty()
void
put(ActiveMQDestination key, Object value)
void
remove(ActiveMQDestination key, Object value)
Removes the value from the associated destinationSet
removeAll(ActiveMQDestination key)
void
reset()
protected void
setEntries(List<DestinationMapEntry> entries)
A helper method to allow the destination map to be populated from a dependency injection framework such as Springstatic Set
union(Set existing, Set candidates)
Set
unsynchronizedGet(ActiveMQDestination key)
void
unsynchronizedPut(ActiveMQDestination key, Object value)
void
unsynchronizedRemove(ActiveMQDestination key, Object value)
-
-
-
Field Detail
-
ANY_DESCENDENT
protected static final String ANY_DESCENDENT
- See Also:
- Constant Field Values
-
ANY_CHILD
protected static final String ANY_CHILD
- See Also:
- Constant Field Values
-
-
Method Detail
-
get
public Set get(ActiveMQDestination key)
Looks up the value(s) matching the given Destination key. For simple destinations this is typically a List of one single value, for wildcards or composite destinations this will typically be a List of matching values.- Parameters:
key
- the destination to lookup- Returns:
- a List of matching values or an empty list if there are no matching values.
-
unsynchronizedGet
public Set unsynchronizedGet(ActiveMQDestination key)
-
put
public void put(ActiveMQDestination key, Object value)
-
unsynchronizedPut
public void unsynchronizedPut(ActiveMQDestination key, Object value)
-
remove
public void remove(ActiveMQDestination key, Object value)
Removes the value from the associated destination
-
unsynchronizedRemove
public void unsynchronizedRemove(ActiveMQDestination key, Object value)
-
getTopicRootChildCount
public int getTopicRootChildCount()
-
getQueueRootChildCount
public int getQueueRootChildCount()
-
getQueueRootNode
public DestinationMapNode getQueueRootNode()
-
getTopicRootNode
public DestinationMapNode getTopicRootNode()
-
getTempQueueRootNode
public DestinationMapNode getTempQueueRootNode()
-
getTempTopicRootNode
public DestinationMapNode getTempTopicRootNode()
-
setEntries
protected void setEntries(List<DestinationMapEntry> entries)
A helper method to allow the destination map to be populated from a dependency injection framework such as Spring
-
getEntryClass
protected Class<? extends DestinationMapEntry> getEntryClass()
Returns the type of the allowed entries which can be set via thesetEntries(List)
method. This allows derived classes to further restrict the type of allowed entries to make a type safe destination map for custom policies.
-
findWildcardMatches
protected Set findWildcardMatches(ActiveMQDestination key)
-
findWildcardMatches
protected Set findWildcardMatches(ActiveMQDestination key, boolean deep)
-
removeAll
public Set removeAll(ActiveMQDestination key)
- Parameters:
key
-- Returns:
-
chooseValue
public DestinationMapEntry chooseValue(ActiveMQDestination destination)
Returns the value which matches the given destination or null if there is no matching value. If there are multiple values, the results are sorted and the last item (the biggest) is returned.- Parameters:
destination
- the destination to find the value for- Returns:
- the largest matching value or null if no value matches
-
getRootNode
protected DestinationMapNode getRootNode(ActiveMQDestination key)
Returns the root node for the given destination type
-
reset
public void reset()
-
isEmpty
public boolean isEmpty()
-
-