groovyx.gpars.activeobject
Class InternalActor

java.lang.Object
  extended by groovyx.gpars.serial.WithSerialId
      extended by groovyx.gpars.actor.impl.MessageStream
          extended by groovyx.gpars.actor.Actor
              extended by groovyx.gpars.actor.AbstractLoopingActor
                  extended by groovyx.gpars.activeobject.InternalActor
All Implemented Interfaces:
java.io.Serializable

public final class InternalActor
extends AbstractLoopingActor

Backs active objects and invokes all object's active methods.

Author:
Vaclav Pech
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class groovyx.gpars.actor.Actor
Actor.MyRemoteHandle, Actor.RemoteActor
 
Nested classes/interfaces inherited from class groovyx.gpars.actor.impl.MessageStream
MessageStream.RemoteMessageStream, MessageStream.SendTo
 
Field Summary
static java.lang.String METHOD_NAME_PREFIX
           
private static java.lang.Object[] No_ARGS
           
private static long serialVersionUID
           
 
Fields inherited from class groovyx.gpars.actor.Actor
ACTOR_HAS_ALREADY_BEEN_STARTED, CANNOT_SEND_REPLIES_NO_SENDER_HAS_BEEN_REGISTERED, currentThread, parallelGroup, START_MESSAGE, STOP_MESSAGE, TERMINATE_MESSAGE, TIMEOUT, TIMEOUT_MESSAGE, timer
 
Fields inherited from class groovyx.gpars.serial.WithSerialId
serialHandle
 
Constructor Summary
InternalActor()
          Just like DynamicDispatchActor, except that the actual method dispatch is static through the closure passed to the initialize() method.
 
Method Summary
static InternalActor create(java.lang.Object groupId)
           
private static java.lang.Object handleCurrentMessage(java.lang.Object msg)
           
 void onMessage(java.lang.Object[] msg)
          Handles incoming messages
(package private)  DataflowVariable<java.lang.Object> submit(java.lang.Object... args)
          A DataflowVariable is passed to the actor, which will bind it once the result is known.
(package private)  java.lang.Object submitAndWait(java.lang.Object... args)
          A DataflowVariable is passed to the actor, which will bind it once the result is known.
 
Methods inherited from class groovyx.gpars.actor.AbstractLoopingActor
getSender, hasBeenStopped, initialize, isActive, isFair, makeFair, reply, replyIfExists, send, setParallelGroup, setTimeout, silentStart, start, stop, sweepNextMessage, terminate
 
Methods inherited from class groovyx.gpars.actor.Actor
createActorMessage, createRemoteHandle, deregisterCurrentActorWithThread, getJoinLatch, getParallelGroup, handleException, handleInterrupt, handleStart, handleTermination, handleTimeout, isActorThread, join, join, join, join, onStop, registerCurrentActorWithThread, sendAndContinue, threadBoundActor
 
Methods inherited from class groovyx.gpars.actor.impl.MessageStream
call, getRemoteClass, leftShift, send, send, sendAndWait, sendAndWait, sendAndWait
 
Methods inherited from class groovyx.gpars.serial.WithSerialId
getOrCreateSerialHandle, writeReplace
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

METHOD_NAME_PREFIX

public static final java.lang.String METHOD_NAME_PREFIX
See Also:
Constant Field Values

No_ARGS

private static final java.lang.Object[] No_ARGS
Constructor Detail

InternalActor

public InternalActor()
Just like DynamicDispatchActor, except that the actual method dispatch is static through the closure passed to the initialize() method.

Method Detail

submit

DataflowVariable<java.lang.Object> submit(java.lang.Object... args)
A DataflowVariable is passed to the actor, which will bind it once the result is known.

Parameters:
args - The method parameters
Returns:
A Promise for the real result

submitAndWait

java.lang.Object submitAndWait(java.lang.Object... args)
                         throws java.lang.Throwable
A DataflowVariable is passed to the actor, which will bind it once the result is known. The method blocks waiting for the Promise to hold a value. The value is then returned back to the caller.

Parameters:
args - The method parameters
Returns:
The result of the internal method as returned when run in the internal actor's context
Throws:
java.lang.InterruptedException - If the current thread gets interrupted while waiting for the internal actor to respond
java.lang.Throwable - If the target method invoked asynchronously throws an exception.

onMessage

public void onMessage(java.lang.Object[] msg)
Handles incoming messages

Parameters:
msg - The message representing the requested method call

handleCurrentMessage

private static java.lang.Object handleCurrentMessage(java.lang.Object msg)

create

public static InternalActor create(java.lang.Object groupId)

Copyright © 2008–2010 Václav Pech. All Rights Reserved.