Class AbstractServerHandler<CallMessage,V,CastMessage>
- java.lang.Object
-
- co.paralleluniverse.actors.behaviors.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 theServerHandlerinterface. All methods do nothing, except forhandleCallwhich throws anUnsupportedOperationException.
-
-
Constructor Summary
Constructors Constructor Description AbstractServerHandler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description VhandleCall(ActorRef<?> from, java.lang.Object id, CallMessage m)Called to handle a synchronous request (one waiting for a response).voidhandleCast(ActorRef<?> from, java.lang.Object id, CastMessage m)Called to handle an asynchronous request (one that does not for a response).voidhandleInfo(java.lang.Object m)voidhandleTimeout()Called whenever the timeout set withsetTimeoutor supplied at construction expires without any message received.voidinit()voidterminate(java.lang.Throwable cause)
-
-
-
Method Detail
-
init
public void init() throws SuspendExecutionThis implementation does nothing
- Specified by:
initin interfaceInitializer- Throws:
SuspendExecution
-
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 viaServer.call(which is how it's usually done), this value will be returned by thecallmethod. - 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 viaServer.call, the exception will be thrown by thecallmethod, possibly wrapped in aRuntimeException. - If this method returns
null, then a reply is not immediately sent, and thecallmethod will remain blocked until a reply is sent manually withreplyorreplyError.
This implementation throws an
UnsupportedOperationException.- Specified by:
handleCallin interfaceServerHandler<CallMessage,V,CastMessage>- Parameters:
from- the sender of the requestid- the request's unique idm- the request- Returns:
- a value that will be sent as a response to the sender of the request.
- Throws:
SuspendExecution
- If this method returns a non-null value, it will be sent back to the sender of the request wrapped by an
-
handleCast
public void handleCast(ActorRef<?> from, java.lang.Object id, CastMessage m) throws SuspendExecution
Called to handle an asynchronous request (one that does not for a response).This implementation does nothing
- Specified by:
handleCastin interfaceServerHandler<CallMessage,V,CastMessage>- Parameters:
from- the sender of the requestid- the request's unique idm- the request- Throws:
SuspendExecution
-
handleInfo
public void handleInfo(java.lang.Object m) throws SuspendExecutionCalled to handle any message sent to this actor that is neither acallnor acast.This implementation does nothing
- Specified by:
handleInfoin interfaceServerHandler<CallMessage,V,CastMessage>- Parameters:
m- the message- Throws:
SuspendExecution
-
handleTimeout
public void handleTimeout() throws SuspendExecutionCalled whenever the timeout set withsetTimeoutor 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:
handleTimeoutin interfaceServerHandler<CallMessage,V,CastMessage>- Throws:
SuspendExecution
-
terminate
public void terminate(java.lang.Throwable cause) throws SuspendExecutionThis implementation does nothing
- Specified by:
terminatein interfaceInitializer- Throws:
SuspendExecution
-
-