@Test public void orderedForward() { final List<String> order = new ArrayList<>(); handler = new ServerCallHandler<String, Integer>() { @Override public ServerCall.Listener<String> startCall( ServerCall<String, Integer> call, Metadata headers) { order.add("handler"); return listener; } }; ServerInterceptor interceptor1 = new ServerInterceptor() { @Override public <ReqT, RespT> ServerCall.Listener<ReqT> interceptCall( ServerCall<ReqT, RespT> call, Metadata headers, ServerCallHandler<ReqT, RespT> next) { order.add("i1"); return next.startCall(call, headers); } }; ServerInterceptor interceptor2 = new ServerInterceptor() { @Override public <ReqT, RespT> ServerCall.Listener<ReqT> interceptCall( ServerCall<ReqT, RespT> call, Metadata headers, ServerCallHandler<ReqT, RespT> next) { order.add("i2"); return next.startCall(call, headers); } }; ServerServiceDefinition serviceDefinition = ServerServiceDefinition.builder( new ServiceDescriptor("basic", flowMethod)) .addMethod(flowMethod, handler).build(); ServerServiceDefinition intercepted = ServerInterceptors.interceptForward( serviceDefinition, interceptor1, interceptor2); assertSame(listener, getSoleMethod(intercepted).getServerCallHandler().startCall(call, headers)); assertEquals(Arrays.asList("i1", "i2", "handler"), order); }
public static ServerServiceDefinition interceptForward(ServerServiceDefinition serviceDef, ServerInterceptor... interceptors) { return interceptForward(serviceDef, Arrays.asList(interceptors)); }
ServerInterceptors { public static ServerServiceDefinition interceptForward(ServerServiceDefinition serviceDef, ServerInterceptor... interceptors) { return interceptForward(serviceDef, Arrays.asList(interceptors)); } }
ServerInterceptors { public static ServerServiceDefinition interceptForward(ServerServiceDefinition serviceDef, ServerInterceptor... interceptors) { return interceptForward(serviceDef, Arrays.asList(interceptors)); } private  ServerInterceptors(); }
ServerInterceptors { public static ServerServiceDefinition interceptForward(ServerServiceDefinition serviceDef, ServerInterceptor... interceptors) { return interceptForward(serviceDef, Arrays.asList(interceptors)); } private  ServerInterceptors(); static ServerServiceDefinition interceptForward(ServerServiceDefinition serviceDef,
                                                         ServerInterceptor... interceptors); static ServerServiceDefinition interceptForward(BindableService bindableService,
      ServerInterceptor... interceptors); static ServerServiceDefinition interceptForward(
      ServerServiceDefinition serviceDef,
      List<? extends ServerInterceptor> interceptors); static ServerServiceDefinition interceptForward(
      BindableService bindableService,
      List<? extends ServerInterceptor> interceptors); static ServerServiceDefinition intercept(ServerServiceDefinition serviceDef,
                                                  ServerInterceptor... interceptors); static ServerServiceDefinition intercept(BindableService bindableService,
      ServerInterceptor... interceptors); static ServerServiceDefinition intercept(ServerServiceDefinition serviceDef,
                                                  List<? extends ServerInterceptor> interceptors); static ServerServiceDefinition intercept(BindableService bindableService,
      List<? extends ServerInterceptor> interceptors); @ExperimentalApi("https://github.com/grpc/grpc-java/issues/1712") static ServerServiceDefinition useInputStreamMessages(
      final ServerServiceDefinition serviceDef); @ExperimentalApi("https://github.com/grpc/grpc-java/issues/1712") static ServerServiceDefinition useMarshalledMessages(
      final ServerServiceDefinition serviceDef,
      final MethodDescriptor.Marshaller<T> marshaller); }
ServerInterceptors { public static ServerServiceDefinition interceptForward(ServerServiceDefinition serviceDef, ServerInterceptor... interceptors) { return interceptForward(serviceDef, Arrays.asList(interceptors)); } private  ServerInterceptors(); static ServerServiceDefinition interceptForward(ServerServiceDefinition serviceDef,
                                                         ServerInterceptor... interceptors); static ServerServiceDefinition interceptForward(BindableService bindableService,
      ServerInterceptor... interceptors); static ServerServiceDefinition interceptForward(
      ServerServiceDefinition serviceDef,
      List<? extends ServerInterceptor> interceptors); static ServerServiceDefinition interceptForward(
      BindableService bindableService,
      List<? extends ServerInterceptor> interceptors); static ServerServiceDefinition intercept(ServerServiceDefinition serviceDef,
                                                  ServerInterceptor... interceptors); static ServerServiceDefinition intercept(BindableService bindableService,
      ServerInterceptor... interceptors); static ServerServiceDefinition intercept(ServerServiceDefinition serviceDef,
                                                  List<? extends ServerInterceptor> interceptors); static ServerServiceDefinition intercept(BindableService bindableService,
      List<? extends ServerInterceptor> interceptors); @ExperimentalApi("https://github.com/grpc/grpc-java/issues/1712") static ServerServiceDefinition useInputStreamMessages(
      final ServerServiceDefinition serviceDef); @ExperimentalApi("https://github.com/grpc/grpc-java/issues/1712") static ServerServiceDefinition useMarshalledMessages(
      final ServerServiceDefinition serviceDef,
      final MethodDescriptor.Marshaller<T> marshaller);  }