@@ -158,34 +158,48 @@ The following examples demonstrate how to use annotations to create a global cli
158
158
159
159
```` java
160
160
@Configuration
161
- public class ThirdPartyInterceptorConfig {}
161
+ public class GlobalInterceptorConfiguration {
162
162
163
- @GrpcGlobalServerInterceptor
164
- LogGrpcInterceptor logServerInterceptor () {
163
+ @GrpcGlobalClientInterceptor
164
+ LogGrpcInterceptor logClientInterceptor () {
165
165
return new LogGrpcInterceptor ();
166
166
}
167
167
168
168
}
169
169
````
170
170
171
- This variant is very handy if you wish to add third-party interceptors to the global scope.
171
+ The following example demonstrates creation via ` GlobalClientInterceptorConfigurer `
172
+
173
+ ```` java
174
+ @Configuration
175
+ public class GlobalInterceptorConfiguration {
176
+
177
+ @Bean
178
+ GlobalClientInterceptorConfigurer globalClientInterceptorConfigurer () {
179
+ interceptors - > interceptors. add(new LogGrpcInterceptor ());
180
+ }
181
+
182
+ }
183
+ ````
184
+
185
+ These variant are very handy if you wish to add third-party interceptors to the global scope.
172
186
173
187
For your own interceptor implementations you can achieve the same result by adding the annotation to the class itself:
174
188
175
189
```` java
176
- @GrpcGlobalServerInterceptor
177
- public class LogGrpcInterceptor implements ServerInterceptor {
190
+ @GrpcGlobalClientInterceptor
191
+ public class LogGrpcInterceptor implements ClientInterceptor {
178
192
179
193
private static final Logger log = LoggerFactory . getLogger(LogGrpcInterceptor . class);
180
194
181
195
@Override
182
- public <ReqT , RespT > ServerCall . Listener <ReqT > interceptCall (
183
- ServerCall <ReqT , RespT > serverCall ,
184
- Metadata metadata ,
185
- ServerCallHandler< ReqT , RespT > serverCallHandler ) {
196
+ public <ReqT , RespT > ClientCall <ReqT , RespT > interceptCall (
197
+ final MethodDescriptor <ReqT , RespT > method ,
198
+ final CallOptions callOptions ,
199
+ final Channel next ) {
186
200
187
- log. info(serverCall . getMethodDescriptor() . getFullMethodName());
188
- return serverCallHandler . startCall(serverCall, metadata );
201
+ log. info(method . getFullMethodName());
202
+ return next . newCall(method, callOptions );
189
203
}
190
204
191
205
}
0 commit comments