Search in sources :

Example 1 with PayloadMethodArgumentResolver

use of org.springframework.messaging.handler.annotation.reactive.PayloadMethodArgumentResolver in project spring-framework by spring-projects.

the class RSocketMessageHandler method extendMapping.

@Override
protected CompositeMessageCondition extendMapping(CompositeMessageCondition composite, HandlerMethod handler) {
    List<MessageCondition<?>> conditions = composite.getMessageConditions();
    Assert.isTrue(conditions.size() == 2 && conditions.get(0) instanceof RSocketFrameTypeMessageCondition && conditions.get(1) instanceof DestinationPatternsMessageCondition, "Unexpected message condition types");
    if (conditions.get(0) != RSocketFrameTypeMessageCondition.EMPTY_CONDITION) {
        return composite;
    }
    int responseCardinality = getCardinality(handler.getReturnType());
    int requestCardinality = 0;
    for (MethodParameter parameter : handler.getMethodParameters()) {
        if (getArgumentResolvers().getArgumentResolver(parameter) instanceof PayloadMethodArgumentResolver) {
            requestCardinality = getCardinality(parameter);
        }
    }
    return new CompositeMessageCondition(RSocketFrameTypeMessageCondition.getCondition(requestCardinality, responseCardinality), conditions.get(1));
}
Also used : DestinationPatternsMessageCondition(org.springframework.messaging.handler.DestinationPatternsMessageCondition) MessageCondition(org.springframework.messaging.handler.MessageCondition) CompositeMessageCondition(org.springframework.messaging.handler.CompositeMessageCondition) CompositeMessageCondition(org.springframework.messaging.handler.CompositeMessageCondition) DestinationPatternsMessageCondition(org.springframework.messaging.handler.DestinationPatternsMessageCondition) PayloadMethodArgumentResolver(org.springframework.messaging.handler.annotation.reactive.PayloadMethodArgumentResolver) MethodParameter(org.springframework.core.MethodParameter)

Aggregations

MethodParameter (org.springframework.core.MethodParameter)1 CompositeMessageCondition (org.springframework.messaging.handler.CompositeMessageCondition)1 DestinationPatternsMessageCondition (org.springframework.messaging.handler.DestinationPatternsMessageCondition)1 MessageCondition (org.springframework.messaging.handler.MessageCondition)1 PayloadMethodArgumentResolver (org.springframework.messaging.handler.annotation.reactive.PayloadMethodArgumentResolver)1