Class AbstractServerHandler<CallMessage,​V,​CastMessage>

  • All Implemented Interfaces:
    Initializer, ServerHandler<CallMessage,​V,​CastMessage>

    public class AbstractServerHandler<CallMessage,​V,​CastMessage>
    extends java.lang.Object
    implements ServerHandler<CallMessage,​V,​CastMessage>
    A convenience class implementing the ServerHandler interface. All methods do nothing, except for handleCall which throws an UnsupportedOperationException.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      V handleCall​(ActorRef<?> from, java.lang.Object id, CallMessage m)
      Called to handle a synchronous request (one waiting for a response).
      void handleCast​(ActorRef<?> from, java.lang.Object id, CastMessage m)
      Called to handle an asynchronous request (one that does not for a response).
      void handleInfo​(java.lang.Object m)
      Called to handle any message sent to this actor that is neither a call nor a cast.
      void handleTimeout()
      Called whenever the timeout set with setTimeout or supplied at construction expires without any message received.
      void init()
      void terminate​(java.lang.Throwable cause)
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • AbstractServerHandler

        public AbstractServerHandler()
    • Method Detail

      • handleCall

        public V handleCall​(ActorRef<?> from,
                            java.lang.Object id,
                            CallMessage m)
                     throws SuspendExecution
        Called to handle a synchronous request (one waiting for a response).
        • If this method returns a non-null value, it will be sent back to the sender of the request wrapped by an ErrorResponseMessage; if the request was sent via Server.call (which is how it's usually done), this value will be returned by the call method.
        • If this method throws an exception, it will be sent back to the sender of the request wrapped by an ErrorResponseMessage; if the request was sent via Server.call, the exception will be thrown by the call method, possibly wrapped in a RuntimeException.
        • If this method returns null, then a reply is not immediately sent, and the call method will remain blocked until a reply is sent manually with reply or replyError.

        This implementation throws an UnsupportedOperationException.

        Specified by:
        handleCall in interface ServerHandler<CallMessage,​V,​CastMessage>
        Parameters:
        from - the sender of the request
        id - the request's unique id
        m - the request
        Returns:
        a value that will be sent as a response to the sender of the request.
        Throws:
        SuspendExecution
      • handleTimeout

        public void handleTimeout()
                           throws SuspendExecution
        Called whenever the timeout set with setTimeout or supplied at construction expires without any message received. The countdown is reset after every received message. This method will be triggered multiple times if a message is not received for a period of time longer than multiple timeout durations.

        This implementation does nothing

        Specified by:
        handleTimeout in interface ServerHandler<CallMessage,​V,​CastMessage>
        Throws:
        SuspendExecution