PaP
Class ApplicationActor

java.lang.Object
  |
  +--PaP.Actor
        |
        +--PaP.ApplicationActor
All Implemented Interfaces:
ActorInterface, ControlInterface, java.rmi.Remote, java.io.Serializable
Direct Known Subclasses:
ActorDummy, ChatClient, ChatServer, FTClient, LoginAgent, UserAgent, Watcher, WatchServer, WatchServerNew, VisitorAgent

public abstract class ApplicationActor
extends Actor
implements java.io.Serializable

Superclass for all application actors, interfaces PaP suppoer functions.

See Also:
Serialized Form

Fields inherited from class PaP.Actor
bf, context, fh
 
Constructor Summary
ApplicationActor()
          Creates a new ApplicationActor and invokes the superclass' constructor.
 
Method Summary
 RequestResult actorBehaviourPlugIn(java.lang.String pRoleId)
          Sends a request to the actor's Director to change the actor's behaviour by plugging in the specified Role.
 RequestResult actorBehaviourPlugOut()
          Sends a request to the actor's Director to change the actor's behaviour by plugging out the current role.
 RequestResult actorCapabilities(int opType, CapabilitySet caps)
          Sends a request to the actor's Director to change the actor's set of capabilities.
 RequestResult actorChangeBehaviour(java.lang.String pRoleId, java.lang.String[] pars)
          Sends a request to the actor's Director to change the actor's behaviour by plugging in the specified Role.
 RequestResult actorEntry(RequestPars pRP)
          Common entry point of ApplicationActors to invoke some activity from the outside.
 RequestResult actorPlay(GAI ident)
          Sends a request to the specified actor to perform ActorPlay.
 RequestResult actorPlugIn(ActorPlugInReq request)
          Sends a request to the actor's Director containing the specified ActorPlugInRequest.
 RequestResult actorPlugOut(RoleSession pRS)
          Sends an ActorPlugOut request to the actor's Director.
 RequestPars anyOtherRequestType(RequestPars pRP)
          This method is called every time the actorEntry() method receives a type of request that is not to be forwarded to the actor by calling applicationActorEntry().
abstract  RequestResult applicationActorEntry(RequestPars pRP)
          Defines the common entry point for every actor by declaring this method abstract.
private  RequestResult callActorChangeBehaviour(ActorPlugInReq request, java.lang.String[] pars)
          Common method used by all methods concerned with changing the actor's behaviour.
 RequestResult control(java.lang.String command, java.lang.String[] pars)
          Common entry point to invoke an actor's functionality.
private  void dbg(java.lang.String dbg)
          Sends debug information to this actor's BaseFrame window, which is an interactive debug client window for several entities.
 void init(ActorContext pAC)
          Initializes this actor by setting its actorcontext through a call to the superclass' init().
 RequestResult loginUser(LoginRequest request)
          Sends the specified LoginRequest to the Director.
 RequestResult logoutUser(java.lang.String username)
          Sends a LogoutRequest to the Director for the user with the specified username.
 RequestResult playChangesPlugIn(Play pPlay)
          Sends a request to the actor's Director to plugout the current version of the specified play and plugin same play againg.
 RequestResult playPlugIn(Play pPlay)
          Sends a request to the Director to plugin the specified Play.
 RequestResult playPlugOut(java.lang.String pPlayId, java.lang.String pPlayVer)
          Sends a request to the actor's Director to plugout the specified version of the specified Play.
private  RequestResult requestToActor(RequestPars pRP)
          Common method for most types of requests from actors to directors.
 RequestResult roleFigurePlugIn(RoleFigureRequest request)
          Sends the specified RoleFigureRequest to the Director.
 RequestResult roleFigurePlugOut(RoleFigureRequest request)
          Sends the specified RoleFigureRequest to the Director.
 RequestResult roleSessionAction(RoleSession pRS, ApplicationMessage pMessage)
          Sends the specified ApplicationMessage to another actor by using the specified RoleSession.
 RequestResult sessionResume(RequestPars rpars)
          Sends the specified request of type SessionResume to the specified actor by calling requestToActor().
 RequestResult sessionSuspend(GAI actorGAI)
          Sends a SessionSuspend request to the actor with the specified GAI.
 RequestResult sessionUpdate(Session session)
          Sends the specified Session-object to the Director in the form of a SessionUpdate request.
 RequestResult subscribeCancel(java.lang.String subscribeID)
          Sends a request to the actor's Director that this actor wishes to cancel its subscription on report on events taking place in this PaP domain.
 RequestResult subscribeReport(java.lang.String[] subscribeReport)
          This method is called by the Director every time the actor receives a new report from the SubscribeRequest service.
 RequestResult subscribeRequest(SubscribeRequest request)
          Sends a request to the actor's Director that this actor wishes to subscribe for reports on when a set of events are taking place in this PaP domain.
 
Methods inherited from class PaP.Actor
findRoleSession, getGAI, start, status, term
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Constructor Detail

ApplicationActor

public ApplicationActor()
Creates a new ApplicationActor and invokes the superclass' constructor.
Method Detail

actorBehaviourPlugIn

public RequestResult actorBehaviourPlugIn(java.lang.String pRoleId)
                                   throws java.lang.Exception
Sends a request to the actor's Director to change the actor's behaviour by plugging in the specified Role. This is done by calling callActorChangeBehaviour().
Parameters:
pRoleId - Identifies the new role to be assigned to the actor.
Returns:
RequestResult indicating wether the request was handled successfully or not.

actorBehaviourPlugOut

public RequestResult actorBehaviourPlugOut()
                                    throws java.lang.Exception
Sends a request to the actor's Director to change the actor's behaviour by plugging out the current role. What actually happens is that a predefined 'dummy' role is plugged in. This is done by calling callActorChangeBehaviour().
Parameters:
pRoleId - The new Role to be assigned to the actor.
Returns:
RequestResult indicating wether the request was handled successfully or not.

actorCapabilities

public RequestResult actorCapabilities(int opType,
                                       CapabilitySet caps)
                                throws java.lang.Exception
Sends a request to the actor's Director to change the actor's set of capabilities.
Parameters:
opType - Specifies 'Set', 'Add' or 'Remove' as operation type.
caps - The set of capabilities to add, set or remove.
Returns:
RequestResult indicating wether the request was handled successfully or not.

actorChangeBehaviour

public RequestResult actorChangeBehaviour(java.lang.String pRoleId,
                                          java.lang.String[] pars)
                                   throws java.lang.Exception
Sends a request to the actor's Director to change the actor's behaviour by plugging in the specified Role. The specified set of parameters will be withdrawn from the existing actor and given to the upgraded actor. This is done by calling callActorChangeBehaviour().
Parameters:
pRoleId - Identifies the new role to be assigned to the actor.
pars - The data withdrawn from the existing to the upgraded actor.
Returns:
RequestResult indicating wether the request was handled successfully or not.

actorEntry

public RequestResult actorEntry(RequestPars pRP)
                         throws java.lang.Exception
Common entry point of ApplicationActors to invoke some activity from the outside.
Parameters:
pRP - Parameters for the activity this actorEntry will attempt to carry out.
Returns:
RequestResult indicating wether the request was handled successfully or not.
Throws:
java.lang.Exception -  

actorPlay

public RequestResult actorPlay(GAI ident)
                        throws java.lang.Exception
Sends a request to the specified actor to perform ActorPlay.
Parameters:
ident - The GAI of the actor to request for ActorPlay.
Returns:
RequestResult indicating wether the request was handled successfully or not.

actorPlugIn

public RequestResult actorPlugIn(ActorPlugInReq request)
                          throws java.lang.Exception
Sends a request to the actor's Director containing the specified ActorPlugInRequest. The result of this request is either:
1. A new Actor is created.
The Director sends a request to the correct PAS that will create an instance and the correct behaviour must be loaded. Then the behaviour for the actor is downloaded (i.e. actor behaviour plugin).
2. An existing instance may be applied.

For both 1. and 2. a RoleSession is returned in the RequestResult to the initiator.
Parameters:
request - ActorPlugInReq containing application specific parameters for the request.
Returns:
RequestResult indicating wether the request was served successfully or not.

actorPlugOut

public RequestResult actorPlugOut(RoleSession pRS)
                           throws java.lang.Exception
Sends an ActorPlugOut request to the actor's Director. The result of this request is either:
1. An existing actor is plugged out. The actor is removed from the Director's playing base and the actor instance is removed from the PAS at where it is located.

2. The actor shall not be removed (because of conditions specified). The RoleSession registry is removed at actors and Director.
Parameters:
pRS - This RoleSession specifies which actor to be plugged out.
Returns:
RequestResult indicating wether the request was handled successfully or not.

anyOtherRequestType

public RequestPars anyOtherRequestType(RequestPars pRP)
                                throws java.lang.Exception
This method is called every time the actorEntry() method receives a type of request that is not to be forwarded to the actor by calling applicationActorEntry(). The actor can receive these requests by overloading this method. This way the actor has the possibility to control any received request.
Parameters:
pRP - The received request.
Returns:
The received RequestPars if the request is to be forwarded to Director and handled there, else it returns null.
Throws:
Exception. -  

applicationActorEntry

public abstract RequestResult applicationActorEntry(RequestPars pRP)
                                             throws java.lang.Exception
Defines the common entry point for every actor by declaring this method abstract. Allmost all request received through actorEntry() is forwarded to the actor by calling this method so every actor must implement this method to receive any requests. This is the ONLY entry to the application part of actors in addition to subscribeReport() and anyOtherRequestType().
Parameters:
rp - Parameters for the activity this actorEntry will attempt to carry out.
Returns:
RequestResult indicating wether the request was handled successfully or not.

callActorChangeBehaviour

private RequestResult callActorChangeBehaviour(ActorPlugInReq request,
                                               java.lang.String[] pars)
                                        throws java.lang.Exception
Common method used by all methods concerned with changing the actor's behaviour. It builds a request and adds the specifed parameters, and then sends it to the actor's Director.
Parameters:
request - An ActorPlugInReq containing configuration information regarding the request.
pars - Set of information to follow an ActorChangeBehaviour request.
Returns:
RequestResult indicating wether the request was handled successfully or not.

control

public RequestResult control(java.lang.String command,
                             java.lang.String[] pars)
                      throws java.lang.Exception
Common entry point to invoke an actor's functionality. It is up to the actor to decide which operations to perform depending on the specified command. Usually it calls the appropriate method in this class. This method can be triggered by input from the actor's baseframe.
Parameters:
command - Name of the command to perform.
args - Additional arguments for the specified command.
Returns:
RequestResult indicating wether the command was completed successfully or not.
Throws:
Exception. -  

init

public void init(ActorContext pAC)
Initializes this actor by setting its actorcontext through a call to the superclass' init(). This method is provided to keep the constructor empty.
Overrides:
init in class Actor
Parameters:
pAC - The actor's ActorContext.

loginUser

public RequestResult loginUser(LoginRequest request)
                        throws java.lang.Exception
Sends the specified LoginRequest to the Director. The request should contain the username and password of the user trying to login and wether the user want to resume a stored session or create a new one.
Parameters:
request - The LoginRequest to be sent.
Returns:
RequestResult indicating wether the request was handled successfully or not.
Throws:
java.lang.Exception - if something goes wrong.

logoutUser

public RequestResult logoutUser(java.lang.String username)
                         throws java.lang.Exception
Sends a LogoutRequest to the Director for the user with the specified username.
Parameters:
username - The username of the user wanting to logout.
Returns:
RequestResult indicating wether the request was handled successfully or not.
Throws:
java.lang.Exception - if something goes wrong.

playChangesPlugIn

public RequestResult playChangesPlugIn(Play pPlay)
                                throws java.lang.Exception
Sends a request to the actor's Director to plugout the current version of the specified play and plugin same play againg. This is usually used to update a Play.
Parameters:
pPlay - The play to be plugged in.
Returns:
RequestResult indicating wether the request was served successfully or not.

playPlugIn

public RequestResult playPlugIn(Play pPlay)
                         throws java.lang.Exception
Sends a request to the Director to plugin the specified Play. If the request is successful then the Play is put in the Director's repertoire base and manuscript base.
Parameters:
pPlay - The play to be plugged in.
Returns:
RequestResult indicating success or failure of the handling the request.

playPlugOut

public RequestResult playPlugOut(java.lang.String pPlayId,
                                 java.lang.String pPlayVer)
                          throws java.lang.Exception
Sends a request to the actor's Director to plugout the specified version of the specified Play.
Parameters:
pPlayId - Specifies the Play to be plugged out.
pPlayVer - Specifies which version of the Play to be plugged out. A null value means that all versions of the Play should be plugged out.
Returns:
RequestResult indicating if the request was served successfully or not.

roleFigurePlugIn

public RequestResult roleFigurePlugIn(RoleFigureRequest request)
                               throws java.lang.Exception
Sends the specified RoleFigureRequest to the Director. The request should contain the GAI of the initiator and cooperator of the RoleSession to be created as well as the role of the actor sending the request.
Parameters:
request - The RoleFigureRequest to be sent.
Returns:
RequestResult indicating wether the request was served successfully or not.
Throws:
java.lang.Exception - if something goes wrong.

roleFigurePlugOut

public RequestResult roleFigurePlugOut(RoleFigureRequest request)
                                throws java.lang.Exception
Sends the specified RoleFigureRequest to the Director. The request should contain the GAI of the initiator and cooperator of the RoleSession to be removed as well as the RoleSession itself. This is necessary to find the RoleSession in the actors' RoleSessionContext.
Parameters:
request - The RoleFigureRequest to be sent.
Returns:
RequestResult indicating wether the request was served successfully or not.
Throws:
java.lang.Exception - if something goes wrong.

roleSessionAction

public RequestResult roleSessionAction(RoleSession pRS,
                                       ApplicationMessage pMessage)
                                throws java.lang.Exception
Sends the specified ApplicationMessage to another actor by using the specified RoleSession. A so called RoleSessionAction is performed when an ApplicationMessage is sent from one actor to another.
Parameters:
pRS - The role session to use. It will determine who will be the receiving actor.
pMessage - The application specific message to send.
Returns:
RequestResult indicating wether the request was handled successfully or not.

sessionResume

public RequestResult sessionResume(RequestPars rpars)
                            throws java.lang.Exception
Sends the specified request of type SessionResume to the specified actor by calling requestToActor().
Parameters:
rpars - The request to be sent.
Returns:
RequestResult indicating wether the request was handled successfully or not.

sessionSuspend

public RequestResult sessionSuspend(GAI actorGAI)
                             throws java.lang.Exception
Sends a SessionSuspend request to the actor with the specified GAI. If the actor can serve the request he will return information about his state in the RequestResult returned.
Parameters:
actorGAI - The GAI of the actor the request is sent to.
Returns:
RequestResult indicating wether the request was handled successfully or not.

sessionUpdate

public RequestResult sessionUpdate(Session session)
                            throws java.lang.Exception
Sends the specified Session-object to the Director in the form of a SessionUpdate request. The Director will then replace the user's Session-object in the SessionBase with the specified Session-object.
Parameters:
session - The Session-object to be updated.
Returns:
RequestResult indicating wether the request was handled successfully or not.

subscribeCancel

public RequestResult subscribeCancel(java.lang.String subscribeID)
                              throws java.lang.Exception
Sends a request to the actor's Director that this actor wishes to cancel its subscription on report on events taking place in this PaP domain. See SubscribeRequest for more information regarding the Subscribe functionality.
Parameters:
subscribeID - Identification of the actor's subscription. This is give when the actor sends a SubscribeRequest.
Returns:
RequestResult indicating wether the request was handled successfully or not.

subscribeReport

public RequestResult subscribeReport(java.lang.String[] subscribeReport)
                              throws java.lang.Exception
This method is called by the Director every time the actor receives a new report from the SubscribeRequest service. In order for the actor to receive such report he needs to overload this method as well as send a SubscribeRequest to the Director. An overview of the content of a report is given in the SubscribeCollection-class.
Parameters:
subscribeReport - String-array that contains information about the set of events that has occured and is being reported.
Returns:
RequestResult indicating wether the result could be handled successfully or not.

subscribeRequest

public RequestResult subscribeRequest(SubscribeRequest request)
                               throws java.lang.Exception
Sends a request to the actor's Director that this actor wishes to subscribe for reports on when a set of events are taking place in this PaP domain. This means that it is notified when some activity is happening. See SubscribeRequest for more information regarding the Subscribe functionality.
Parameters:
request - Specifies the type of subscription request for the actor.
Returns:
RequestResult indicating wether the request was handled successfully or not.

dbg

private void dbg(java.lang.String dbg)
Sends debug information to this actor's BaseFrame window, which is an interactive debug client window for several entities.
Parameters:
dbg - The debug information to be sent.

requestToActor

private RequestResult requestToActor(RequestPars pRP)
                              throws java.lang.Exception
Common method for most types of requests from actors to directors.
Parameters:
pRP - The requestparameters.
Returns:
RequestResult indicating wether the request was handled successfully or not.