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 and METADATA_PUSH, from the handling of stream requests.
Since:
5.2
Author:
Rossen Stoyanchev
  • Field Details

    • 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:
    • 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)
  • Constructor Details

    • RSocketFrameTypeMessageCondition

      public RSocketFrameTypeMessageCondition(io.rsocket.frame.FrameType... frameType)
    • RSocketFrameTypeMessageCondition

      public RSocketFrameTypeMessageCondition(Collection<io.rsocket.frame.FrameType> frameTypes)
  • Method Details

    • 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), never null.
      Specified by:
      getContent in class AbstractMessageCondition<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 class AbstractMessageCondition<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

      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 via MessageCondition.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 declared 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