Rename socket factory processor methods on NettyRSocketServerFactory
Previously, the methods were named addServerProcessors and setServerProcessors which wasn't aligned with them taking socket factory processors (ServerRSocketFactoryProcessor) as an argument. This commit renames the methods to align them more closely with the type of their arguments. Closes gh-18617
This commit is contained in:
@@ -97,7 +97,7 @@ public class RSocketServerAutoConfiguration {
|
||||
PropertyMapper map = PropertyMapper.get().alwaysApplyingWhenNonNull();
|
||||
map.from(properties.getServer().getAddress()).to(factory::setAddress);
|
||||
map.from(properties.getServer().getPort()).to(factory::setPort);
|
||||
factory.setServerProcessors(processors.orderedStream().collect(Collectors.toList()));
|
||||
factory.setSocketFactoryProcessors(processors.orderedStream().collect(Collectors.toList()));
|
||||
return factory;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import io.rsocket.RSocketFactory;
|
||||
import io.rsocket.RSocketFactory.ServerRSocketFactory;
|
||||
import io.rsocket.SocketAcceptor;
|
||||
import io.rsocket.transport.ServerTransport;
|
||||
import io.rsocket.transport.netty.server.CloseableChannel;
|
||||
@@ -60,7 +61,7 @@ public class NettyRSocketServerFactory implements RSocketServerFactory, Configur
|
||||
|
||||
private Duration lifecycleTimeout;
|
||||
|
||||
private List<ServerRSocketFactoryProcessor> serverProcessors = new ArrayList<>();
|
||||
private List<ServerRSocketFactoryProcessor> socketFactoryProcessors = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public void setPort(int port) {
|
||||
@@ -86,23 +87,25 @@ public class NettyRSocketServerFactory implements RSocketServerFactory, Configur
|
||||
}
|
||||
|
||||
/**
|
||||
* Set {@link ServerRSocketFactoryProcessor}s that should be applied to the RSocket
|
||||
* server builder. Calling this method will replace any existing customizers.
|
||||
* @param serverProcessors server processors to apply before the server starts
|
||||
* Set {@link ServerRSocketFactoryProcessor}s that should be called to process the
|
||||
* {@link ServerRSocketFactory} while building the server. Calling this method will
|
||||
* replace any existing processors.
|
||||
* @param socketFactoryProcessors processors to apply before the server starts
|
||||
*/
|
||||
public void setServerProcessors(Collection<? extends ServerRSocketFactoryProcessor> serverProcessors) {
|
||||
Assert.notNull(serverProcessors, "ServerProcessors must not be null");
|
||||
this.serverProcessors = new ArrayList<>(serverProcessors);
|
||||
public void setSocketFactoryProcessors(
|
||||
Collection<? extends ServerRSocketFactoryProcessor> socketFactoryProcessors) {
|
||||
Assert.notNull(socketFactoryProcessors, "SocketFactoryProcessors must not be null");
|
||||
this.socketFactoryProcessors = new ArrayList<>(socketFactoryProcessors);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add {@link ServerRSocketFactoryProcessor}s that should applied while building the
|
||||
* server.
|
||||
* @param serverProcessors server processors to apply before the server starts
|
||||
* Add {@link ServerRSocketFactoryProcessor}s that should be called to process the
|
||||
* {@link ServerRSocketFactory} while building the server.
|
||||
* @param socketFactoryProcessors processors to apply before the server starts
|
||||
*/
|
||||
public void addServerProcessors(ServerRSocketFactoryProcessor... serverProcessors) {
|
||||
Assert.notNull(serverProcessors, "ServerProcessors must not be null");
|
||||
this.serverProcessors.addAll(Arrays.asList(serverProcessors));
|
||||
public void addSocketFactoryProcessors(ServerRSocketFactoryProcessor... socketFactoryProcessors) {
|
||||
Assert.notNull(socketFactoryProcessors, "SocketFactoryProcessors must not be null");
|
||||
this.socketFactoryProcessors.addAll(Arrays.asList(socketFactoryProcessors));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -118,7 +121,7 @@ public class NettyRSocketServerFactory implements RSocketServerFactory, Configur
|
||||
public NettyRSocketServer create(SocketAcceptor socketAcceptor) {
|
||||
ServerTransport<CloseableChannel> transport = createTransport();
|
||||
RSocketFactory.ServerRSocketFactory factory = RSocketFactory.receive();
|
||||
for (ServerRSocketFactoryProcessor processor : this.serverProcessors) {
|
||||
for (ServerRSocketFactoryProcessor processor : this.socketFactoryProcessors) {
|
||||
factory = processor.process(factory);
|
||||
}
|
||||
Mono<CloseableChannel> starter = factory.acceptor(socketAcceptor).transport(transport).start();
|
||||
|
||||
@@ -137,7 +137,7 @@ class NettyRSocketServerFactoryTests {
|
||||
given(processors[i].process(any(RSocketFactory.ServerRSocketFactory.class)))
|
||||
.will((invocation) -> invocation.getArgument(0));
|
||||
}
|
||||
factory.setServerProcessors(Arrays.asList(processors));
|
||||
factory.setSocketFactoryProcessors(Arrays.asList(processors));
|
||||
this.server = factory.create(new EchoRequestResponseAcceptor());
|
||||
InOrder ordered = inOrder((Object[]) processors);
|
||||
for (ServerRSocketFactoryProcessor processor : processors) {
|
||||
|
||||
Reference in New Issue
Block a user