Skip to content

Commit 6f9d7a3

Browse files
author
Alexander Furer
committed
sample for #117
1 parent ad190b1 commit 6f9d7a3

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

grpc-spring-boot-starter-demo/src/test/java/org/lognet/springboot/grpc/OrderedInterceptorsTest.java

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,34 @@ protected void beforeGreeting() {
5353

5454
@Override
5555
protected void afterGreeting() {
56-
assertThat(calledInterceptors).containsExactly(1, 2, 3, 4,5, 10, 100);
56+
assertThat(calledInterceptors).containsExactly(1, 2, 3, 4,5,6, 10, 100);
5757
}
5858

5959

6060

6161
@Configuration
6262
public static class TheConfiguration {
6363

64+
65+
@Bean
66+
@GRpcGlobalInterceptor
67+
public ServerInterceptor mySixthInterceptor(){
68+
return new MySixthInterceptor();
69+
}
70+
71+
class MySixthInterceptor implements ServerInterceptor,Ordered {
72+
@Override
73+
public <ReqT, RespT> Listener<ReqT> interceptCall(ServerCall<ReqT, RespT> call, Metadata headers, ServerCallHandler<ReqT, RespT> next) {
74+
calledInterceptors.add(6);
75+
return next.startCall(call, headers);
76+
}
77+
78+
@Override
79+
public int getOrder() {
80+
return 6;
81+
}
82+
}
83+
6484
@GRpcGlobalInterceptor
6585
@Order(2)
6686
static class SecondInterceptor implements ServerInterceptor {

0 commit comments

Comments
 (0)