|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.ninjacat.drama.Actor
public class Actor
Override this class to implement your actors. To receive messages from other actors declare methods that will receive messages. Receivers should be annotated withReceiverannotation and have following signature:public void onMessage(ActorRef sender, T message);message parameter could be of any type. If there is no receiver method for a specified message type, then message will be delivered tounhandled(ActorRef, Object)receiver. By default that receiver does nothing. Be aware that message receiver methods could be called on any thread. Each other message could be received on different thread. ActorRef parameter to a receiver method can be null. Messages should be immutable. It is also recommended that message classes be declared as final. Declaring receiver for a particular type and sending messages of descendant types is supported, but not recommended as it is inefficient and requires additional memory.
| Field Summary | |
|---|---|
protected Collection<Method> |
allReceiverMethods
|
protected Map<Class<?>,Method> |
receivers
|
protected Set<Class<?>> |
unsupportedMessageClasses
|
| Constructor Summary | |
|---|---|
Actor()
|
|
| Method Summary | |
|---|---|
boolean |
equals(Object o)
|
ActorSystem |
getActorSystem()
|
protected Semaphore |
getExecutionLock()
|
String |
getName()
|
ActorRef |
getSelf()
|
int |
hashCode()
|
protected void |
onShutdown()
This method is called after actor is deleted. |
protected void |
onStartup()
This method is called when new actor is created, before any message could be delivered to this actor. |
void |
onSystemMessage(ActorRef sender,
SystemMessage message)
|
void |
run()
Performs message dispatching for this actor's inbox |
String |
toString()
|
protected void |
unhandled(ActorRef sender,
Object message)
This method is called when no other receivers for message is found. |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected final Collection<Method> allReceiverMethods
protected final Map<Class<?>,Method> receivers
protected final Set<Class<?>> unsupportedMessageClasses
| Constructor Detail |
|---|
public Actor()
| Method Detail |
|---|
public String getName()
ActorSystempublic ActorRef getSelf()
public ActorSystem getActorSystem()
ActorSystempublic final void run()
run in interface Runnable
public final void onSystemMessage(ActorRef sender,
SystemMessage message)
public boolean equals(Object o)
equals in class Objectpublic int hashCode()
hashCode in class Objectpublic String toString()
toString in class Objectprotected Semaphore getExecutionLock()
protected void onStartup()
This method is called when new actor is created, before any message could be delivered to this actor. Default implementation does nothing.
protected void onShutdown()
This method is called after actor is deleted. No messages will be delivered to this actor after this method is called. Default implementation does nothing. Usually actor is deleted by callingActorRef.stop(), but it may as well be deleted when itsActorSystemis terminating.
protected void unhandled(ActorRef sender,
Object message)
This method is called when no other receivers for message is found.
sender - ActorRef which sent the messagemessage - Message itself
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||