Polish RSocket server bootstrap

See gh-16021
pull/16575/head
Brian Clozel 6 years ago
parent d4c47a13a0
commit 71362299ae

@ -18,9 +18,10 @@ package org.springframework.boot.autoconfigure.rsocket;
import java.util.stream.Collectors;
import io.netty.buffer.PooledByteBufAllocator;
import io.rsocket.RSocketFactory;
import io.rsocket.SocketAcceptor;
import io.rsocket.transport.netty.server.TcpServerTransport;
import reactor.netty.http.server.HttpServer;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
@ -33,7 +34,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.context.properties.PropertyMapper;
import org.springframework.boot.rsocket.netty.NettyRSocketBootstrap;
import org.springframework.boot.rsocket.server.RSocketServerBootstrap;
import org.springframework.boot.rsocket.netty.NettyRSocketServerFactory;
import org.springframework.boot.rsocket.server.RSocketServerFactory;
import org.springframework.boot.rsocket.server.ServerRSocketFactoryCustomizer;
@ -57,8 +58,8 @@ import org.springframework.messaging.rsocket.RSocketStrategies;
* @since 2.2.0
*/
@Configuration(proxyBeanMethods = false)
@ConditionalOnClass({ RSocketFactory.class, RSocketStrategies.class,
PooledByteBufAllocator.class })
@ConditionalOnClass({ RSocketFactory.class, RSocketStrategies.class, HttpServer.class,
TcpServerTransport.class })
@ConditionalOnBean(MessageHandlerAcceptor.class)
@AutoConfigureAfter(RSocketStrategiesAutoConfiguration.class)
@EnableConfigurationProperties(RSocketProperties.class)
@ -105,10 +106,10 @@ public class RSocketServerAutoConfiguration {
}
@Bean
public NettyRSocketBootstrap nettyRSocketBootstrap(
public RSocketServerBootstrap nettyRSocketBootstrap(
RSocketServerFactory rSocketServerFactory,
SocketAcceptor socketAcceptor) {
return new NettyRSocketBootstrap(rSocketServerFactory, socketAcceptor);
return new RSocketServerBootstrap(rSocketServerFactory, socketAcceptor);
}
}

@ -19,7 +19,7 @@ package org.springframework.boot.autoconfigure.rsocket;
import org.junit.Test;
import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.rsocket.netty.NettyRSocketBootstrap;
import org.springframework.boot.rsocket.server.RSocketServerBootstrap;
import org.springframework.boot.rsocket.server.RSocketServerFactory;
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
import org.springframework.boot.test.context.runner.ReactiveWebApplicationContextRunner;
@ -46,7 +46,7 @@ public class RSocketServerAutoConfigurationTests {
contextRunner.run((context) -> assertThat(context)
.doesNotHaveBean(WebServerFactoryCustomizer.class)
.doesNotHaveBean(RSocketServerFactory.class)
.doesNotHaveBean(NettyRSocketBootstrap.class));
.doesNotHaveBean(RSocketServerBootstrap.class));
}
@Test
@ -55,7 +55,7 @@ public class RSocketServerAutoConfigurationTests {
contextRunner.run((context) -> assertThat(context)
.doesNotHaveBean(WebServerFactoryCustomizer.class)
.doesNotHaveBean(RSocketServerFactory.class)
.doesNotHaveBean(NettyRSocketBootstrap.class));
.doesNotHaveBean(RSocketServerBootstrap.class));
}
@Test
@ -67,7 +67,7 @@ public class RSocketServerAutoConfigurationTests {
.run((context) -> assertThat(context)
.doesNotHaveBean(WebServerFactoryCustomizer.class)
.doesNotHaveBean(RSocketServerFactory.class)
.doesNotHaveBean(NettyRSocketBootstrap.class));
.doesNotHaveBean(RSocketServerBootstrap.class));
}
@Test
@ -87,7 +87,7 @@ public class RSocketServerAutoConfigurationTests {
contextRunner.withPropertyValues("spring.rsocket.server.port=0")
.run((context) -> assertThat(context)
.hasSingleBean(RSocketServerFactory.class)
.hasSingleBean(NettyRSocketBootstrap.class));
.hasSingleBean(RSocketServerBootstrap.class));
}
private ApplicationContextRunner createContextRunner() {

@ -14,13 +14,11 @@
* limitations under the License.
*/
package org.springframework.boot.rsocket.netty;
package org.springframework.boot.rsocket.server;
import io.rsocket.SocketAcceptor;
import org.springframework.boot.rsocket.context.RSocketServerInitializedEvent;
import org.springframework.boot.rsocket.server.RSocketServer;
import org.springframework.boot.rsocket.server.RSocketServerFactory;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ApplicationEventPublisherAware;
import org.springframework.context.SmartLifecycle;
@ -31,14 +29,14 @@ import org.springframework.context.SmartLifecycle;
* @author Brian Clozel
* @since 2.2.0
*/
public class NettyRSocketBootstrap
public class RSocketServerBootstrap
implements ApplicationEventPublisherAware, SmartLifecycle {
private final RSocketServer rSocketServer;
private ApplicationEventPublisher applicationEventPublisher;
public NettyRSocketBootstrap(RSocketServerFactory serverFactoryProvider,
public RSocketServerBootstrap(RSocketServerFactory serverFactoryProvider,
SocketAcceptor socketAcceptor) {
this.rSocketServer = serverFactoryProvider.create(socketAcceptor);
}
Loading…
Cancel
Save