Package adams.scripting.engine
Class AbstractScriptingEngine
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.option.AbstractOptionHandler
-
- adams.scripting.engine.AbstractScriptingEngine
-
- All Implemented Interfaces:
Destroyable
,GlobalInfoSupporter
,LoggingLevelHandler
,LoggingSupporter
,OptionHandler
,Pausable
,SizeOfHandler
,Stoppable
,StoppableWithFeedback
,FlowContextHandler
,RemoteScriptingEngine
,RemoteCommandProcessorHandler
,Serializable
- Direct Known Subclasses:
AbstractScriptingEngineEnhancer
,AbstractScriptingEngineWithJobQueue
,MultiScriptingEngine
public abstract class AbstractScriptingEngine extends AbstractOptionHandler implements RemoteScriptingEngine
Ancestor of scripting engine for remote commands.- Version:
- $Revision$
- Author:
- FracPete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected RemoteCommandHandler
m_CommandHandler
the command handler.protected RemoteCommandProcessor
m_CommandProcessor
the command processor.protected Actor
m_FlowContext
the flow context.protected boolean
m_Paused
whether the engine is paused.protected PermissionHandler
m_PermissionHandler
the permission handler.protected RemoteScriptingEngineHandler
m_RemoteScriptingEngineHandler
the application context.protected RequestHandler
m_RequestHandler
the request handler.protected ResponseHandler
m_ResponseHandler
the response handler to use.protected boolean
m_Running
whether the engine is running.protected boolean
m_Stopped
whether the engine is stopped.-
Fields inherited from class adams.core.option.AbstractOptionHandler
m_OptionManager
-
Fields inherited from class adams.core.logging.LoggingObject
m_Logger, m_LoggingIsEnabled, m_LoggingLevel
-
-
Constructor Summary
Constructors Constructor Description AbstractScriptingEngine()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description String
commandProcessorTipText()
Returns the tip text for this property.void
defineOptions()
Adds options to the internal list of options.protected abstract String
doExecute()
Performs the actual execution of the scripting engine.String
execute()
Executes the scripting engine.void
executeJob(CallableWithResult<String> job)
Executes the job.static RemoteScriptingEngine
forCommandLine(String cmdline)
Instantiates the engine from the given commandline (i.e., classname and optional options).static RemoteScriptingEngine
forName(String classname, String[] options)
Instantiates the engine with the given options.RemoteCommandHandler
getCommandHandler()
Returns the command handler in use.RemoteCommandProcessor
getCommandProcessor()
Returns the command processor in use.protected RemoteCommandHandler
getDefaultCommandHandler()
Returns the default command handler.protected RemoteCommandProcessor
getDefaultCommandProcessor()
Returns the default command processor.protected PermissionHandler
getDefaultPermissionHandler()
Returns the default permission handler.protected RequestHandler
getDefaultRequestHandler()
Returns the default request handler.protected ResponseHandler
getDefaultResponseHandler()
Returns the default request handler.Actor
getFlowContext()
Returns the flow context, if any.PermissionHandler
getPermissionHandler()
Returns the permission handler in use.RemoteScriptingEngineHandler
getRemoteScriptingEngineHandler()
Returns the application context.RequestHandler
getRequestHandler()
Returns the request handler in use.ResponseHandler
getResponseHandler()
Returns the response listener in use.protected void
initialize()
Initializes the members.boolean
isPaused()
Returns whether the object is currently paused.boolean
isRunning()
Returns whether the scripting engine is currently running.boolean
isStopped()
Whether the execution has been stopped.void
pauseExecution()
Pauses the execution.String
permissionHandlerTipText()
Returns the tip text for this property.String
requestHandlerTipText()
Returns the tip text for this property.String
responseHandlerTipText()
Returns the tip text for this property.void
resumeExecution()
Resumes the execution.static RemoteScriptingEngine
runScriptingEngine(Class env, Class engine, String[] options)
Runs the engine from the commandline.static RemoteScriptingEngine
runScriptingEngine(Class engine, String[] options)
Runs the engine from the commandline.void
setCommandHandler(RemoteCommandHandler value)
Sets the command handler to use.void
setCommandProcessor(RemoteCommandProcessor value)
Sets the command processor to use.void
setFlowContext(Actor value)
Sets the flow context.void
setPermissionHandler(PermissionHandler value)
Sets the permission handler to use.void
setRemoteScriptingEngineHandler(RemoteScriptingEngineHandler value)
Sets the application context.void
setRequestHandler(RequestHandler value)
Sets the request handler to use.void
setResponseHandler(ResponseHandler value)
Sets the response listener to use.void
stopExecution()
Stops the execution.-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, destroy, finishInit, getDefaultLoggingLevel, getOptionManager, globalInfo, loggingLevelTipText, newOptionManager, reset, setLoggingLevel, toCommandLine, toString
-
Methods inherited from class adams.core.logging.LoggingObject
configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface adams.core.Destroyable
destroy
-
Methods inherited from interface adams.core.logging.LoggingLevelHandler
getLoggingLevel
-
Methods inherited from interface adams.core.option.OptionHandler
cleanUpOptions, getOptionManager, toCommandLine
-
-
-
-
Field Detail
-
m_RemoteScriptingEngineHandler
protected RemoteScriptingEngineHandler m_RemoteScriptingEngineHandler
the application context.
-
m_FlowContext
protected Actor m_FlowContext
the flow context.
-
m_PermissionHandler
protected PermissionHandler m_PermissionHandler
the permission handler.
-
m_CommandHandler
protected RemoteCommandHandler m_CommandHandler
the command handler.
-
m_CommandProcessor
protected RemoteCommandProcessor m_CommandProcessor
the command processor.
-
m_RequestHandler
protected RequestHandler m_RequestHandler
the request handler.
-
m_ResponseHandler
protected ResponseHandler m_ResponseHandler
the response handler to use.
-
m_Paused
protected boolean m_Paused
whether the engine is paused.
-
m_Stopped
protected boolean m_Stopped
whether the engine is stopped.
-
m_Running
protected boolean m_Running
whether the engine is running.
-
-
Method Detail
-
defineOptions
public void defineOptions()
Adds options to the internal list of options.- Specified by:
defineOptions
in interfaceOptionHandler
- Overrides:
defineOptions
in classAbstractOptionHandler
-
initialize
protected void initialize()
Initializes the members.- Overrides:
initialize
in classAbstractOptionHandler
-
getDefaultCommandHandler
protected RemoteCommandHandler getDefaultCommandHandler()
Returns the default command handler.- Returns:
- the default
-
setCommandHandler
public void setCommandHandler(RemoteCommandHandler value)
Sets the command handler to use.- Specified by:
setCommandHandler
in interfaceRemoteScriptingEngine
- Parameters:
value
- the command handler
-
getCommandHandler
public RemoteCommandHandler getCommandHandler()
Returns the command handler in use.- Specified by:
getCommandHandler
in interfaceRemoteScriptingEngine
- Returns:
- the command handler
-
getDefaultCommandProcessor
protected RemoteCommandProcessor getDefaultCommandProcessor()
Returns the default command processor.- Returns:
- the processor
-
setCommandProcessor
public void setCommandProcessor(RemoteCommandProcessor value)
Sets the command processor to use.- Specified by:
setCommandProcessor
in interfaceRemoteCommandProcessorHandler
- Parameters:
value
- the processor
-
getCommandProcessor
public RemoteCommandProcessor getCommandProcessor()
Returns the command processor in use.- Specified by:
getCommandProcessor
in interfaceRemoteCommandProcessorHandler
- Returns:
- the processor
-
commandProcessorTipText
public String commandProcessorTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the gui
-
getDefaultPermissionHandler
protected PermissionHandler getDefaultPermissionHandler()
Returns the default permission handler.- Returns:
- the default
-
setPermissionHandler
public void setPermissionHandler(PermissionHandler value)
Sets the permission handler to use.- Specified by:
setPermissionHandler
in interfaceRemoteScriptingEngine
- Parameters:
value
- the permission handler
-
getPermissionHandler
public PermissionHandler getPermissionHandler()
Returns the permission handler in use.- Specified by:
getPermissionHandler
in interfaceRemoteScriptingEngine
- Returns:
- the permission handler
-
permissionHandlerTipText
public String permissionHandlerTipText()
Returns the tip text for this property.- Specified by:
permissionHandlerTipText
in interfaceRemoteScriptingEngine
- Returns:
- tip text for this property suitable for displaying in the gui
-
getDefaultRequestHandler
protected RequestHandler getDefaultRequestHandler()
Returns the default request handler.- Returns:
- the default
-
setRequestHandler
public void setRequestHandler(RequestHandler value)
Sets the request handler to use.- Specified by:
setRequestHandler
in interfaceRemoteScriptingEngine
- Parameters:
value
- the request handler
-
getRequestHandler
public RequestHandler getRequestHandler()
Returns the request handler in use.- Specified by:
getRequestHandler
in interfaceRemoteScriptingEngine
- Returns:
- the request handler
-
requestHandlerTipText
public String requestHandlerTipText()
Returns the tip text for this property.- Specified by:
requestHandlerTipText
in interfaceRemoteScriptingEngine
- Returns:
- tip text for this property suitable for displaying in the gui
-
getDefaultResponseHandler
protected ResponseHandler getDefaultResponseHandler()
Returns the default request handler.- Returns:
- the default
-
setResponseHandler
public void setResponseHandler(ResponseHandler value)
Sets the response listener to use.- Specified by:
setResponseHandler
in interfaceRemoteScriptingEngine
- Parameters:
value
- the response listener
-
getResponseHandler
public ResponseHandler getResponseHandler()
Returns the response listener in use.- Specified by:
getResponseHandler
in interfaceRemoteScriptingEngine
- Returns:
- the response listener
-
responseHandlerTipText
public String responseHandlerTipText()
Returns the tip text for this property.- Specified by:
responseHandlerTipText
in interfaceRemoteScriptingEngine
- Returns:
- tip text for this property suitable for displaying in the gui
-
setRemoteScriptingEngineHandler
public void setRemoteScriptingEngineHandler(RemoteScriptingEngineHandler value)
Sets the application context.- Specified by:
setRemoteScriptingEngineHandler
in interfaceRemoteScriptingEngine
- Parameters:
value
- the context
-
getRemoteScriptingEngineHandler
public RemoteScriptingEngineHandler getRemoteScriptingEngineHandler()
Returns the application context.- Specified by:
getRemoteScriptingEngineHandler
in interfaceRemoteScriptingEngine
- Returns:
- the context, null if none set
-
setFlowContext
public void setFlowContext(Actor value)
Sets the flow context.- Specified by:
setFlowContext
in interfaceFlowContextHandler
- Specified by:
setFlowContext
in interfaceRemoteScriptingEngine
- Parameters:
value
- the actor
-
getFlowContext
public Actor getFlowContext()
Returns the flow context, if any.- Specified by:
getFlowContext
in interfaceFlowContextHandler
- Specified by:
getFlowContext
in interfaceRemoteScriptingEngine
- Returns:
- the actor, null if none available
-
executeJob
public void executeJob(CallableWithResult<String> job)
Executes the job.- Specified by:
executeJob
in interfaceRemoteScriptingEngine
- Parameters:
job
- the job to execute
-
pauseExecution
public void pauseExecution()
Pauses the execution.- Specified by:
pauseExecution
in interfacePausable
-
isPaused
public boolean isPaused()
Returns whether the object is currently paused.
-
resumeExecution
public void resumeExecution()
Resumes the execution.- Specified by:
resumeExecution
in interfacePausable
-
stopExecution
public void stopExecution()
Stops the execution.- Specified by:
stopExecution
in interfaceStoppable
-
isStopped
public boolean isStopped()
Whether the execution has been stopped.- Specified by:
isStopped
in interfaceStoppableWithFeedback
- Returns:
- true if stopped
-
isRunning
public boolean isRunning()
Returns whether the scripting engine is currently running.- Specified by:
isRunning
in interfaceRemoteScriptingEngine
- Returns:
- true if running
-
doExecute
protected abstract String doExecute()
Performs the actual execution of the scripting engine.- Returns:
- error message in case of failure to start up or run, otherwise null
-
execute
public String execute()
Executes the scripting engine.- Specified by:
execute
in interfaceRemoteScriptingEngine
- Returns:
- error message in case of failure to start up or run, otherwise null
-
runScriptingEngine
public static RemoteScriptingEngine runScriptingEngine(Class engine, String[] options)
Runs the engine from the commandline. Retrieves the environment from option "-env classname".- Parameters:
options
- the commandline options- Returns:
- the instantiated frame, null in case of an error or invocation of help
-
runScriptingEngine
public static RemoteScriptingEngine runScriptingEngine(Class env, Class engine, String[] options)
Runs the engine from the commandline.- Parameters:
env
- the environment class to useengine
- the engine classoptions
- the commandline options- Returns:
- the instantiated frame, null in case of an error or invocation of help
-
forName
public static RemoteScriptingEngine forName(String classname, String[] options)
Instantiates the engine with the given options.- Parameters:
classname
- the classname of the engine to instantiateoptions
- the options for the engine- Returns:
- the instantiated engine or null if an error occurred
-
forCommandLine
public static RemoteScriptingEngine forCommandLine(String cmdline)
Instantiates the engine from the given commandline (i.e., classname and optional options).- Parameters:
cmdline
- the classname (and optional options) of the engine to instantiate- Returns:
- the instantiated engine or null if an error occurred
-
-