Upgrade to RSocket 1.0 RC7 snapshots
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -15,8 +15,6 @@
|
||||
*/
|
||||
package org.springframework.messaging.rsocket;
|
||||
|
||||
import io.rsocket.RSocketFactory;
|
||||
|
||||
/**
|
||||
* Strategy to apply configuration to a client side {@code RSocketFactory}.
|
||||
* that's being prepared by {@link RSocketRequester.Builder} to connect
|
||||
@@ -24,13 +22,17 @@ import io.rsocket.RSocketFactory;
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
* @since 5.2
|
||||
* @deprecated as of 5.2.6 following the deprecation of
|
||||
* {@link io.rsocket.RSocketFactory.ClientRSocketFactory RSocketFactory.ClientRSocketFactory}
|
||||
* in RSocket 1.0 RC7. Please, use {@link RSocketConnectorConfigurer}.
|
||||
*/
|
||||
@FunctionalInterface
|
||||
@Deprecated
|
||||
public interface ClientRSocketFactoryConfigurer {
|
||||
|
||||
/**
|
||||
* Apply configuration to the given {@code ClientRSocketFactory}.
|
||||
*/
|
||||
void configure(RSocketFactory.ClientRSocketFactory rsocketFactory);
|
||||
void configure(io.rsocket.RSocketFactory.ClientRSocketFactory rsocketFactory);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -25,12 +25,12 @@ import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import io.rsocket.Payload;
|
||||
import io.rsocket.RSocketFactory;
|
||||
import io.rsocket.frame.decoder.PayloadDecoder;
|
||||
import io.rsocket.metadata.WellKnownMimeType;
|
||||
import io.rsocket.transport.ClientTransport;
|
||||
import io.rsocket.transport.netty.client.TcpClientTransport;
|
||||
import io.rsocket.transport.netty.client.WebsocketClientTransport;
|
||||
import io.rsocket.util.DefaultPayload;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import org.springframework.core.ReactiveAdapter;
|
||||
@@ -43,6 +43,7 @@ import org.springframework.core.io.buffer.DataBufferUtils;
|
||||
import org.springframework.core.io.buffer.NettyDataBufferFactory;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.MimeType;
|
||||
import org.springframework.util.MimeTypeUtils;
|
||||
@@ -56,10 +57,17 @@ import org.springframework.util.MimeTypeUtils;
|
||||
*/
|
||||
final class DefaultRSocketRequesterBuilder implements RSocketRequester.Builder {
|
||||
|
||||
private final static boolean rsocketConnectorPresent =
|
||||
ClassUtils.isPresent("io.rsocket.core.RSocketConnector",
|
||||
DefaultRSocketRequesterBuilder.class.getClassLoader());
|
||||
|
||||
|
||||
private static final Map<String, Object> HINTS = Collections.emptyMap();
|
||||
|
||||
private static final byte[] EMPTY_BYTE_ARRAY = new byte[0];
|
||||
|
||||
private static final Payload EMPTY_SETUP_PAYLOAD = DefaultPayload.create(EMPTY_BYTE_ARRAY);
|
||||
|
||||
|
||||
@Nullable
|
||||
private MimeType dataMimeType;
|
||||
@@ -84,7 +92,10 @@ final class DefaultRSocketRequesterBuilder implements RSocketRequester.Builder {
|
||||
|
||||
private List<Consumer<RSocketStrategies.Builder>> strategiesConfigurers = new ArrayList<>();
|
||||
|
||||
private List<ClientRSocketFactoryConfigurer> rsocketConfigurers = new ArrayList<>();
|
||||
private List<RSocketConnectorConfigurer> rsocketConnectorConfigurers = new ArrayList<>();
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private List<ClientRSocketFactoryConfigurer> rsocketFactoryConfigurers = new ArrayList<>();
|
||||
|
||||
|
||||
@Override
|
||||
@@ -133,8 +144,15 @@ final class DefaultRSocketRequesterBuilder implements RSocketRequester.Builder {
|
||||
}
|
||||
|
||||
@Override
|
||||
public RSocketRequester.Builder rsocketConnector(RSocketConnectorConfigurer configurer) {
|
||||
this.rsocketConnectorConfigurers.add(configurer);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public RSocketRequester.Builder rsocketFactory(ClientRSocketFactoryConfigurer configurer) {
|
||||
this.rsocketConfigurers.add(configurer);
|
||||
this.rsocketFactoryConfigurers.add(configurer);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -164,28 +182,25 @@ final class DefaultRSocketRequesterBuilder implements RSocketRequester.Builder {
|
||||
Assert.isTrue(!rsocketStrategies.encoders().isEmpty(), "No encoders");
|
||||
Assert.isTrue(!rsocketStrategies.decoders().isEmpty(), "No decoders");
|
||||
|
||||
RSocketFactory.ClientRSocketFactory factory = RSocketFactory.connect();
|
||||
this.rsocketConfigurers.forEach(configurer -> configurer.configure(factory));
|
||||
|
||||
if (rsocketStrategies.dataBufferFactory() instanceof NettyDataBufferFactory) {
|
||||
factory.frameDecoder(PayloadDecoder.ZERO_COPY);
|
||||
}
|
||||
|
||||
MimeType metaMimeType = this.metadataMimeType != null ? this.metadataMimeType :
|
||||
MimeTypeUtils.parseMimeType(WellKnownMimeType.MESSAGE_RSOCKET_COMPOSITE_METADATA.getString());
|
||||
|
||||
MimeType dataMimeType = getDataMimeType(rsocketStrategies);
|
||||
factory.dataMimeType(dataMimeType.toString());
|
||||
factory.metadataMimeType(metaMimeType.toString());
|
||||
|
||||
return getSetupPayload(dataMimeType, metaMimeType, rsocketStrategies)
|
||||
.doOnNext(factory::setupPayload)
|
||||
.then(Mono.defer(() ->
|
||||
factory.transport(transport)
|
||||
.start()
|
||||
.map(rsocket -> new DefaultRSocketRequester(
|
||||
rsocket, dataMimeType, metaMimeType, rsocketStrategies))
|
||||
));
|
||||
if (rsocketConnectorPresent) {
|
||||
return getSetupPayload(dataMimeType, metaMimeType, rsocketStrategies)
|
||||
.flatMap(payload ->
|
||||
new RSocketConnectorHelper().connect(
|
||||
this.rsocketConnectorConfigurers, this.rsocketFactoryConfigurers,
|
||||
metaMimeType, dataMimeType, payload, rsocketStrategies, transport));
|
||||
}
|
||||
else {
|
||||
return getSetupPayload(dataMimeType, metaMimeType, rsocketStrategies)
|
||||
.flatMap(payload ->
|
||||
new RSocketFactoryHelper().connect(
|
||||
this.rsocketFactoryConfigurers, metaMimeType, dataMimeType, payload,
|
||||
rsocketStrategies, transport));
|
||||
}
|
||||
}
|
||||
|
||||
private RSocketStrategies getRSocketStrategies() {
|
||||
@@ -234,7 +249,7 @@ final class DefaultRSocketRequesterBuilder implements RSocketRequester.Builder {
|
||||
Object data = this.setupData;
|
||||
boolean hasMetadata = (this.setupRoute != null || !CollectionUtils.isEmpty(this.setupMetadata));
|
||||
if (!hasMetadata && data == null) {
|
||||
return Mono.empty();
|
||||
return Mono.just(EMPTY_SETUP_PAYLOAD);
|
||||
}
|
||||
|
||||
Mono<DataBuffer> dataMono = Mono.empty();
|
||||
@@ -269,4 +284,69 @@ final class DefaultRSocketRequesterBuilder implements RSocketRequester.Builder {
|
||||
.doOnDiscard(Payload.class, Payload::release);
|
||||
}
|
||||
|
||||
|
||||
private static class RSocketConnectorHelper {
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
Mono<RSocketRequester> connect(
|
||||
List<RSocketConnectorConfigurer> connectorConfigurers,
|
||||
List<ClientRSocketFactoryConfigurer> factoryConfigurers,
|
||||
MimeType metaMimeType, MimeType dataMimeType, Payload setupPayload,
|
||||
RSocketStrategies rsocketStrategies, ClientTransport transport) {
|
||||
|
||||
io.rsocket.core.RSocketConnector connector = io.rsocket.core.RSocketConnector.create();
|
||||
connectorConfigurers.forEach(c -> c.configure(connector));
|
||||
|
||||
if (!factoryConfigurers.isEmpty()) {
|
||||
io.rsocket.RSocketFactory.ClientRSocketFactory factory =
|
||||
new io.rsocket.RSocketFactory.ClientRSocketFactory(connector);
|
||||
factoryConfigurers.forEach(c -> c.configure(factory));
|
||||
}
|
||||
|
||||
if (rsocketStrategies.dataBufferFactory() instanceof NettyDataBufferFactory) {
|
||||
connector.payloadDecoder(PayloadDecoder.ZERO_COPY);
|
||||
}
|
||||
|
||||
if (setupPayload != EMPTY_SETUP_PAYLOAD) {
|
||||
connector.setupPayload(setupPayload);
|
||||
}
|
||||
|
||||
return connector
|
||||
.metadataMimeType(metaMimeType.toString())
|
||||
.dataMimeType(dataMimeType.toString())
|
||||
.connect(transport)
|
||||
.map(rsocket -> new DefaultRSocketRequester(
|
||||
rsocket, dataMimeType, metaMimeType, rsocketStrategies));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private static class RSocketFactoryHelper {
|
||||
|
||||
Mono<RSocketRequester> connect(
|
||||
List<ClientRSocketFactoryConfigurer> configurers,
|
||||
MimeType metaMimeType, MimeType dataMimeType, Payload setupPayload,
|
||||
RSocketStrategies rsocketStrategies, ClientTransport transport) {
|
||||
|
||||
io.rsocket.RSocketFactory.ClientRSocketFactory factory = io.rsocket.RSocketFactory.connect();
|
||||
configurers.forEach(c -> c.configure(factory));
|
||||
|
||||
if (rsocketStrategies.dataBufferFactory() instanceof NettyDataBufferFactory) {
|
||||
factory.frameDecoder(PayloadDecoder.ZERO_COPY);
|
||||
}
|
||||
|
||||
if (setupPayload != EMPTY_SETUP_PAYLOAD) {
|
||||
factory.setupPayload(setupPayload);
|
||||
}
|
||||
|
||||
return factory.metadataMimeType(metaMimeType.toString())
|
||||
.dataMimeType(dataMimeType.toString())
|
||||
.transport(transport)
|
||||
.start()
|
||||
.map(rsocket -> new DefaultRSocketRequester(
|
||||
rsocket, dataMimeType, metaMimeType, rsocketStrategies));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.messaging.rsocket;
|
||||
|
||||
import io.rsocket.core.RSocketConnector;
|
||||
|
||||
/**
|
||||
* Strategy to apply configuration to an {@code RSocketConnector}. For use with
|
||||
* {@link RSocketRequester.Builder#rsocketConnector RSocketRequester.Builder}.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
* @since 5.2.6
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface RSocketConnectorConfigurer {
|
||||
|
||||
/**
|
||||
* Apply configuration to the given {@code RSocketConnector}.
|
||||
*/
|
||||
void configure(RSocketConnector connector);
|
||||
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -185,6 +185,26 @@ public interface RSocketRequester {
|
||||
*/
|
||||
RSocketRequester.Builder rsocketStrategies(Consumer<RSocketStrategies.Builder> configurer);
|
||||
|
||||
/**
|
||||
* Callback to configure the {@code RSocketConnector} directly.
|
||||
* <ul>
|
||||
* <li>The data and metadata mime types cannot be set directly
|
||||
* on the {@code RSocketConnector} and will be overridden. Use the
|
||||
* shortcuts {@link #dataMimeType(MimeType)} and
|
||||
* {@link #metadataMimeType(MimeType)} on this builder instead.
|
||||
* <li>The frame decoder also cannot be set directly and instead is set
|
||||
* to match the configured {@code DataBufferFactory}.
|
||||
* <li>For the
|
||||
* {@link io.rsocket.core.RSocketConnector#setupPayload(Payload)
|
||||
* setupPayload}, consider using methods on this builder to specify the
|
||||
* route, other metadata, and data as Object values to be encoded.
|
||||
* <li>To configure client side responding, see
|
||||
* {@link RSocketMessageHandler#responder(RSocketStrategies, Object...)}.
|
||||
* </ul>
|
||||
* @since 5.2.6
|
||||
*/
|
||||
RSocketRequester.Builder rsocketConnector(RSocketConnectorConfigurer configurer);
|
||||
|
||||
/**
|
||||
* Callback to configure the {@code ClientRSocketFactory} directly.
|
||||
* <ul>
|
||||
@@ -201,7 +221,11 @@ public interface RSocketRequester {
|
||||
* <li>To configure client side responding, see
|
||||
* {@link RSocketMessageHandler#clientResponder(RSocketStrategies, Object...)}.
|
||||
* </ul>
|
||||
* @deprecated as of 5.2.6 following the deprecation of
|
||||
* {@link io.rsocket.RSocketFactory.ClientRSocketFactory RSocketFactory.ClientRSocketFactory}
|
||||
* in RSocket 1.0 RC7. Please, use {@link #rsocketConnector(RSocketConnectorConfigurer)}.
|
||||
*/
|
||||
@Deprecated
|
||||
RSocketRequester.Builder rsocketFactory(ClientRSocketFactoryConfigurer configurer);
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -20,8 +20,6 @@ import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import io.rsocket.Payload;
|
||||
import io.rsocket.RSocketFactory.ClientRSocketFactory;
|
||||
import io.rsocket.RSocketFactory.ServerRSocketFactory;
|
||||
|
||||
import org.springframework.core.ReactiveAdapterRegistry;
|
||||
import org.springframework.core.ResolvableType;
|
||||
@@ -200,9 +198,10 @@ public interface RSocketStrategies {
|
||||
* <a href="https://github.com/rsocket/rsocket-java#zero-copy">configured</a>
|
||||
* for zero copy. For client setup, {@link RSocketRequester.Builder}
|
||||
* adapts automatically to the {@code DataBufferFactory} configured
|
||||
* here, and sets the frame decoder in {@link ClientRSocketFactory
|
||||
* ClientRSocketFactory} accordingly. For server setup, the
|
||||
* {@link ServerRSocketFactory ServerRSocketFactory} must be configured
|
||||
* here, and sets the frame decoder in
|
||||
* {@link io.rsocket.core.RSocketConnector RSocketConnector}
|
||||
* accordingly. For server setup, the
|
||||
* {@link io.rsocket.core.RSocketServer RSocketServer} must be configured
|
||||
* accordingly for zero copy too.
|
||||
* <p>If using {@link DefaultDataBufferFactory} instead, there is no
|
||||
* need for related config changes in RSocket.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -48,7 +48,6 @@ import org.springframework.messaging.handler.annotation.MessageMapping;
|
||||
import org.springframework.messaging.handler.annotation.reactive.MessageMappingMessageHandler;
|
||||
import org.springframework.messaging.handler.annotation.reactive.PayloadMethodArgumentResolver;
|
||||
import org.springframework.messaging.handler.invocation.reactive.HandlerMethodReturnValueHandler;
|
||||
import org.springframework.messaging.rsocket.ClientRSocketFactoryConfigurer;
|
||||
import org.springframework.messaging.rsocket.MetadataExtractor;
|
||||
import org.springframework.messaging.rsocket.RSocketRequester;
|
||||
import org.springframework.messaging.rsocket.RSocketStrategies;
|
||||
@@ -70,13 +69,13 @@ import org.springframework.util.StringUtils;
|
||||
* {@link #setHandlerPredicate(Predicate) handlerPredicate}. Given an instance
|
||||
* of this class, you can then use {@link #responder()} to obtain a
|
||||
* {@link SocketAcceptor} adapter to register with the
|
||||
* {@link io.rsocket.RSocketFactory}.
|
||||
* {@link io.rsocket.core.RSocketServer}.
|
||||
*
|
||||
* <p>For client scenarios, possibly in the same process as a server, consider
|
||||
* <p>For a client, possibly in the same process as a server, consider
|
||||
* consider using the static factory method
|
||||
* {@link #clientResponder(RSocketStrategies, Object...)} to obtain a client
|
||||
* responder to be registered with an
|
||||
* {@link org.springframework.messaging.rsocket.RSocketRequester.Builder#rsocketFactory
|
||||
* {@link #responder(RSocketStrategies, Object...)} to obtain a client
|
||||
* responder to be registered via
|
||||
* {@link org.springframework.messaging.rsocket.RSocketRequester.Builder#rsocketConnector
|
||||
* RSocketRequester.Builder}.
|
||||
*
|
||||
* <p>For {@code @MessageMapping} methods, this class automatically determines
|
||||
@@ -393,13 +392,13 @@ public class RSocketMessageHandler extends MessageMappingMessageHandler {
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an adapter for a {@link SocketAcceptor} that delegates to this
|
||||
* {@code RSocketMessageHandler} instance. The adapter can be plugged in as a
|
||||
* {@link io.rsocket.RSocketFactory.ClientRSocketFactory#acceptor(SocketAcceptor) client} or
|
||||
* {@link io.rsocket.RSocketFactory.ServerRSocketFactory#acceptor(SocketAcceptor) server}
|
||||
* side responder.
|
||||
* <p>The initial {@link ConnectionSetupPayload} can be handled with a
|
||||
* {@link ConnectMapping @ConnectionMapping} method which can be asynchronous
|
||||
* Return an RSocket {@link SocketAcceptor} backed by this
|
||||
* {@code RSocketMessageHandler} instance that can be plugged in as a
|
||||
* {@link io.rsocket.core.RSocketConnector#acceptor(SocketAcceptor) client} or
|
||||
* {@link io.rsocket.core.RSocketServer#acceptor(SocketAcceptor) server}
|
||||
* RSocket responder.
|
||||
* <p>The initial {@link ConnectionSetupPayload} is handled through
|
||||
* {@link ConnectMapping @ConnectionMapping} methods that can be asynchronous
|
||||
* and return {@code Mono<Void>} with an error signal preventing the
|
||||
* connection. Such a method can also start requests to the client but that
|
||||
* must be done decoupled from handling and from the current thread.
|
||||
@@ -445,10 +444,61 @@ public class RSocketMessageHandler extends MessageMappingMessageHandler {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Static factory method to create an RSocket {@link SocketAcceptor}
|
||||
* backed by handlers with annotated methods. Effectively a shortcut for:
|
||||
* <pre class="code">
|
||||
* RSocketMessageHandler handler = new RSocketMessageHandler();
|
||||
* handler.setHandlers(handlers);
|
||||
* handler.setRSocketStrategies(strategies);
|
||||
* handler.afterPropertiesSet();
|
||||
*
|
||||
* SocketAcceptor acceptor = handler.responder();
|
||||
* </pre>
|
||||
* <p>This is intended for programmatic creation and registration of a
|
||||
* client-side responder. For example:
|
||||
* <pre class="code">
|
||||
* SocketAcceptor responder =
|
||||
* RSocketMessageHandler.responder(strategies, new ClientHandler());
|
||||
*
|
||||
* RSocketRequester.builder()
|
||||
* .rsocketConnector(connector -> connector.acceptor(responder))
|
||||
* .connectTcp("localhost", server.address().getPort());
|
||||
* </pre>
|
||||
*
|
||||
* <p>Note that the given handlers do not need to have any stereotype
|
||||
* annotations such as {@code @Controller} which helps to avoid overlap with
|
||||
* server side handlers that may be used in the same application. However,
|
||||
* for more advanced scenarios, e.g. discovering handlers through a custom
|
||||
* stereotype annotation, consider declaring {@code RSocketMessageHandler}
|
||||
* as a bean, and then obtain the responder from it.
|
||||
*
|
||||
* @param strategies the strategies to set on the created
|
||||
* {@code RSocketMessageHandler}
|
||||
* @param candidateHandlers a list of Objects and/or Classes with annotated
|
||||
* handler methods; used to call {@link #setHandlers(List)} with
|
||||
* on the created {@code RSocketMessageHandler}
|
||||
* @return a configurer that may be passed into
|
||||
* {@link org.springframework.messaging.rsocket.RSocketRequester.Builder#rsocketConnector}
|
||||
* @since 5.2.6
|
||||
*/
|
||||
public static SocketAcceptor responder(RSocketStrategies strategies, Object... candidateHandlers) {
|
||||
Assert.notEmpty(candidateHandlers, "No handlers");
|
||||
List<Object> handlers = new ArrayList<>(candidateHandlers.length);
|
||||
for (Object obj : candidateHandlers) {
|
||||
handlers.add(obj instanceof Class ? BeanUtils.instantiateClass((Class<?>) obj) : obj);
|
||||
}
|
||||
RSocketMessageHandler handler = new RSocketMessageHandler();
|
||||
handler.setHandlers(handlers);
|
||||
handler.setRSocketStrategies(strategies);
|
||||
handler.afterPropertiesSet();
|
||||
return handler.responder();
|
||||
}
|
||||
|
||||
/**
|
||||
* Static factory method for a configurer of a client side responder with
|
||||
* annotated handler methods. This is intended to be passed into
|
||||
* {@link org.springframework.messaging.rsocket.RSocketRequester.Builder#rsocketFactory(ClientRSocketFactoryConfigurer)}.
|
||||
* {@link org.springframework.messaging.rsocket.RSocketRequester.Builder#rsocketFactory}.
|
||||
* <p>In effect a shortcut to create and initialize
|
||||
* {@code RSocketMessageHandler} with the given strategies and handlers,
|
||||
* use {@link #responder()} to obtain the responder, and plug that into
|
||||
@@ -462,9 +512,13 @@ public class RSocketMessageHandler extends MessageMappingMessageHandler {
|
||||
* handler methods; used to call {@link #setHandlers(List)} with
|
||||
* on the created {@code RSocketMessageHandler}
|
||||
* @return a configurer that may be passed into
|
||||
* {@link org.springframework.messaging.rsocket.RSocketRequester.Builder#rsocketFactory(ClientRSocketFactoryConfigurer)}
|
||||
* {@link org.springframework.messaging.rsocket.RSocketRequester.Builder#rsocketFactory}
|
||||
* @deprecated as of 5.2.6 following the deprecation of
|
||||
* {@link io.rsocket.RSocketFactory.ClientRSocketFactory RSocketFactory.ClientRSocketFactory}
|
||||
* in RSocket 1.0 RC7.
|
||||
*/
|
||||
public static ClientRSocketFactoryConfigurer clientResponder(
|
||||
@Deprecated
|
||||
public static org.springframework.messaging.rsocket.ClientRSocketFactoryConfigurer clientResponder(
|
||||
RSocketStrategies strategies, Object... candidateHandlers) {
|
||||
|
||||
Assert.notEmpty(candidateHandlers, "No handlers");
|
||||
@@ -473,12 +527,14 @@ public class RSocketMessageHandler extends MessageMappingMessageHandler {
|
||||
handlers.add(obj instanceof Class ? BeanUtils.instantiateClass((Class<?>) obj) : obj);
|
||||
}
|
||||
|
||||
return rsocketFactory -> {
|
||||
return factory -> {
|
||||
RSocketMessageHandler handler = new RSocketMessageHandler();
|
||||
handler.setHandlers(handlers);
|
||||
handler.setRSocketStrategies(strategies);
|
||||
handler.afterPropertiesSet();
|
||||
rsocketFactory.acceptor(handler.responder());
|
||||
factory.acceptor(handler.responder());
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user