public abstract class JLPCActor extends Object implements TargetActor, RequestProcessor, RequestSource
An actor which implements Local Procedure Calls (LPC) and mostly works synchronously. Actors need to implement the processRequest method.
public class Multiply { public int a; public int b; } public class Multiplier extends JLPCActor { public Multiplier(Mailbox mailbox) { super(mailbox); } protected void processRequest(Object req, RP rp) throws Exception { Multiply m = (Multiply) req; rp.process(new Integer(m.a * m.b)); } }
Modifier and Type | Class and Description |
---|---|
class |
JLPCActor.SMBuilder
Creates a _SMBuilder.
|
Constructor and Description |
---|
JLPCActor() |
Modifier and Type | Method and Description |
---|---|
void |
acceptEvent(APCRequestSource apcRequestSource,
Request request)
Wraps and enqueues an unwrapped request in the requester's inbox.
|
void |
acceptRequest(APCRequestSource apcRequestSource,
Request request,
RP rp)
Wraps and enqueues an unwrapped request in the requester's inbox.
|
String |
getActorType()
Returns the actor type.
|
JLPCActor |
getAncestor(Class targetClass)
Returns A matching ancestor from the parent chain.
|
ExceptionHandler |
getExceptionHandler()
Returns the exception handler.
|
ActorFactory |
getFactory()
Returns the factory.
|
Mailbox |
getMailbox()
Returns the actor's mailbox.
|
MailboxFactory |
getMailboxFactory()
Returns the mailbox factory.
|
JLPCActor |
getMatch(Class targetClass) |
JLPCActor |
getParent()
Returns the actor's parent.
|
boolean |
hasDataItem(String name)
Returns true when the concurrent data of the actor, or its parent, contains the named data item.
|
void |
haveEvents()
A notification that there are incoming requests and responses that are ready for processing.
|
void |
initialize()
Initialize a degraded LiteActor
|
void |
initialize(Actor parent)
Initialize a degraded LiteActor
|
void |
initialize(Mailbox mailbox)
Initialize a LiteActor
|
void |
initialize(Mailbox mailbox,
Actor parent)
Initialize a LiteActor
|
void |
initialize(Mailbox mailbox,
Actor parent,
ActorFactory factory)
Initialize a LiteActor
|
protected Requirement[] |
requirements()
Returns the actor's requirements.
|
void |
responseFrom(BufferedEventsQueue<JAMessage> eventQueue,
JAResponse japcResponse)
Enqueues the response in the responder's outbox.
|
protected void |
send(Actor actor,
Request request,
RP rp)
Send a request to another actor.
|
void |
send(BufferedEventsDestination<JAMessage> destination,
JARequest japcRequest)
Sends a request to a mailbox.
|
protected void |
sendEvent(Actor actor,
Request request)
Send a request to another actor and discard any response.
|
void |
setExceptionHandler(ExceptionHandler exceptionHandler)
Assign an exception handler.
|
void |
setInitialBufferCapacity(int initialBufferCapacity)
Set the initial capacity for buffered outgoing messages.
|
public final void initialize() throws Exception
Exception
public final void initialize(Actor parent) throws Exception
parent
- The parent actor.Exception
public final void initialize(Mailbox mailbox) throws Exception
mailbox
- A mailbox which may be shared with other actors.Exception
public final void initialize(Mailbox mailbox, Actor parent) throws Exception
mailbox
- A mailbox which may be shared with other actors.parent
- The parent actor.Exception
public void initialize(Mailbox mailbox, Actor parent, ActorFactory factory) throws Exception
mailbox
- A mailbox which may be shared with other actors.parent
- The parent actor.factory
- The factory.Exception
public final JLPCActor getParent()
public final JLPCActor getAncestor(Class targetClass)
getAncestor
in interface Actor
targetClass
- A class which the ancestor is an instanceof.protected Requirement[] requirements() throws Exception
Exception
public final String getActorType()
getActorType
in interface Actor
public final ActorFactory getFactory()
getFactory
in interface Actor
public final ExceptionHandler getExceptionHandler()
getExceptionHandler
in interface RequestProcessor
getExceptionHandler
in interface RequestSource
public final void setExceptionHandler(ExceptionHandler exceptionHandler)
setExceptionHandler
in interface RequestProcessor
setExceptionHandler
in interface RequestSource
setExceptionHandler
in interface TargetActor
exceptionHandler
- The exception handler.public final void haveEvents()
haveEvents
in interface RequestProcessor
public final Mailbox getMailbox()
getMailbox
in interface Actor
getMailbox
in interface RequestSource
public final void responseFrom(BufferedEventsQueue<JAMessage> eventQueue, JAResponse japcResponse)
responseFrom
in interface APCRequestSource
eventQueue
- The responder's outbox.japcResponse
- The wrapped response to be enqueued.public final void send(BufferedEventsDestination<JAMessage> destination, JARequest japcRequest)
send
in interface APCRequestSource
destination
- The mailbox which is to receive the request.japcRequest
- The wrapped request to be sent.public final void setInitialBufferCapacity(int initialBufferCapacity)
setInitialBufferCapacity
in interface Actor
initialBufferCapacity
- The initial capacity for buffered outgoing messages.public final void acceptRequest(APCRequestSource apcRequestSource, Request request, RP rp) throws Exception
acceptRequest
in interface Actor
apcRequestSource
- The originator of the request.request
- The request to be sent.rp
- The request processor.Exception
- Any uncaught exceptions raised while processing the request.public final void acceptEvent(APCRequestSource apcRequestSource, Request request) throws Exception
acceptEvent
in interface Actor
apcRequestSource
- The originator of the request.request
- The request to be sent.Exception
- Any uncaught exceptions raised while processing the request.protected final void send(Actor actor, Request request, RP rp) throws Exception
actor
- The target actor.request
- The request.rp
- The response processor.Exception
- Any uncaught exceptions raised while processing the request.protected final void sendEvent(Actor actor, Request request)
actor
- The target actor.request
- The request.public final MailboxFactory getMailboxFactory()
public final boolean hasDataItem(String name)
hasDataItem
in interface Actor
name
- The key for the data item.Copyright © 2012. All Rights Reserved.