Java 类io.grpc.ForwardingServerCallListener.SimpleForwardingServerCallListener 实例源码

项目:grpc-spring-security-demo    文件:SecurityContextPersistenceInterceptor.java   
@Override
public <ReqT, RespT> ServerCall.Listener<ReqT> interceptCall(
        ServerCall<ReqT, RespT> call,
        Metadata headers,
        ServerCallHandler<ReqT, RespT> next) {
    ServerCall.Listener<ReqT> delegate = next.startCall(call, headers);
    return new SimpleForwardingServerCallListener<ReqT>(delegate) {
        @Override
        public void onComplete() {
            try {
                super.onComplete();
            } finally {
                SecurityContextHolder.clearContext();
                log.debug("SecurityContextHolder now cleared, as request processing completed");
            }
        }

        @Override
        public void onCancel() {
            try {
                super.onCancel();
            } finally {
                SecurityContextHolder.clearContext();
                log.debug("SecurityContextHolder now cleared, as request processing was canceled");
            }
        }
    };
}
项目:grpc-java    文件:ForwardingServerCallListenerTest.java   
@Before
public void setUp() {
  MockitoAnnotations.initMocks(this);
  forwarder = new SimpleForwardingServerCallListener<Void>(serverCallListener) {};
}