Package adams.core.scripting
Class JepScriptingEngineThread
- java.lang.Object
-
- java.lang.Thread
-
- adams.core.scripting.JepScriptingEngineThread
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
-
-
Field Summary
Fields Modifier and Type Field Description protected jep.SharedInterpreter
m_Interpreter
the central interpreter.protected JepScriptingEngine
m_Owner
the owning engine.protected boolean
m_Processing
whether any command is currently being processed.protected boolean
m_Running
whether the thread is running.protected LinkedBlockingQueue<JepScriptlet>
m_Scriptlets
the current command queue.-
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
-
-
Constructor Summary
Constructors Constructor Description JepScriptingEngineThread(JepScriptingEngine owner)
Initializes the thread.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(JepScriptlet scriptlet)
Adds the scriptlet to the queue.void
clear()
Clears the queue of scriplets.protected String
doProcess(JepScriptlet scriptlet)
Executes the given scriptlet.jep.SharedInterpreter
getInterpreter()
Returns the interpreter in use.JepScriptingEngine
getOwner()
Returns the owning scripting engine.boolean
isEmpty()
Returns whether there are no commands currently in the queue.boolean
isProcessing()
Returns whether a command is currently being processed.boolean
isRunning()
Returns whether the thread is still active and waits for commands to execute.protected void
postProcess(JepScriptlet scriptlet, boolean success, String lastError)
Performs some postprocessing.protected void
preProcess(JepScriptlet scriptlet)
Performs some preprocessing.void
run()
Executes the scripting commands.protected void
runScript(File scriptFile)
Executes the script.void
stopExecution()
Stops the execution of scripting commands.-
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, toString, yield
-
-
-
-
Field Detail
-
m_Owner
protected JepScriptingEngine m_Owner
the owning engine.
-
m_Scriptlets
protected LinkedBlockingQueue<JepScriptlet> m_Scriptlets
the current command queue.
-
m_Running
protected boolean m_Running
whether the thread is running.
-
m_Processing
protected boolean m_Processing
whether any command is currently being processed.
-
m_Interpreter
protected jep.SharedInterpreter m_Interpreter
the central interpreter.
-
-
Constructor Detail
-
JepScriptingEngineThread
public JepScriptingEngineThread(JepScriptingEngine owner)
Initializes the thread.- Parameters:
owner
- the owning scripting engine
-
-
Method Detail
-
getOwner
public JepScriptingEngine getOwner()
Returns the owning scripting engine.- Returns:
- the owner
-
getInterpreter
public jep.SharedInterpreter getInterpreter()
Returns the interpreter in use.- Returns:
- the interpreter
-
clear
public void clear()
Clears the queue of scriplets.
-
add
public void add(JepScriptlet scriptlet)
Adds the scriptlet to the queue.- Parameters:
scriptlet
- the scriptlet to add
-
runScript
protected void runScript(File scriptFile) throws jep.JepException
Executes the script.- Parameters:
scriptFile
- the script to execute- Throws:
jep.JepException
- if execution fails
-
stopExecution
public void stopExecution()
Stops the execution of scripting commands.- Specified by:
stopExecution
in interfaceadams.core.Stoppable
-
isRunning
public boolean isRunning()
Returns whether the thread is still active and waits for commands to execute.- Returns:
- true if accepting commands to process
-
isProcessing
public boolean isProcessing()
Returns whether a command is currently being processed.- Returns:
- true if a command is being processed
-
isEmpty
public boolean isEmpty()
Returns whether there are no commands currently in the queue.- Returns:
- true if no commands waiting to be executed
-
preProcess
protected void preProcess(JepScriptlet scriptlet)
Performs some preprocessing.- Parameters:
scriptlet
- the scriptlet that is about to be executed
-
doProcess
protected String doProcess(JepScriptlet scriptlet)
Executes the given scriptlet.- Parameters:
scriptlet
- the scriptlet to execute- Returns:
- the error message, null if no problems occurred
-
postProcess
protected void postProcess(JepScriptlet scriptlet, boolean success, String lastError)
Performs some postprocessing.- Parameters:
scriptlet
- the scriptlet that was executedsuccess
- true if successfully executedlastError
- the error, or null if none happened
-
-