-
Notifications
You must be signed in to change notification settings - Fork 41.3k
Provide an RSocketMessageHandlerCustomizer to allow customizing of the RSocketMessageHandler #21081
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package org.springframework.boot.autoconfigure.rsocket; | ||
|
||
import org.apache.catalina.connector.Connector; | ||
import org.springframework.boot.web.embedded.tomcat.ConfigurableTomcatWebServerFactory; | ||
import org.springframework.messaging.rsocket.RSocketStrategies; | ||
import org.springframework.messaging.rsocket.annotation.support.RSocketMessageHandler; | ||
import org.springframework.util.RouteMatcher; | ||
|
||
/** | ||
* @author Aarti Gupta | ||
* Callback interface that can be used to customize a RSocketMessageHandler {@link Connector}. | ||
*/ | ||
@FunctionalInterface | ||
public interface RSocketMessageHandlerCustomizer { | ||
|
||
RSocketMessageHandler setRouteMatcher(RouteMatcher handler); | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,9 @@ | |
import io.rsocket.RSocketFactory; | ||
import io.rsocket.transport.netty.server.TcpServerTransport; | ||
|
||
import java.util.Objects; | ||
import java.util.stream.Collectors; | ||
import org.springframework.beans.factory.ObjectProvider; | ||
import org.springframework.boot.autoconfigure.AutoConfigureAfter; | ||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; | ||
|
@@ -28,6 +31,7 @@ | |
import org.springframework.messaging.rsocket.RSocketRequester; | ||
import org.springframework.messaging.rsocket.RSocketStrategies; | ||
import org.springframework.messaging.rsocket.annotation.support.RSocketMessageHandler; | ||
import org.springframework.util.RouteMatcher; | ||
|
||
/** | ||
* {@link EnableAutoConfiguration Auto-configuration} for Spring RSocket support in Spring | ||
|
@@ -36,17 +40,19 @@ | |
* @author Brian Clozel | ||
* @since 2.2.0 | ||
*/ | ||
@Configuration(proxyBeanMethods = false) | ||
@ConditionalOnClass({ RSocketRequester.class, RSocketFactory.class, TcpServerTransport.class }) | ||
@Configuration(proxyBeanMethods = true) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a reason this was change to |
||
@ConditionalOnClass({RSocketRequester.class, RSocketFactory.class, TcpServerTransport.class}) | ||
@AutoConfigureAfter(RSocketStrategiesAutoConfiguration.class) | ||
public class RSocketMessagingAutoConfiguration { | ||
|
||
|
||
@Bean | ||
@ConditionalOnMissingBean | ||
public RSocketMessageHandler messageHandler(RSocketStrategies rSocketStrategies) { | ||
RSocketMessageHandler messageHandler = new RSocketMessageHandler(); | ||
messageHandler.setRSocketStrategies(rSocketStrategies); | ||
return messageHandler; | ||
@ConditionalOnMissingBean(RSocketMessageHandler.class) | ||
public RSocketMessageHandler messageHandler(RSocketStrategies rSocketStrategies, ObjectProvider<RSocketMessageHandlerCustomizer> customizers) { | ||
RSocketMessageHandlerCustomizer rSocketMessageHandlerCustomizer = customizers.getIfAvailable(); | ||
return rSocketMessageHandlerCustomizer.setRouteMatcher(rSocketStrategies.routeMatcher()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like |
||
} | ||
|
||
|
||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be consistent with other customizers, the method shouldn't return anything but be
void
instead.