|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.lang.Thread com.jstatcom.engine.PCall
public abstract class PCall
This class encapsulates procedure calls to carry out computational tasks in
an extra thread. It can optionally be executed in a single worker thread by
invoking the thread with execute
. Concrete subclasses must
implement runCode
with the respective algorithm for the
computation. Subclasses can also overwrite finalCode
for
output formatting or other tasks that should be carried out if
runCode
finished successfully. All relevant data should be
given as arguments in the constructor.
A procedure call object can be invoked with the respective arguments from a GUI or a non GUI object. It helps to separate the program logic from the user interface part.
All events that are fired are synchronized with the Swing
EvenDispatchingThread
if isGui()==true
.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class java.lang.Thread |
---|
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler |
Field Summary |
---|
Fields inherited from class java.lang.Thread |
---|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Constructor Summary | |
---|---|
PCall()
|
Method Summary | |
---|---|
void |
add(PCall pCall)
Adds another call object that will be executed if this call finished successfully. |
void |
addPCallListener(PCallListener l)
Registers listener l such that it will receive notifications. |
void |
call(java.lang.String procName,
JSCData[] args,
JSCData[] retData)
Adapter to Engine.call that uses engine() . |
void |
cancel()
Interrupts this call and calls the stop method of the
engine. |
abstract Engine |
engine()
Gets the Engine instance that is used by this call for the
convenience implementations of the adapter methods to the engine
interface. |
boolean |
equals(java.lang.Object o)
Overwrite protection method calls super method. |
void |
execute()
Puts this call object in the worker thread queue. |
EDU.oswego.cs.dl.util.concurrent.Executor |
getExecutor()
Gets the executor that is used by the execute method. |
OutHolder |
getOutHolder()
Gets the output holder component. |
long |
getStartTime()
Gets the system time at thread start. |
SymbolTable |
getSymbolTable()
Gets the currently used symbol table. |
int |
hashCode()
Overwrite protection method calls super method. |
boolean |
isGui()
Gets whether GUI mode is set. |
boolean |
isPrintDate()
Gets whether date is printed in output. |
boolean |
isSuccess()
Gets whether the call finished successfully. |
void |
load(java.lang.String module,
LoadTypes loadType,
JSCData[] args)
Adapter to Engine.load that uses engine() . |
void |
remove(PCall pCall)
Removes an element from the list of calls that are executed if this call finishes ok. |
void |
removePCallListener(PCallListener l)
Unregisters listener l so that it will no longer be notified. |
void |
run()
Template method that calls preCode ,runCode
and finalCode in this order. |
void |
setGui(boolean gui)
Sets GUI mode, if true/false the following features are
enabled/disabled:
event synchronization with Swing
Swing dialogs are used to display error messages
Default is true . |
void |
setOutHolder(OutHolder outputHolder)
Sets the output component that the results and other output should be written to. |
void |
setPrintDate(boolean b)
Sets whether date is printed in output, the default is true . |
void |
setSymbolTable(SymbolTable newSymbolTable)
Sets the symbol table to access data objects. |
Methods inherited from class java.lang.Thread |
---|
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield |
Methods inherited from class java.lang.Object |
---|
getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public PCall()
Method Detail |
---|
public final void addPCallListener(PCallListener l)
l
- listener to be addedpublic OutHolder getOutHolder()
SystemOutHolder
.
public long getStartTime()
System.currentTimeMillis()
when the call was
startedpublic SymbolTable getSymbolTable()
public boolean isSuccess()
true
if runCode
was successfulpublic void removePCallListener(PCallListener l)
l
- listener to be removedpublic final void run()
preCode
,runCode
and finalCode
in this order. It handles any exceptions
that occur in these methods. The method has the following structure:
started
of all registered
PCallListener
objects
getOutput
buffer
runCode
finalCode
if no exception was thrown and no
interruption occured
outHolder
if no error
occured (optional)
outHolder
and a dialog is shown (optional)
outHolder
success
and
finished
methods of PCallListener
objects
are called, otherwise only finished
runCode
and finalCode
as well as by
setting:
finalCode
method of
subclasses by using the getOutput
buffer.
run
in interface java.lang.Runnable
run
in class java.lang.Thread
public void setOutHolder(OutHolder outputHolder)
SystemOutHolder
.
outputHolder
- write output topublic void setSymbolTable(SymbolTable newSymbolTable)
newSymbolTable
- a new symbol table
java.lang.IllegalArgumentException
- if (newSymbolTable == null)
public void execute()
getExecutor
.
Implementation
Calls execute(Runnable command)
from
util.concurrent.QueuedExecutor
.
public void cancel()
stop
method of the
engine.
public void add(PCall pCall)
The event notification is done whenever a call was finished, meaning that
success
and finished
are called before the
other elements of the list are started.
pCall
- call object that is exectued conditional on this call to
finish without errorpublic void remove(PCall pCall)
pCall
was not added
before.
pCall
- the call object to removepublic boolean isPrintDate()
true
if printedpublic void setPrintDate(boolean b)
true
.
b
- true
if printedpublic final int hashCode()
hashCode
in class java.lang.Object
public final boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public abstract Engine engine()
Engine
instance that is used by this call for the
convenience implementations of the adapter methods to the engine
interface.
Engine
public void call(java.lang.String procName, JSCData[] args, JSCData[] retData)
Engine.call
that uses engine()
.
procName
- procedure to be executed by this engineargs
- the data to be used as inputretData
- the return typesEngine
public void load(java.lang.String module, LoadTypes loadType, JSCData[] args)
Engine.load
that uses engine()
.
module
- the name of the module to loadloadType
- the type of module to loadargs
- module load arguments if neededpublic EDU.oswego.cs.dl.util.concurrent.Executor getExecutor()
execute
method. The
default implementation uses util.concurrent.QueuedExecutor
.
Subclasses might overwrite this method to define a different execution
policy.
Executor
to be used by
execute
public boolean isGui()
true
if in GUI mode, false
otherwisepublic void setGui(boolean gui)
true/false
the following features are
enabled/disabled:
true
.
gui
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |