Class DestinationPatternsMessageCondition
java.lang.Object
org.springframework.messaging.handler.AbstractMessageCondition<DestinationPatternsMessageCondition>
org.springframework.messaging.handler.DestinationPatternsMessageCondition
- All Implemented Interfaces:
- MessageCondition<DestinationPatternsMessageCondition>
public class DestinationPatternsMessageCondition
extends AbstractMessageCondition<DestinationPatternsMessageCondition>
MessageCondition to match the destination header of a Message
 against one or more patterns through a RouteMatcher.- Since:
- 4.0
- Author:
- Rossen Stoyanchev
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final StringThe name of the "lookup destination" header.
- 
Constructor SummaryConstructorsConstructorDescriptionDestinationPatternsMessageCondition(String... patterns) Constructor with patterns only.DestinationPatternsMessageCondition(String[] patterns, @Nullable PathMatcher matcher) Constructor with patterns and aPathMatcherinstance.DestinationPatternsMessageCondition(String[] patterns, RouteMatcher routeMatcher) Constructor with patterns and aRouteMatcherinstance.
- 
Method SummaryModifier and TypeMethodDescriptionReturns a new instance with URL patterns from the current instance ("this") and the "other" instance as follows: If there are patterns in both instances, combine the patterns in "this" with the patterns in "other" usingPathMatcher.combine(String, String).intcompareTo(DestinationPatternsMessageCondition other, Message<?> message) Compare the two conditions based on the destination patterns they contain.protected Collection<String> Return the collection of objects the message condition is composed of (for example, destination patterns), nevernull.getMatchingCondition(Message<?> message) Check if any of the patterns match the given Message destination and return an instance that is guaranteed to contain matching patterns, sorted viaPathMatcher.getPatternComparator(String).protected StringThe notation to use when printing discrete items of content.Methods inherited from class org.springframework.messaging.handler.AbstractMessageConditionequals, hashCode, toString
- 
Field Details- 
LOOKUP_DESTINATION_HEADERThe name of the "lookup destination" header.- See Also:
 
 
- 
- 
Constructor Details- 
DestinationPatternsMessageConditionConstructor with patterns only. Creates and uses an instance ofAntPathMatcherwith default settings.Non-empty patterns that don't start with "/" are prepended with "/". - Parameters:
- patterns- the URL patterns to match to, or if 0 then always match
 
- 
DestinationPatternsMessageConditionConstructor with patterns and aPathMatcherinstance.- Parameters:
- patterns- the URL patterns to match to, or if 0 then always match
- matcher- the- PathMatcherto use
 
- 
DestinationPatternsMessageConditionConstructor with patterns and aRouteMatcherinstance.- Parameters:
- patterns- the URL patterns to match to, or if 0 then always match
- routeMatcher- the- RouteMatcherto use
- Since:
- 5.2
 
 
- 
- 
Method Details- 
getPatterns
- 
getContentDescription copied from class:AbstractMessageConditionReturn the collection of objects the message condition is composed of (for example, destination patterns), nevernull.- Specified by:
- getContentin class- AbstractMessageCondition<DestinationPatternsMessageCondition>
 
- 
getToStringInfixDescription copied from class:AbstractMessageConditionThe notation to use when printing discrete items of content. For example " || " for URL patterns or " && " for param expressions.- Specified by:
- getToStringInfixin class- AbstractMessageCondition<DestinationPatternsMessageCondition>
 
- 
combineReturns a new instance with URL patterns from the current instance ("this") and the "other" instance as follows:- If there are patterns in both instances, combine the patterns in "this" with
 the patterns in "other" using PathMatcher.combine(String, String).
- If only one instance has patterns, use them.
- If neither instance has patterns, use an empty String (i.e. "").
 - Parameters:
- other- the condition to combine with
- Returns:
- the resulting message condition
 
- If there are patterns in both instances, combine the patterns in "this" with
 the patterns in "other" using 
- 
getMatchingConditionCheck if any of the patterns match the given Message destination and return an instance that is guaranteed to contain matching patterns, sorted viaPathMatcher.getPatternComparator(String).- Parameters:
- message- the message to match to
- Returns:
- the same instance if the condition contains no patterns;
 or a new condition with sorted matching patterns;
 or nulleither if a destination can not be extracted or there is no match
 
- 
compareToCompare the two conditions based on the destination patterns they contain. Patterns are compared one at a time, from top to bottom viaPathMatcher.getPatternComparator(String). If all compared patterns match equally, but one instance has more patterns, it is considered a closer match.It is assumed that both instances have been obtained via getMatchingCondition(Message)to ensure they contain only patterns that match the request and are sorted with the best matches on top.
 
-