Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
6b4efcce
Commit
6b4efcce
authored
May 31, 2021
by
Stephane Nicoll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish "Apply RSocketConnectorConfigurer beans to RSocketRequester.Builder"
See gh-26341
parent
850c6538
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
12 deletions
+10
-12
RSocketRequesterAutoConfiguration.java
...oconfigure/rsocket/RSocketRequesterAutoConfiguration.java
+5
-5
RSocketRequesterAutoConfigurationTests.java
...igure/rsocket/RSocketRequesterAutoConfigurationTests.java
+4
-6
rsocket.adoc
.../spring-boot-docs/src/docs/asciidoc/features/rsocket.adoc
+1
-1
No files found.
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/rsocket/RSocketRequesterAutoConfiguration.java
View file @
6b4efcce
/*
/*
* Copyright 2012-202
0
the original author or authors.
* Copyright 2012-202
1
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -29,6 +29,7 @@ import org.springframework.context.annotation.Configuration;
...
@@ -29,6 +29,7 @@ import org.springframework.context.annotation.Configuration;
import
org.springframework.context.annotation.Scope
;
import
org.springframework.context.annotation.Scope
;
import
org.springframework.messaging.rsocket.RSocketConnectorConfigurer
;
import
org.springframework.messaging.rsocket.RSocketConnectorConfigurer
;
import
org.springframework.messaging.rsocket.RSocketRequester
;
import
org.springframework.messaging.rsocket.RSocketRequester
;
import
org.springframework.messaging.rsocket.RSocketRequester.Builder
;
import
org.springframework.messaging.rsocket.RSocketStrategies
;
import
org.springframework.messaging.rsocket.RSocketStrategies
;
/**
/**
...
@@ -39,7 +40,6 @@ import org.springframework.messaging.rsocket.RSocketStrategies;
...
@@ -39,7 +40,6 @@ import org.springframework.messaging.rsocket.RSocketStrategies;
* requester instances with different configurations.
* requester instances with different configurations.
*
*
* @author Brian Clozel
* @author Brian Clozel
* @author Nguyen Bao Sach
* @since 2.2.0
* @since 2.2.0
*/
*/
@Configuration
(
proxyBeanMethods
=
false
)
@Configuration
(
proxyBeanMethods
=
false
)
...
@@ -52,9 +52,9 @@ public class RSocketRequesterAutoConfiguration {
...
@@ -52,9 +52,9 @@ public class RSocketRequesterAutoConfiguration {
@ConditionalOnMissingBean
@ConditionalOnMissingBean
public
RSocketRequester
.
Builder
rSocketRequesterBuilder
(
RSocketStrategies
strategies
,
public
RSocketRequester
.
Builder
rSocketRequesterBuilder
(
RSocketStrategies
strategies
,
ObjectProvider
<
RSocketConnectorConfigurer
>
connectorConfigurers
)
{
ObjectProvider
<
RSocketConnectorConfigurer
>
connectorConfigurers
)
{
return
connectorConfigurers
.
orderedStream
()
Builder
builder
=
RSocketRequester
.
builder
().
rsocketStrategies
(
strategies
);
.
collect
(
RSocketRequester:
:
builder
,
RSocketRequester
.
Builder
::
rsocketConnector
,
(
first
,
second
)
->
{
connectorConfigurers
.
orderedStream
().
forEach
(
builder:
:
rsocketConnector
);
}).
rsocketStrategies
(
strategies
)
;
return
builder
;
}
}
}
}
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/rsocket/RSocketRequesterAutoConfigurationTests.java
View file @
6b4efcce
/*
/*
* Copyright 2012-20
19
the original author or authors.
* Copyright 2012-20
21
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -64,14 +64,12 @@ class RSocketRequesterAutoConfigurationTests {
...
@@ -64,14 +64,12 @@ class RSocketRequesterAutoConfigurationTests {
}
}
@Test
@Test
void
rSocketConnectorConfigurersArePickedUp
()
{
void
shouldCreateBuilderWithAvailableRSocketConnectorConfigurers
()
{
RSocketConnectorConfigurer
first
=
mock
(
RSocketConnectorConfigurer
.
class
);
RSocketConnectorConfigurer
first
=
mock
(
RSocketConnectorConfigurer
.
class
);
RSocketConnectorConfigurer
second
=
mock
(
RSocketConnectorConfigurer
.
class
);
RSocketConnectorConfigurer
second
=
mock
(
RSocketConnectorConfigurer
.
class
);
this
.
contextRunner
.
withBean
(
"firstRSocketConnectorConfigurer"
,
RSocketConnectorConfigurer
.
class
,
()
->
first
)
this
.
contextRunner
.
withBean
(
"first"
,
RSocketConnectorConfigurer
.
class
,
()
->
first
)
.
withBean
(
"secondRSocketConnectorConfigurer"
,
RSocketConnectorConfigurer
.
class
,
()
->
second
)
.
withBean
(
"second"
,
RSocketConnectorConfigurer
.
class
,
()
->
second
).
run
((
context
)
->
{
.
run
((
context
)
->
{
assertThat
(
context
).
getBeans
(
RSocketConnectorConfigurer
.
class
).
hasSize
(
2
);
assertThat
(
context
).
getBeans
(
RSocketConnectorConfigurer
.
class
).
hasSize
(
2
);
RSocketRequester
.
Builder
builder
=
context
.
getBean
(
RSocketRequester
.
Builder
.
class
);
RSocketRequester
.
Builder
builder
=
context
.
getBean
(
RSocketRequester
.
Builder
.
class
);
assertThat
(
builder
).
extracting
(
"rsocketConnectorConfigurers"
,
as
(
InstanceOfAssertFactories
.
LIST
))
assertThat
(
builder
).
extracting
(
"rsocketConnectorConfigurers"
,
as
(
InstanceOfAssertFactories
.
LIST
))
.
containsExactly
(
first
,
second
);
.
containsExactly
(
first
,
second
);
...
...
spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/rsocket.adoc
View file @
6b4efcce
...
@@ -73,7 +73,7 @@ Once the `RSocket` channel is established between server and client, any party c
...
@@ -73,7 +73,7 @@ Once the `RSocket` channel is established between server and client, any party c
As a server, you can get injected with an `RSocketRequester` instance on any handler method of an RSocket `@Controller`.
As a server, you can get injected with an `RSocketRequester` instance on any handler method of an RSocket `@Controller`.
As a client, you need to configure and establish an RSocket connection first.
As a client, you need to configure and establish an RSocket connection first.
Spring Boot auto-configures an `RSocketRequester.Builder` for such cases with the expected codecs.
Spring Boot auto-configures an `RSocketRequester.Builder` for such cases with the expected codecs
and apply any `RSocketConnectorConfigurer` bean
.
The `RSocketRequester.Builder` instance is a prototype bean, meaning each injection point will provide you with a new instance .
The `RSocketRequester.Builder` instance is a prototype bean, meaning each injection point will provide you with a new instance .
This is done on purpose since this builder is stateful and you shouldn't create requesters with different setups using the same instance.
This is done on purpose since this builder is stateful and you shouldn't create requesters with different setups using the same instance.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment