Class ForwardingServerCallListener<ReqT>
- java.lang.Object
-
- io.grpc.ServerCall.Listener<ReqT>
-
- io.grpc.ForwardingServerCallListener<ReqT>
-
- Direct Known Subclasses:
ForwardingServerCallListener.SimpleForwardingServerCallListener
public abstract class ForwardingServerCallListener<ReqT> extends ServerCall.Listener<ReqT>
AServerCall.Listenerwhich forwards all of its methods to anotherServerCall.Listenerof matching parameterized types.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classForwardingServerCallListener.SimpleForwardingServerCallListener<ReqT>A simplified version ofForwardingServerCallListenerwhere subclasses can pass in aServerCall.Listeneras the delegate.
-
Constructor Summary
Constructors Constructor Description ForwardingServerCallListener()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract ServerCall.Listener<ReqT>delegate()Returns the delegatedServerCall.Listener.voidonCancel()The call was cancelled and the server is encouraged to abort processing to save resources, since the client will not process any further messages.voidonComplete()The call is considered complete andServerCall.Listener.onCancel()is guaranteed not to be called.voidonEvent(Object event)A custom event has been triggered by the call.voidonHalfClose()The client completed all message sending.voidonMessage(ReqT message)A request message has been received.voidonReady()This indicates that the call may now be capable of sending additional messages (viaServerCall.sendMessage(RespT)) without requiring excessive buffering internally.StringtoString()
-
-
-
Method Detail
-
delegate
protected abstract ServerCall.Listener<ReqT> delegate()
Returns the delegatedServerCall.Listener.
-
onMessage
public void onMessage(ReqT message)
Description copied from class:ServerCall.ListenerA request message has been received. For streaming calls, there may be zero or more request messages.- Overrides:
onMessagein classServerCall.Listener<ReqT>- Parameters:
message- a received request message.
-
onHalfClose
public void onHalfClose()
Description copied from class:ServerCall.ListenerThe client completed all message sending. However, the call may still be cancelled.- Overrides:
onHalfClosein classServerCall.Listener<ReqT>
-
onCancel
public void onCancel()
Description copied from class:ServerCall.ListenerThe call was cancelled and the server is encouraged to abort processing to save resources, since the client will not process any further messages. Cancellations can be caused by timeouts, explicit cancellation by the client, network errors, etc.There will be no further callbacks for the call.
- Overrides:
onCancelin classServerCall.Listener<ReqT>
-
onComplete
public void onComplete()
Description copied from class:ServerCall.ListenerThe call is considered complete andServerCall.Listener.onCancel()is guaranteed not to be called. However, the client is not guaranteed to have received all messages.There will be no further callbacks for the call.
- Overrides:
onCompletein classServerCall.Listener<ReqT>
-
onReady
public void onReady()
Description copied from class:ServerCall.ListenerThis indicates that the call may now be capable of sending additional messages (viaServerCall.sendMessage(RespT)) without requiring excessive buffering internally. This event is just a suggestion and the application is free to ignore it, however doing so may result in excessive buffering within the call.Because there is a processing delay to deliver this notification, it is possible for concurrent writes to cause
isReady() == falsewithin this callback. Handle "spurious" notifications by checkingisReady()'s current value instead of assuming it is nowtrue. IfisReady() == falsethe normal expectations apply, so there would be anotheronReady()callback.- Overrides:
onReadyin classServerCall.Listener<ReqT>
-
onEvent
public void onEvent(Object event)
Description copied from class:ServerCall.ListenerA custom event has been triggered by the call.This callback is guaranteed to run on the call's executor, serialized with other callbacks (like
ServerCall.Listener.onMessage(ReqT),ServerCall.Listener.onHalfClose()). This means the implementation does not need internal synchronization to access call-specific state.Deadlock avoidance: In some transports (such as Binder transport) or when using a direct executor, this callback may be invoked while transport-level locks are held. Implementations should avoid acquiring locks that are held by callers of
ServerCallmethods (such asServerCall.triggerEvent(java.lang.Object),ServerCall.close(io.grpc.Status, io.grpc.Metadata), orServerCall.request(int)), and should avoid callingServerCallmethods while holding application-level locks, as this can lead to deadlocks from lock-order inversion.- Overrides:
onEventin classServerCall.Listener<ReqT>- Parameters:
event- the triggered event.
-
-