Class StateCheckingResponseObserver<V>
- All Implemented Interfaces:
ResponseObserver<V>
ResponseObserver that performs state sanity checks.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal voidReceives a notification of successful stream completion.protected abstract voidfinal voidReceives a terminating error from the stream.protected abstract voidfinal voidonResponse(V response) Receives a value from the stream.protected abstract voidonResponseImpl(V response) final voidonStart(StreamController controller) Called before the stream is started.protected abstract voidonStartImpl(StreamController controller)
-
Constructor Details
-
StateCheckingResponseObserver
public StateCheckingResponseObserver()
-
-
Method Details
-
onStart
Called before the stream is started. This must be invoked synchronously on the same thread that calledServerStreamingCallable.call(Object, ResponseObserver, ApiCallContext)Allows for disabling flow control and early stream termination via
StreamController.This implementation simply delegates to
onStartImpl(StreamController)after ensuring consistent state.- Specified by:
onStartin interfaceResponseObserver<V>- Parameters:
controller- The controller for the stream.
-
onResponse
Receives a value from the stream.Can be called many times but is never called after
ResponseObserver.onError(Throwable)orResponseObserver.onComplete()are called.Clients may may receive 0 or more onResponse callbacks.
If an exception is thrown by an implementation the caller will terminate the stream by calling
ResponseObserver.onError(Throwable)with the caught exception as the cause.This implementation simply delegates to
onResponseImpl(Object)after ensuring consistent state.- Specified by:
onResponsein interfaceResponseObserver<V>- Parameters:
response- the value passed to the stream
-
onComplete
public final void onComplete()Receives a notification of successful stream completion.May only be called once, and if called, it must be the last method called. In particular, if an exception is thrown by an implementation of
onComplete, no further calls to any method are allowed.This implementation simply delegates to
onCompleteImpl()after ensuring consistent state.- Specified by:
onCompletein interfaceResponseObserver<V>
-
onError
Receives a terminating error from the stream.May only be called once, and if called, it must be the last method called. In particular, if an exception is thrown by an implementation of
onError, no further calls to any method are allowed.This implementation simply delegates to
onErrorImpl(Throwable)after ensuring consistent state.- Specified by:
onErrorin interfaceResponseObserver<V>- Parameters:
t- the error occurred on the stream
-
onStartImpl
- See Also:
-
onResponseImpl
- See Also:
-
onErrorImpl
- See Also:
-
onCompleteImpl
protected abstract void onCompleteImpl()- See Also:
-