|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectaa.core.ActorThread
This class describes an actor thread. An actor thread works with an Actor (behavior) class.
History
Field Summary | |
private Actor |
m_actorBehavior
|
private ActorName |
m_anActorName
|
private boolean |
m_bDestroy
|
private boolean |
m_bMigrate
|
protected boolean |
m_bRetire
|
private boolean |
m_bSuspend
|
private java.lang.Class |
m_classActor
|
private java.util.Hashtable |
m_htMethods
|
private java.net.InetAddress |
m_iaDestHost
|
private Platform |
m_pPlatform
|
private Queue |
m_qMsgQueue
|
private java.lang.String |
m_strClassName
|
private java.lang.String |
m_strLastErrorMessage
|
Constructor Summary | |
ActorThread(ActorName p_anActor,
boolean p_bCreate)
Creates an actor thread. |
Method Summary | |
protected void |
becomeActor(java.lang.String p_strClassName,
java.lang.Object[] p_objaArgs)
Change the behavior of this actor. |
protected java.lang.Object |
callMessage(ActorName p_anReceiver,
java.lang.String p_strMethod,
java.lang.Object[] p_objaArgs)
Sends an out-going message, and wait the response. |
protected ActorName |
createActor(java.lang.String p_strClassName,
java.lang.Object[] p_objaArgs)
Creates a new actor. |
private void |
createMethodTable()
Creates a method table. |
protected ActorName |
createRemoteActor(java.lang.String p_strHost,
java.lang.String p_strClassName,
java.lang.Object[] p_objaArgs)
Create a new actor on a remote system. |
protected void |
deliverMessage(ActorMessage p_amMsg)
Inserts a message into the mail queue of this actor, and wakes up sleeping actors. |
protected void |
destroyActor()
Destroys this actor thread. |
private java.lang.reflect.Constructor |
findConstructor(java.lang.Class p_classActor,
java.lang.Object[] p_objaArgs)
Finds a proper constructor. |
protected java.lang.String |
getActorClassName()
Returns the class name of this actor. |
ActorName |
getActorName()
Returns the name of this actor. |
protected ActorName |
getDefaultDirectoryManager()
Returns the actor name of the default Direcotry Manager actor. |
protected ActorName |
getDefaultDirectoryManager(java.lang.String p_strHostName)
Returns The actor name of the default Direcotry Manager actor on the specified host. |
protected java.lang.String |
getLastErrorMessage()
Returns the last error message of asynchronous operations. |
protected void |
initAfterMigration()
Re-initialize after actor migration. |
protected void |
kill()
Kills this actor. |
protected void |
migrateActor(java.net.InetAddress p_iaDestHost)
Initializes the migration of this actor. |
protected void |
processMessage(ActorMessage p_amMsg)
Processes a communication message. |
protected void |
resume()
Resumes this actor. |
void |
run()
Executes the main loop of this thread. |
protected void |
sendMessage(ActorName p_anReceiver,
java.lang.String p_strMethod,
java.lang.Object[] p_objaArgs)
Sends an out-going message to the sepcified actor. |
protected void |
setBehavior(java.lang.String p_strActorClass,
java.lang.Object[] p_objaArgs,
Queue p_qMsgQueue)
Sets the behavior of this actor thread. |
protected void |
setLastErrorMessage(java.lang.String p_strMsg)
Sets the error message of an asynchronous operation. |
protected void |
suspend()
Suspends this actor. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private ActorName m_anActorName
private java.lang.Class m_classActor
private java.lang.String m_strClassName
private Actor m_actorBehavior
private java.lang.String m_strLastErrorMessage
private java.net.InetAddress m_iaDestHost
private boolean m_bSuspend
private boolean m_bMigrate
private boolean m_bDestroy
protected boolean m_bRetire
private Queue m_qMsgQueue
private transient java.util.Hashtable m_htMethods
private transient Platform m_pPlatform
Constructor Detail |
public ActorThread(ActorName p_anActor, boolean p_bCreate)
p_anActor
- an actor name of this actor.Method Detail |
private java.lang.reflect.Constructor findConstructor(java.lang.Class p_classActor, java.lang.Object[] p_objaArgs) throws java.lang.NoSuchMethodException
setBehavior
method.
p_classActor
- the class of an actor to be created.p_objaArgs
- arguments of the constructor of the actor.
java.lang.NoSuchMethodException
- it occurs when the construct cannot be found.private void createMethodTable()
setBehavior
or
initAfterMigration
.
protected void setBehavior(java.lang.String p_strActorClass, java.lang.Object[] p_objaArgs, Queue p_qMsgQueue) throws ActorException
p_strActorClass
- the behavior class of an actor to be created.p_objaArgs
- arguments of the constructor of the actor behavior.p_qMsgQueue
- reference to a message queue to be used in this actor.
CreateActorException
- it occurs when actor creation fails.
ActorException
protected void initAfterMigration()
public void run()
run
in interface java.lang.Runnable
protected void processMessage(ActorMessage p_amMsg)
protected void deliverMessage(ActorMessage p_amMsg)
p_amMsg
- an actor communication message.protected void suspend()
protected void resume()
protected void kill()
public ActorName getActorName()
protected java.lang.String getActorClassName()
protected void setLastErrorMessage(java.lang.String p_strMsg)
p_strMsg
- the error message of an asynchronous operation.protected java.lang.String getLastErrorMessage()
protected ActorName getDefaultDirectoryManager()
protected ActorName getDefaultDirectoryManager(java.lang.String p_strHostName)
p_strHostName
- the specified host.
protected ActorName createActor(java.lang.String p_strClassName, java.lang.Object[] p_objaArgs) throws CreateActorException
p_strClassName
- the class name of a new actor.p_objaArgs
- an array of arguments of a new actor.
CreateActorException
protected ActorName createRemoteActor(java.lang.String p_strHost, java.lang.String p_strClassName, java.lang.Object[] p_objaArgs) throws CreateActorException
p_strHost
- the host name of a new actor.p_strClassName
- the class name of a new actor.p_objaArgs
- an array of arguments of a new actor.
CreateActorException
protected void becomeActor(java.lang.String p_strClassName, java.lang.Object[] p_objaArgs) throws BecomeActorException
p_strClassName
- the class name of a new actor.p_objaArgs
- an array of arguments of a new actor.
BecomeActorException
protected void sendMessage(ActorName p_anReceiver, java.lang.String p_strMethod, java.lang.Object[] p_objaArgs)
p_anReceiver
- the name of the receiver actor of this message.p_strMethod
- a message (or method) name (or type).p_objaArgs
- a set of argument objects.protected java.lang.Object callMessage(ActorName p_anReceiver, java.lang.String p_strMethod, java.lang.Object[] p_objaArgs) throws CommunicationException
p_anReceiver
- the name of the receiver actor of this message.p_strMethod
- a message (or method) name (or type).p_objaArgs
- a set of argument objects.
CommunicationException
- if an error happens
while synchoronous message is processed.protected void migrateActor(java.net.InetAddress p_iaDestHost)
p_iaDestHost
- the Inet address of the destination host
where this actor migrate.protected void destroyActor()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |