|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.actorsguildframework.Actor
@Bean(threadSafe=true) public abstract class Actor
Actor is the class that all actors need to implement.
You can not create an actor using the 'new' operator. Doing so would throw an exception.
Instead, Agent.create(Class) must be used to create a new instance. Agent returns a
proxy for the actual Actor which must be used to access the actor. Most of the features of the
Actor's Guild framework are being done by this invisible proxy.
An actor does not need a constructor, but you can define one without arguments. Anything you write in it will be visible in all normal messages, but not in multi-threaded messages (you need to synchronize manually for them).
For the Actor's initialization you implement bean properties, preferably with the Prop
annotation which will ensure that they are thread-safe (the property implementations offered
by most IDEs are not!). Properties can be initialized upon creation of the Actor in the
Agent.create(Class, Props) invocation. After create completed setting the
properties, the Agent will invoke the Actor's Initializer method. Implement one for any
additional initialization work.
Every actor should define one or more methods to receive messages. These methods must be
annotated with Message, and follow the rules given in the documentation of @Message.
All the actual work is being done by the message implementations.
By default, an actor receives only one message at a time. Thus is it operated single-threaded,
and does not need to take care of such things as synchronization. In some cases, especially
to integrate external interfaces and code, it is useful or even required for an actor to
process several messages simultaneously. This can be declared using the Model
and Usage annotation.
An actor can have public methods that are not @Message. However, you are responsible for the synchronization of such methods, otherwise they will not work correctly.
Agent,
Agent.create(Class, Props)| Constructor Summary | |
|---|---|
Actor()
The default constructor for all Actors. |
|
| Method Summary | ||
|---|---|---|
Agent |
getAgent()
Returns the Agent of this Actor. |
|
static Agent |
getCurrentAgent()
Returns the current thread's agent, if the current thread is a thread processing an actor message. |
|
ImmediateResult<Void> |
noResult()
Helper method to create a new ImmediateResult instance for methods that have no result. |
|
|
result(T value)
Helper method to create a new ImmediateResult instance. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Actor()
Agent.create(Class).
ActorRuntimeException - if the instantiated actor is not a proxy class| Method Detail |
|---|
public final Agent getAgent()
getCurrentAgent()public <T> ImmediateResult<T> result(T value)
T - the type of resultvalue - the result value
public ImmediateResult<Void> noResult()
public static Agent getCurrentAgent()
getAgent()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||