public static class NashornAccessorHostApplication.ActorSubstitute extends java.lang.Object implements AccessorOrchestrator
eventLoop()
.
To request that a callback be invoked, call invokeCallback(Runnable)
from any thread. The argument will be appended to a list of callbacks
to be invoked, and the event loop thread will be notified.
Callbacks will be executed in the same thread as the thread that
calls eventLoop()
.Constructor and Description |
---|
ActorSubstitute(java.lang.String name)
Construct an actor substitute instance.
|
Modifier and Type | Method and Description |
---|---|
void |
clearInterval(java.lang.Object timer)
Clear the interval with the specified handle, if it
has not already executed.
|
void |
clearTimeout(java.lang.Object timer)
Clear the timeout with the specified handle, if it
has not already executed.
|
java.lang.String |
description()
Return a description.
|
void |
error(java.lang.String message)
Report an error.
|
void |
eventLoop()
Start an event loop in a new thread that does not end until
wrapup() is called. |
NamedObj |
getContainer()
Return null.
|
java.lang.String |
getDisplayName()
Return the name specified in the constructor.
|
java.lang.String |
getFullName()
Return the name specified in the constructor.
|
java.lang.String |
getName()
Return the name specified in the constructor.
|
java.lang.String |
getName(NamedObj relativeTo)
Return the name specified in the constructor.
|
void |
invokeCallback(java.lang.Runnable function)
Invoke the specified function as soon as possible, but after any currently
executing or other pending callbacks have completed.
|
void |
log(java.lang.String message)
Print a message.
|
java.util.Timer |
setInterval(java.lang.Runnable function,
long periodMS)
Specify a function to invoke as a callback periodically with
the specified period (in milliseconds).
|
void |
setName(java.lang.String name)
Set the name.
|
java.util.Timer |
setTimeout(java.lang.Runnable function,
long timeMS)
Specify a function to invoke as a callback after the specified
time (in milliseconds) has elapsed.
|
void |
setTopLevelAccessor(jdk.nashorn.api.scripting.ScriptObjectMirror accessor)
Specify a top-level accessor to associate with this orchestrator
and start an event loop to invoke callbacks.
|
void |
wrapup()
Stop the event loop, canceling all pending callbacks.
|
public ActorSubstitute(java.lang.String name)
name
- The name of the actor substitute instance.public void clearInterval(java.lang.Object timer) throws IllegalActionException
clearInterval
in interface AccessorOrchestrator
timer
- The timeout handle.IllegalActionException
- If the handle is invalid.setTimeout(Runnable, long)
,
setInterval(Runnable, long)
public void clearTimeout(java.lang.Object timer) throws IllegalActionException
clearTimeout
in interface AccessorOrchestrator
timer
- The timeout handle.IllegalActionException
- If the handle is invalid.setTimeout(Runnable, long)
,
setInterval(Runnable, long)
public java.lang.String description() throws IllegalActionException
description
in interface Nameable
IllegalActionException
- If there is a problem accessing
subcomponents of the object.public void error(java.lang.String message)
error
in interface AccessorOrchestrator
message
- The error message.public void eventLoop()
wrapup()
is called.public NamedObj getContainer()
getContainer
in interface Nameable
public java.lang.String getDisplayName()
getDisplayName
in interface Nameable
public java.lang.String getFullName()
getFullName
in interface Nameable
public java.lang.String getName()
getName
in interface Nameable
setName(String)
public java.lang.String getName(NamedObj relativeTo) throws InvalidStateException
getName
in interface Nameable
relativeTo
- The object relative to which you want the name.InvalidStateException
- If a recursive structure is
encountered, where this object directly or indirectly contains
itself. Note that this is a runtime exception so it need not
be declared explicitly.setName(String)
public void invokeCallback(java.lang.Runnable function)
AccessorOrchestrator
invokeCallback
in interface AccessorOrchestrator
function
- The function to invoke.public void log(java.lang.String message)
log
in interface AccessorOrchestrator
message
- The message to be printed.public void setName(java.lang.String name)
public java.util.Timer setInterval(java.lang.Runnable function, long periodMS)
setInterval
in interface AccessorOrchestrator
function
- The function to invoke.periodMS
- The period in milliseconds.AccessorOrchestrator.clearTimeout(Object)
public java.util.Timer setTimeout(java.lang.Runnable function, long timeMS)
setTimeout
in interface AccessorOrchestrator
function
- The function to invoke.timeMS
- The time in milliseconds.AccessorOrchestrator.clearTimeout(Object)
public void setTopLevelAccessor(jdk.nashorn.api.scripting.ScriptObjectMirror accessor)
accessor
- A top-level accessor.public void wrapup() throws IllegalActionException
wrapup
in interface AccessorOrchestrator
IllegalActionException
- If there is a problem wrapping up.