|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object
|
+--java.lang.Thread
|
+--osl.manager.ActorImpl
This class defines the basic functionality required of all classes which provide actor implementations. An actor implementation provides the interface used by the actor manager to do such things as deliver messages and exceptions, or instruct the actor that it should rebuild its state after a migration. Similarly, an actor implementation provides the interface by which the Actor class translates user service requests into actual service invocations on the ActorManager.
This class is an abstract extension of thread (rather than just an interface) in order to solve a technical problem involving the instantiation of user-written extensions of Actor. In particular, in order to allow user-written actors to invoke actor operations within their constructors, it is first necessary to properly initialize the Actor fields "self" and "implementor". Moreover, these fields should have at least package protection so that they are inaccessible to the user-written portion of an actor. The easy solution would be to initialize these fields by passing arguments to the actor constructor. However, since this must be done through a user-written constructor then we immediately give the user access to sensitive fields. The solution used is to take advantage of package level protection and have the Actor constructor (which is always called before any user-written constructor) consult package protected fields in the ActorImpl class. In particular, the "self" field in this class must be initialized before the actor implementation instantiates the user-written actor. Moreover, the protected status of the fields given below SHOULD NOT be weakened any further (e.g. made public) otherwise smart users will be able to mangle these fields from their constructor.
ActorManager,
ActorName,
Actor, Serialized Form| Field Summary | |
protected java.lang.Class |
actorClass
This field holds the run-time class of the actor managed by this implementation. |
static java.lang.Class |
classRef
A convenient constant which holds the class reference for this class. |
protected ActorContext |
context
The context passed in the initialize method of this actor. |
protected java.util.Hashtable |
extensionMethods
A hashtable which holds the Method structures pointing to extension methods. |
protected long |
nextID
The ID to associate with the next request. |
protected ActorName |
self
This field holds the name of the actor managed by this implementation. |
| Fields inherited from class java.lang.Thread |
MAX_PRIORITY,
MIN_PRIORITY,
NORM_PRIORITY |
| Constructor Summary | |
ActorImpl()
|
|
| Method Summary | |
protected abstract void |
actorDeliver(ActorMsgRequest msg)
This method is called by a manager to deliver a new message to the local actor. |
protected abstract void |
actorInitialize(ActorManager ourMgr,
ActorName you,
ActorCreateRequest req)
This method is called by a manager to initialize an actor implementation after it is instantiated. |
protected abstract void |
actorPostMigrateRebuild(ActorManager ourMgr)
This method is called by the new manager of an actor implementation just after migration has occurred. |
static ActorMsgRequest |
buildAsynchException(ActorName sender,
ActorName receiver,
ActorRequest cause,
java.lang.Exception E)
Build an asynchException message. |
protected void |
finalize()
Output to the system log that we are being GC'd. |
static boolean |
formatAsynchException(ActorMsgRequest msg)
Check if a message is formatted correctly for an "asynchException" message. |
protected abstract ActorName |
implCreate(ActorCreateRequest req)
Request a new actor to be created. |
protected abstract void |
implDestroy(java.lang.String reason)
Request to remove this actor from the system. |
protected java.lang.Object |
implExtension(java.lang.String name,
java.lang.Object[] args)
Invoke an extension provided by this implementation. |
protected abstract java.lang.Object |
implInvokeService(ServiceName name,
java.lang.String meth,
java.lang.Object[] args)
Request a service invocation on the named node service. |
protected abstract void |
implMigrate(ActorManagerName loc)
Request that this actor wishes to be migrated to a new location. |
protected abstract java.lang.Object |
implSend(ActorMsgRequest msg)
Request a message to be sent. |
protected ActorName |
mgrActorCreate(ActorManager mgr,
ActorCreateRequest request)
Call actorCreate in a manager. |
protected void |
mgrActorFatalError(ActorManager mgr,
java.lang.Exception e)
Call actorFatalError in a manager. |
protected java.lang.Object |
mgrActorInvokeService(ActorManager mgr,
ServiceName serviceName,
java.lang.String meth,
java.lang.Object[] serviceArgs)
Call actorInvokeService in a manager. |
protected void |
mgrActorMigrate(ActorManager mgr,
ActorManagerName where)
Call actorMigrate in a manager. |
protected void |
mgrActorSend(ActorManager mgr,
ActorMsgRequest message)
Call actorSend in a manager. |
protected void |
registerExtension(java.lang.String extensionName)
Register an extension method. |
protected void |
removeExtension(java.lang.String extensionName)
Remove a previously registered extension method. |
protected void |
setCreatingThread(java.lang.Thread caller,
ActorImpl creator)
This method is used by an actor implementation to synchronize with the underlying Actor being created. |
protected void |
stampRequest(ActorRequest req)
Stamp a request structure with a timestamp and our ID. |
| Methods inherited from class java.lang.Thread |
activeCount,
checkAccess,
countStackFrames,
currentThread,
destroy,
dumpStack,
enumerate,
getContextClassLoader,
getName,
getPriority,
getThreadGroup,
interrupt,
interrupted,
isAlive,
isDaemon,
isInterrupted,
join,
join,
join,
resume,
run,
setContextClassLoader,
setDaemon,
setName,
setPriority,
sleep,
sleep,
start,
stop,
stop,
suspend,
toString,
yield |
| Methods inherited from class java.lang.Object |
clone,
equals,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
| Field Detail |
protected ActorName self
protected java.lang.Class actorClass
protected ActorContext context
protected long nextID
protected transient java.util.Hashtable extensionMethods
public static java.lang.Class classRef
| Constructor Detail |
public ActorImpl()
| Method Detail |
protected void stampRequest(ActorRequest req)
public static final boolean formatAsynchException(ActorMsgRequest msg)
msg - The ActorMsgRequest to check.
public static final ActorMsgRequest buildAsynchException(ActorName sender,
ActorName receiver,
ActorRequest cause,
java.lang.Exception E)
sender - The ActorName of the sender of the
message.receiver - The ActorName of the receiver of
the message.cause - The ActorRequest giving the original
request which caused the exception.E - The Exception which was generated as a
result of the request.protected void registerExtension(java.lang.String extensionName)
protected void removeExtension(java.lang.String extensionName)
protected void setCreatingThread(java.lang.Thread caller,
ActorImpl creator)
protected ActorName mgrActorCreate(ActorManager mgr,
ActorCreateRequest request)
throws java.lang.SecurityException,
RemoteCodeException
mgr - The manager on which actorCreate
should be invoked.request - The ActorCreateRequest structure
which describes the new actor to be created.
protected void mgrActorSend(ActorManager mgr,
ActorMsgRequest message)
throws RemoteCodeException
mgr - The manager on which actorSend should
be invoked.message - The ActorMsg structure which
indicates the sender and receiver of the message, the method to
invoke on the receiver, and any arguments to pass to the target
method.
protected void mgrActorFatalError(ActorManager mgr,
java.lang.Exception e)
mgr - The manager on which actorFatalError
should be called.thrower - The ActorImpl which is signalling
the fatal error.e - The Exception which describes the fatal
error encountered in the actor.
protected void mgrActorMigrate(ActorManager mgr,
ActorManagerName where)
throws IllegalNodeException,
RemoteRequestRefusedException,
RemoteCodeException
mgr - The manager on which actorMigrate
should be called.thrower - A reference to the ActorImpl which
wishes to be migrated.where - The ActorManagerName of the manager
where this actor should be moved.
protected java.lang.Object mgrActorInvokeService(ActorManager mgr,
ServiceName serviceName,
java.lang.String meth,
java.lang.Object[] serviceArgs)
throws ServiceNotFoundException,
ServiceException
mgr - The manager on which
actorInvokeService should be called.serviceName - The ServiceName of the service
to invoke.serviceArgs - An Object which represents the
sole argument to pass to the invocation function of the service.
protected abstract void actorInitialize(ActorManager ourMgr,
ActorName you,
ActorCreateRequest req)
throws java.lang.Exception
ourMgr - The ActorManager which should be
used by this actor implementation to invoke actor services.you - The ActorName that should be used as
the name of the new actor.rtClass - The run-time Class of the
user-written actor that should be instantiated by this
implementation. This class will always be an extension of the
Actor class.initArgs - The array of arguments to pass to the
constructor of the user-defined actor when it is instantiated.ActorManager.implInitialize(osl.manager.ActorImpl, osl.manager.ActorName, osl.manager.ActorCreateRequest)protected abstract void actorDeliver(ActorMsgRequest msg)
msg - The ActorMsgRequest structure to be
delivered. This structure must be maintained by the actor as it
is required if an exception is returned to the manager.protected abstract void actorPostMigrateRebuild(ActorManager ourMgr)
ourMgr - A reference to the new manager of the
implementation after migration has occurred.
protected abstract java.lang.Object implSend(ActorMsgRequest msg)
throws RemoteCodeException
msg - The ActorMsgRequest describing the
message to send.Actor.send(ActorName, String),
Actor.call(ActorName, String)
protected abstract ActorName implCreate(ActorCreateRequest req)
throws java.lang.SecurityException,
RemoteCodeException
req - The ActorCreateRequest describing the
new actor to create.Actor.create(String),
Actor.create(Class),
Actor.create(ActorManagerName, String),
Actor.create(ActorManagerName, Class)protected abstract void implMigrate(ActorManagerName loc)
loc - The ActorManagerName of the node to
migrate to.Actor.migrate(osl.manager.ActorManagerName),
Actor.cancelMigrate()
protected abstract java.lang.Object implInvokeService(ServiceName name,
java.lang.String meth,
java.lang.Object[] args)
throws ServiceNotFoundException,
ServiceException
name - The ServiceName describing the
service to invoke.args - The Object argument to pass to the
service invocation function.Actor.invokeService(osl.service.ServiceName, java.lang.String)protected abstract void implDestroy(java.lang.String reason)
reason - A String giving a "reason" for the
removal. This string should normally be appended to the log for
the actor before removing it from the system.Actor.destroy(java.lang.String)
protected java.lang.Object implExtension(java.lang.String name,
java.lang.Object[] args)
throws ExtensionException
name - The name of the extension to invoke.args - An Object[] of arguments to pass to
the invoked extension. If no arguments are required, this should
be an array of length 0 (i.e. NOT null). The number and format
of the arguments depends on the extension being invoked.
protected void finalize()
throws java.lang.Throwable
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||