@@ -127,79 +127,37 @@ configuration class, but it's still possible.
127
127
```` java
128
128
@Configuration
129
129
@GrpcClientBean (
130
- clazz = TestServiceGrpc . TestServiceBlockingStub . class,
130
+ clazz = TestServiceBlockingStub . class,
131
131
beanName = " blockingStub" ,
132
132
client = @GrpcClient (" test" )
133
133
)
134
- public static class YourCustomConfiguration {
134
+ @GrpcClientBean (
135
+ clazz = FactoryMethodAccessibleStub . class,
136
+ beanName = " accessibleStub" ,
137
+ client = @GrpcClient (" test" ))
138
+ public class YourCustomConfiguration {
135
139
136
140
@Bean
137
- FoobarService foobarService (@Autowired TestServiceGrpc .TestServiceBlockingStub blockingStub ) {
141
+ FooService fooServiceBean (@Autowired TestServiceGrpc .TestServiceBlockingStub blockingStub ) {
138
142
return new FoobarService (blockingStub);
139
143
}
140
- }
141
144
142
- @Service
143
- @AllArgsConsturtor
144
- public class FoobarService {
145
- private TestServiceBlockingStub blockingStub;
146
-
147
- public String receiveGreeting (String name ) {
148
- HelloRequest request = HelloRequest . newBuilder()
149
- .setName(name)
150
- .build();
151
- return blockingStub. sayHello(request). getMessage();
152
- }
153
- }
154
- ````
155
-
156
- ### GrpcClientBeans
157
-
158
- ` @GrpcClientBeans ` designed for registration multiple stubs to the spring context from single configuration class.
159
-
160
- ```` java
161
- @Configuration
162
- @GrpcClientBeans (value = {
163
- @GrpcClientBean (
164
- clazz = TestServiceGrpc . TestServiceBlockingStub . class,
165
- beanName = " blockingStub" ,
166
- client = @GrpcClient (" test" )),
167
- @GrpcClientBean (
168
- clazz = TestServiceGrpc . FactoryMethodAccessibleStub . class,
169
- beanName = " accessibleStub" ,
170
- client = @GrpcClient (" test" ))
171
- })
172
- public static class YourCustomConfiguration {
173
-
174
- @Bean
175
- FoobarService foobarService (@Autowired TestServiceGrpc .TestServiceBlockingStub blockingStub ,
176
- @Autowired TestServiceGrpc .FactoryMethodAccessibleStub accessibleStub ) {
177
- return new FoobarService (blockingStub, accessibleStub);
178
- }
179
145
}
180
146
181
147
@Service
182
148
@AllArgsConsturtor
183
- public class FoobarService {
149
+ public class BarService {
184
150
185
- private TestServiceBlockingStub blockingStub;
186
151
private FactoryMethodAccessibleStub accessibleStub;
187
152
188
153
public String receiveGreeting (String name ) {
189
154
HelloRequest request = HelloRequest . newBuilder()
190
155
.setName(name)
191
156
.build();
192
- return blockingStub . sayHello(request). getMessage();
157
+ return accessibleStub . sayHello(request). getMessage();
193
158
}
194
159
195
- public String receiveAnotherGreeting (String name ) {
196
- HelloRequest request = HelloRequest . newBuilder()
197
- .setName(name)
198
- .build();
199
- return accessibleStub. sayHi(request). getMessage();
200
- }
201
160
}
202
- ````
203
161
204
162
### GrpcChannelConfigurer
205
163
0 commit comments