Class RSocketFrameTypeMessageCondition
- java.lang.Object
- org.springframework.messaging.handler.AbstractMessageCondition<RSocketFrameTypeMessageCondition>
- org.springframework.messaging.rsocket.annotation.support.RSocketFrameTypeMessageCondition
- All Implemented Interfaces:
MessageCondition<RSocketFrameTypeMessageCondition>
public class RSocketFrameTypeMessageCondition extends AbstractMessageCondition<RSocketFrameTypeMessageCondition>
A condition to assist with mapping onto handler methods based on the RSocket frame type. This helps to separate the handling of connection-level frame types, i.e.SETUP
andMETADATA_PUSH
, from the handling of stream requests.- Since:
- 5.2
- Author:
- Rossen Stoyanchev
Field Summary
Fields Modifier and Type Field Description static RSocketFrameTypeMessageCondition
CONNECT_CONDITION
Match connection-level frames "SETUP" or "METADATA_PUSH".static RSocketFrameTypeMessageCondition
EMPTY_CONDITION
Empty condition that does not match to any RSocket frames (e.g.static String
FRAME_TYPE_HEADER
The name of the header that contains the RSocket frame type being processed.static RSocketFrameTypeMessageCondition
REQUEST_CHANNEL_CONDITION
Match RSocket frame "REQUEST_CHANNEL".static RSocketFrameTypeMessageCondition
REQUEST_CONDITION
Deprecated.as of 5.2.2 because matching to all interaction types is too flexible.static RSocketFrameTypeMessageCondition
REQUEST_FNF_OR_RESPONSE_CONDITION
Match RSocket frames "REQUEST_FNF" or "REQUEST_RESPONSE".static RSocketFrameTypeMessageCondition
REQUEST_RESPONSE_CONDITION
Match RSocket frame "REQUEST_RESPONSE".static RSocketFrameTypeMessageCondition
REQUEST_STREAM_CONDITION
Match RSocket frame "REQUEST_STREAM".
Constructor Summary
Constructors Constructor Description RSocketFrameTypeMessageCondition(io.rsocket.frame.FrameType... frameType)
RSocketFrameTypeMessageCondition(Collection<io.rsocket.frame.FrameType> frameTypes)
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description RSocketFrameTypeMessageCondition
combine(RSocketFrameTypeMessageCondition other)
Define the rules for combining this condition with another.int
compareTo(RSocketFrameTypeMessageCondition other, Message<?> message)
Compare this condition to another in the context of a specific message.static RSocketFrameTypeMessageCondition
getCondition(int cardinalityIn, int cardinalityOut)
Return a condition for matching the RSocket request interaction type with that is selected based on the delcared request and response cardinality of some handler method.protected Collection<?>
getContent()
Return the collection of objects the message condition is composed of (e.g.static io.rsocket.frame.FrameType
getFrameType(Message<?> message)
Find the RSocket frame type in the message headers.Set<io.rsocket.frame.FrameType>
getFrameTypes()
RSocketFrameTypeMessageCondition
getMatchingCondition(Message<?> message)
Check if this condition matches the given Message and returns a potentially new condition with content tailored to the current message.protected String
getToStringInfix()
The notation to use when printing discrete items of content.Methods inherited from class org.springframework.messaging.handler.AbstractMessageCondition
equals, hashCode, toString
Field Detail
FRAME_TYPE_HEADER
public static final String FRAME_TYPE_HEADER
The name of the header that contains the RSocket frame type being processed.- See Also:
- Constant Field Values
CONNECT_CONDITION
public static final RSocketFrameTypeMessageCondition CONNECT_CONDITION
Match connection-level frames "SETUP" or "METADATA_PUSH".
REQUEST_FNF_OR_RESPONSE_CONDITION
public static final RSocketFrameTypeMessageCondition REQUEST_FNF_OR_RESPONSE_CONDITION
Match RSocket frames "REQUEST_FNF" or "REQUEST_RESPONSE".
REQUEST_RESPONSE_CONDITION
public static final RSocketFrameTypeMessageCondition REQUEST_RESPONSE_CONDITION
Match RSocket frame "REQUEST_RESPONSE".
REQUEST_STREAM_CONDITION
public static final RSocketFrameTypeMessageCondition REQUEST_STREAM_CONDITION
Match RSocket frame "REQUEST_STREAM".
REQUEST_CHANNEL_CONDITION
public static final RSocketFrameTypeMessageCondition REQUEST_CHANNEL_CONDITION
Match RSocket frame "REQUEST_CHANNEL".
EMPTY_CONDITION
public static final RSocketFrameTypeMessageCondition EMPTY_CONDITION
Empty condition that does not match to any RSocket frames (e.g. for type-level mappings)
REQUEST_CONDITION
@Deprecated public static final RSocketFrameTypeMessageCondition REQUEST_CONDITION
Deprecated.as of 5.2.2 because matching to all interaction types is too flexible. Please use one of the other constants in this class that match to specific frames.Condition to match "REQUEST_FNF", "REQUEST_RESPONSE", "REQUEST_STREAM", and "REQUEST_CHANNEL".
Constructor Detail
RSocketFrameTypeMessageCondition
public RSocketFrameTypeMessageCondition(io.rsocket.frame.FrameType... frameType)
RSocketFrameTypeMessageCondition
public RSocketFrameTypeMessageCondition(Collection<io.rsocket.frame.FrameType> frameTypes)
Method Detail
getFrameTypes
public Set<io.rsocket.frame.FrameType> getFrameTypes()
getContent
protected Collection<?> getContent()
Description copied from class:AbstractMessageCondition
Return the collection of objects the message condition is composed of (e.g. destination patterns), nevernull
.- Specified by:
getContent
in classAbstractMessageCondition<RSocketFrameTypeMessageCondition>
getToStringInfix
protected String getToStringInfix()
Description copied from class:AbstractMessageCondition
The notation to use when printing discrete items of content. For example " || " for URL patterns or " && " for param expressions.- Specified by:
getToStringInfix
in classAbstractMessageCondition<RSocketFrameTypeMessageCondition>
getFrameType
@Nullable public static io.rsocket.frame.FrameType getFrameType(Message<?> message)
Find the RSocket frame type in the message headers.- Parameters:
message
- the current message- Returns:
- the frame type or
null
if not found
combine
public RSocketFrameTypeMessageCondition combine(RSocketFrameTypeMessageCondition other)
Description copied from interface:MessageCondition
Define the rules for combining this condition with another. For example combining type- and method-level conditions.- Parameters:
other
- the condition to combine with- Returns:
- the resulting message condition
getMatchingCondition
public RSocketFrameTypeMessageCondition getMatchingCondition(Message<?> message)
Description copied from interface:MessageCondition
Check if this condition matches the given Message and returns a potentially new condition with content tailored to the current message. For example a condition with destination patterns might return a new condition with sorted, matching patterns only.- Returns:
- a condition instance in case of a match; or
null
if there is no match.
compareTo
public int compareTo(RSocketFrameTypeMessageCondition other, Message<?> message)
Description copied from interface:MessageCondition
Compare this condition to another in the context of a specific message. It is assumed both instances have been obtained viaMessageCondition.getMatchingCondition(Message)
to ensure they have content relevant to current message only.
getCondition
public static RSocketFrameTypeMessageCondition getCondition(int cardinalityIn, int cardinalityOut)
Return a condition for matching the RSocket request interaction type with that is selected based on the delcared request and response cardinality of some handler method.The table below shows the selections made:
Request Cardinality Response Cardinality Interaction Types 0,1 0 Fire-And-Forget, Request-Response 0,1 1 Request-Response 0,1 2 Request-Stream 2 Any Request-Channel - Parameters:
cardinalityIn
- -- the request cardinality: 1 for a single payload, 2 for many payloads, and 0 if input is not handled.cardinalityOut
- -- the response cardinality: 0 for no output payloads, 1 for a single payload, and 2 for many payloads.- Returns:
- a condition to use for matching the interaction type
- Since:
- 5.2.2