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 RemoteCommandHandlerm_CommandHandlerthe command handler.protected RemoteCommandProcessorm_CommandProcessorthe command processor.protected Actorm_FlowContextthe flow context.protected booleanm_Pausedwhether the engine is paused.protected PermissionHandlerm_PermissionHandlerthe permission handler.protected RemoteScriptingEngineHandlerm_RemoteScriptingEngineHandlerthe application context.protected RequestHandlerm_RequestHandlerthe request handler.protected ResponseHandlerm_ResponseHandlerthe response handler to use.protected booleanm_Runningwhether the engine is running.protected booleanm_Stoppedwhether 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 StringcommandProcessorTipText()Returns the tip text for this property.voiddefineOptions()Adds options to the internal list of options.protected abstract StringdoExecute()Performs the actual execution of the scripting engine.Stringexecute()Executes the scripting engine.voidexecuteJob(CallableWithResult<String> job)Executes the job.static RemoteScriptingEngineforCommandLine(String cmdline)Instantiates the engine from the given commandline (i.e., classname and optional options).static RemoteScriptingEngineforName(String classname, String[] options)Instantiates the engine with the given options.RemoteCommandHandlergetCommandHandler()Returns the command handler in use.RemoteCommandProcessorgetCommandProcessor()Returns the command processor in use.protected RemoteCommandHandlergetDefaultCommandHandler()Returns the default command handler.protected RemoteCommandProcessorgetDefaultCommandProcessor()Returns the default command processor.protected PermissionHandlergetDefaultPermissionHandler()Returns the default permission handler.protected RequestHandlergetDefaultRequestHandler()Returns the default request handler.protected ResponseHandlergetDefaultResponseHandler()Returns the default request handler.ActorgetFlowContext()Returns the flow context, if any.PermissionHandlergetPermissionHandler()Returns the permission handler in use.RemoteScriptingEngineHandlergetRemoteScriptingEngineHandler()Returns the application context.RequestHandlergetRequestHandler()Returns the request handler in use.ResponseHandlergetResponseHandler()Returns the response listener in use.protected voidinitialize()Initializes the members.booleanisPaused()Returns whether the object is currently paused.booleanisRunning()Returns whether the scripting engine is currently running.booleanisStopped()Whether the execution has been stopped.voidpauseExecution()Pauses the execution.StringpermissionHandlerTipText()Returns the tip text for this property.StringrequestHandlerTipText()Returns the tip text for this property.StringresponseHandlerTipText()Returns the tip text for this property.voidresumeExecution()Resumes the execution.static RemoteScriptingEnginerunScriptingEngine(Class env, Class engine, String[] options)Runs the engine from the commandline.static RemoteScriptingEnginerunScriptingEngine(Class engine, String[] options)Runs the engine from the commandline.voidsetCommandHandler(RemoteCommandHandler value)Sets the command handler to use.voidsetCommandProcessor(RemoteCommandProcessor value)Sets the command processor to use.voidsetFlowContext(Actor value)Sets the flow context.voidsetPermissionHandler(PermissionHandler value)Sets the permission handler to use.voidsetRemoteScriptingEngineHandler(RemoteScriptingEngineHandler value)Sets the application context.voidsetRequestHandler(RequestHandler value)Sets the request handler to use.voidsetResponseHandler(ResponseHandler value)Sets the response listener to use.voidstopExecution()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:
defineOptionsin interfaceOptionHandler- Overrides:
defineOptionsin classAbstractOptionHandler
-
initialize
protected void initialize()
Initializes the members.- Overrides:
initializein 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:
setCommandHandlerin interfaceRemoteScriptingEngine- Parameters:
value- the command handler
-
getCommandHandler
public RemoteCommandHandler getCommandHandler()
Returns the command handler in use.- Specified by:
getCommandHandlerin 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:
setCommandProcessorin interfaceRemoteCommandProcessorHandler- Parameters:
value- the processor
-
getCommandProcessor
public RemoteCommandProcessor getCommandProcessor()
Returns the command processor in use.- Specified by:
getCommandProcessorin 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:
setPermissionHandlerin interfaceRemoteScriptingEngine- Parameters:
value- the permission handler
-
getPermissionHandler
public PermissionHandler getPermissionHandler()
Returns the permission handler in use.- Specified by:
getPermissionHandlerin interfaceRemoteScriptingEngine- Returns:
- the permission handler
-
permissionHandlerTipText
public String permissionHandlerTipText()
Returns the tip text for this property.- Specified by:
permissionHandlerTipTextin 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:
setRequestHandlerin interfaceRemoteScriptingEngine- Parameters:
value- the request handler
-
getRequestHandler
public RequestHandler getRequestHandler()
Returns the request handler in use.- Specified by:
getRequestHandlerin interfaceRemoteScriptingEngine- Returns:
- the request handler
-
requestHandlerTipText
public String requestHandlerTipText()
Returns the tip text for this property.- Specified by:
requestHandlerTipTextin 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:
setResponseHandlerin interfaceRemoteScriptingEngine- Parameters:
value- the response listener
-
getResponseHandler
public ResponseHandler getResponseHandler()
Returns the response listener in use.- Specified by:
getResponseHandlerin interfaceRemoteScriptingEngine- Returns:
- the response listener
-
responseHandlerTipText
public String responseHandlerTipText()
Returns the tip text for this property.- Specified by:
responseHandlerTipTextin 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:
setRemoteScriptingEngineHandlerin interfaceRemoteScriptingEngine- Parameters:
value- the context
-
getRemoteScriptingEngineHandler
public RemoteScriptingEngineHandler getRemoteScriptingEngineHandler()
Returns the application context.- Specified by:
getRemoteScriptingEngineHandlerin interfaceRemoteScriptingEngine- Returns:
- the context, null if none set
-
setFlowContext
public void setFlowContext(Actor value)
Sets the flow context.- Specified by:
setFlowContextin interfaceFlowContextHandler- Specified by:
setFlowContextin interfaceRemoteScriptingEngine- Parameters:
value- the actor
-
getFlowContext
public Actor getFlowContext()
Returns the flow context, if any.- Specified by:
getFlowContextin interfaceFlowContextHandler- Specified by:
getFlowContextin interfaceRemoteScriptingEngine- Returns:
- the actor, null if none available
-
executeJob
public void executeJob(CallableWithResult<String> job)
Executes the job.- Specified by:
executeJobin interfaceRemoteScriptingEngine- Parameters:
job- the job to execute
-
pauseExecution
public void pauseExecution()
Pauses the execution.- Specified by:
pauseExecutionin interfacePausable
-
isPaused
public boolean isPaused()
Returns whether the object is currently paused.
-
resumeExecution
public void resumeExecution()
Resumes the execution.- Specified by:
resumeExecutionin interfacePausable
-
stopExecution
public void stopExecution()
Stops the execution.- Specified by:
stopExecutionin interfaceStoppable
-
isStopped
public boolean isStopped()
Whether the execution has been stopped.- Specified by:
isStoppedin interfaceStoppableWithFeedback- Returns:
- true if stopped
-
isRunning
public boolean isRunning()
Returns whether the scripting engine is currently running.- Specified by:
isRunningin 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:
executein 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
-
-