diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/rsocket/RSocketServerAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/rsocket/RSocketServerAutoConfiguration.java index d4c59eb668..2ef84770fa 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/rsocket/RSocketServerAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/rsocket/RSocketServerAutoConfiguration.java @@ -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); } } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/rsocket/RSocketServerAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/rsocket/RSocketServerAutoConfigurationTests.java index d44fd549a9..ec4ff60dcd 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/rsocket/RSocketServerAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/rsocket/RSocketServerAutoConfigurationTests.java @@ -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() { diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/rsocket/netty/NettyRSocketBootstrap.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/rsocket/server/RSocketServerBootstrap.java similarity index 86% rename from spring-boot-project/spring-boot/src/main/java/org/springframework/boot/rsocket/netty/NettyRSocketBootstrap.java rename to spring-boot-project/spring-boot/src/main/java/org/springframework/boot/rsocket/server/RSocketServerBootstrap.java index 85e76011de..a9cb747a80 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/rsocket/netty/NettyRSocketBootstrap.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/rsocket/server/RSocketServerBootstrap.java @@ -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); }