|
|
|
@ -52,6 +52,7 @@ import org.springframework.messaging.rsocket.MetadataExtractor; |
|
|
|
import org.springframework.messaging.rsocket.RSocketRequester; |
|
|
|
import org.springframework.messaging.rsocket.RSocketRequester; |
|
|
|
import org.springframework.messaging.rsocket.RSocketStrategies; |
|
|
|
import org.springframework.messaging.rsocket.RSocketStrategies; |
|
|
|
import org.springframework.messaging.rsocket.annotation.ConnectMapping; |
|
|
|
import org.springframework.messaging.rsocket.annotation.ConnectMapping; |
|
|
|
|
|
|
|
import org.springframework.messaging.rsocket.service.RSocketExchange; |
|
|
|
import org.springframework.util.Assert; |
|
|
|
import org.springframework.util.Assert; |
|
|
|
import org.springframework.util.MimeType; |
|
|
|
import org.springframework.util.MimeType; |
|
|
|
import org.springframework.util.MimeTypeUtils; |
|
|
|
import org.springframework.util.MimeTypeUtils; |
|
|
|
@ -60,8 +61,9 @@ import org.springframework.util.StringUtils; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Extension of {@link MessageMappingMessageHandler} for handling RSocket |
|
|
|
* Extension of {@link MessageMappingMessageHandler} for handling RSocket |
|
|
|
* requests with {@link ConnectMapping @ConnectMapping} and |
|
|
|
* requests with {@link ConnectMapping @ConnectMapping}, |
|
|
|
* {@link MessageMapping @MessageMapping} methods. |
|
|
|
* {@link MessageMapping @MessageMapping} |
|
|
|
|
|
|
|
* and {@link RSocketExchange @RSocketExchange} methods. |
|
|
|
* |
|
|
|
* |
|
|
|
* <p>For server scenarios this class can be declared as a bean in Spring |
|
|
|
* <p>For server scenarios this class can be declared as a bean in Spring |
|
|
|
* configuration and that would detect {@code @MessageMapping} methods in |
|
|
|
* configuration and that would detect {@code @MessageMapping} methods in |
|
|
|
@ -77,13 +79,14 @@ import org.springframework.util.StringUtils; |
|
|
|
* {@link org.springframework.messaging.rsocket.RSocketRequester.Builder#rsocketConnector |
|
|
|
* {@link org.springframework.messaging.rsocket.RSocketRequester.Builder#rsocketConnector |
|
|
|
* RSocketRequester.Builder}. |
|
|
|
* RSocketRequester.Builder}. |
|
|
|
* |
|
|
|
* |
|
|
|
* <p>For {@code @MessageMapping} methods, this class automatically determines |
|
|
|
* <p>For {@code @MessageMapping} and {@code @RSocketExchange} methods, |
|
|
|
* the RSocket interaction type based on the input and output cardinality of the |
|
|
|
* this class automatically determines the RSocket interaction type |
|
|
|
* method. See the |
|
|
|
* based on the input and output cardinality of the method. See the |
|
|
|
* <a href="https://docs.spring.io/spring/docs/current/spring-framework-reference/web-reactive.html#rsocket-annot-responders"> |
|
|
|
* <a href="https://docs.spring.io/spring/docs/current/spring-framework-reference/web-reactive.html#rsocket-annot-responders"> |
|
|
|
* "Annotated Responders"</a> section of the Spring Framework reference for more details. |
|
|
|
* "Annotated Responders"</a> section of the Spring Framework reference for more details. |
|
|
|
* |
|
|
|
* |
|
|
|
* @author Rossen Stoyanchev |
|
|
|
* @author Rossen Stoyanchev |
|
|
|
|
|
|
|
* @author Olga Maciaszek-Sharma |
|
|
|
* @since 5.2 |
|
|
|
* @since 5.2 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public class RSocketMessageHandler extends MessageMappingMessageHandler { |
|
|
|
public class RSocketMessageHandler extends MessageMappingMessageHandler { |
|
|
|
@ -322,6 +325,15 @@ public class RSocketMessageHandler extends MessageMappingMessageHandler { |
|
|
|
RSocketFrameTypeMessageCondition.CONNECT_CONDITION, |
|
|
|
RSocketFrameTypeMessageCondition.CONNECT_CONDITION, |
|
|
|
new DestinationPatternsMessageCondition(patterns, obtainRouteMatcher())); |
|
|
|
new DestinationPatternsMessageCondition(patterns, obtainRouteMatcher())); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
RSocketExchange ann3 = AnnotatedElementUtils.findMergedAnnotation(element, RSocketExchange.class); |
|
|
|
|
|
|
|
if (ann3 != null && StringUtils.hasText(ann3.value())) { |
|
|
|
|
|
|
|
String[] destinations = new String[]{ann3.value()}; |
|
|
|
|
|
|
|
return new CompositeMessageCondition( |
|
|
|
|
|
|
|
RSocketFrameTypeMessageCondition.EMPTY_CONDITION, |
|
|
|
|
|
|
|
new DestinationPatternsMessageCondition(processDestinations(destinations), |
|
|
|
|
|
|
|
obtainRouteMatcher()) |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -402,7 +414,8 @@ public class RSocketMessageHandler extends MessageMappingMessageHandler { |
|
|
|
* connection. Such a method can also start requests to the client but that |
|
|
|
* connection. Such a method can also start requests to the client but that |
|
|
|
* must be done decoupled from handling and from the current thread. |
|
|
|
* must be done decoupled from handling and from the current thread. |
|
|
|
* <p>Subsequent requests on the connection can be handled with |
|
|
|
* <p>Subsequent requests on the connection can be handled with |
|
|
|
* {@link MessageMapping MessageMapping} methods. |
|
|
|
* {@link MessageMapping MessageMapping} |
|
|
|
|
|
|
|
* and {@link RSocketExchange RSocketExchange} methods. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public SocketAcceptor responder() { |
|
|
|
public SocketAcceptor responder() { |
|
|
|
return (setupPayload, sendingRSocket) -> { |
|
|
|
return (setupPayload, sendingRSocket) -> { |
|
|
|
|