Class StateCheckingResponseObserver<V>
- java.lang.Object
-
- com.google.api.gax.rpc.StateCheckingResponseObserver<V>
-
- All Implemented Interfaces:
ResponseObserver<V>
public abstract class StateCheckingResponseObserver<V> extends java.lang.Object implements ResponseObserver<V>
Base implementation ofResponseObserverthat performs state sanity checks.
-
-
Constructor Summary
Constructors Constructor Description StateCheckingResponseObserver()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidonComplete()Receives a notification of successful stream completion.protected abstract voidonCompleteImpl()voidonError(java.lang.Throwable t)Receives a terminating error from the stream.protected abstract voidonErrorImpl(java.lang.Throwable t)voidonResponse(V response)Receives a value from the stream.protected abstract voidonResponseImpl(V response)voidonStart(StreamController controller)Called before the stream is started.protected abstract voidonStartImpl(StreamController controller)
-
-
-
Method Detail
-
onStart
public final void onStart(StreamController controller)
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
public final void onResponse(V response)
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
public final void onError(java.lang.Throwable t)
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
protected abstract void onStartImpl(StreamController controller)
- See Also:
onStart(StreamController)
-
onResponseImpl
protected abstract void onResponseImpl(V response)
- See Also:
onResponse(Object)
-
onErrorImpl
protected abstract void onErrorImpl(java.lang.Throwable t)
- See Also:
onErrorImpl(Throwable)
-
onCompleteImpl
protected abstract void onCompleteImpl()
- See Also:
onComplete()
-
-