Class RSocketFrameTypeMessageCondition

All Implemented Interfaces:

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.
Rossen Stoyanchev
  • Field Details


      public static final String FRAME_TYPE_HEADER
      The name of the header that contains the RSocket frame type being processed.
      See Also:

      public static final RSocketFrameTypeMessageCondition CONNECT_CONDITION
      Match connection-level frames "SETUP" or "METADATA_PUSH".

      public static final RSocketFrameTypeMessageCondition REQUEST_FNF_OR_RESPONSE_CONDITION
      Match RSocket frames "REQUEST_FNF" or "REQUEST_RESPONSE".

      public static final RSocketFrameTypeMessageCondition REQUEST_RESPONSE_CONDITION
      Match RSocket frame "REQUEST_RESPONSE".

      public static final RSocketFrameTypeMessageCondition REQUEST_STREAM_CONDITION
      Match RSocket frame "REQUEST_STREAM".

      public static final RSocketFrameTypeMessageCondition REQUEST_CHANNEL_CONDITION
      Match RSocket frame "REQUEST_CHANNEL".

      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.
      message - the current message
      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.
      other - the condition to combine with
      the resulting message condition
    • getMatchingCondition

      @Nullable 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.
      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
      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.
      a condition to use for matching the interaction type