Package adams.scripting.command
Class AbstractCommandWithResponse
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.option.AbstractOptionHandler
-
- adams.scripting.command.AbstractCommand
-
- adams.scripting.command.AbstractCommandWithResponse
-
- All Implemented Interfaces:
Destroyable,GlobalInfoSupporter,LoggingLevelHandler,LoggingSupporter,OptionHandler,SizeOfHandler,RemoteCommand,RemoteCommandWithErrorMessage,RemoteCommandWithResponse,Serializable
- Direct Known Subclasses:
AbstractFlowAwareCommandWithResponse,AbstractRemoteCommandOnFlowWithResponse,JobRunner,ListFlows,Ping,RetrieveFile,RunRemoteFlow,StartRemoteLogging,StopEngine,StopRemoteLogging,SystemInfo
public abstract class AbstractCommandWithResponse extends AbstractCommand implements RemoteCommandWithResponse
Ancestor for commands that send a response.- Version:
- $Revision$
- Author:
- FracPete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected Stringm_ErrorMessagethe error message.protected Connectionm_ResponseConnectionthe response connection.-
Fields inherited from class adams.scripting.command.AbstractCommand
m_RemoteScriptingEngineHandler, m_Request
-
Fields inherited from class adams.core.option.AbstractOptionHandler
m_OptionManager
-
Fields inherited from class adams.core.logging.LoggingObject
m_Logger, m_LoggingIsEnabled, m_LoggingLevel
-
Fields inherited from interface adams.scripting.command.RemoteCommand
KEY_COMMAND, KEY_TYPE, VALUE_REQUEST, VALUE_RESPONSE
-
-
Constructor Summary
Constructors Constructor Description AbstractCommandWithResponse()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidafterSendResponse(String error)Hook method after sending the response.StringassembleResponse(RemoteCommandProcessor processor)Assembles the command into a string, including any payload.protected PropertiesassembleResponseHeader()Assembles the response header.voidbeforeSendResponse()Hook method before sending the response.voiddefineOptions()Adds options to the internal list of options.protected StringdoHandleRequest(RemoteScriptingEngine engine, RemoteCommandProcessor processor)Handles the request.protected ConnectiongetDefaultResponseConnection()Returns the default connection to use.StringgetErrorMessage()Returns the error message (if any).ConnectiongetResponseConnection()Returns the connection to send the response to.voidhandleResponse(RemoteScriptingEngine engine, ResponseHandler handler)Handles the response.booleanhasErrorMessage()Returns whether an error message is available.Stringparse(Properties header)Parses the header information.protected voidprepareResponsePayload()Hook method for preparing the response payload,
Default implementation does nothing.StringresponseConnectionTipText()Returns the tip text for this property.voidsetResponseConnection(Connection value)Sets the connection to send the response to.StringtoString()Returns a short description of the command.-
Methods inherited from class adams.scripting.command.AbstractCommand
afterSendRequest, assembleRequest, assembleRequestHeader, beforeSendRequest, getRemoteScriptingEngineHandler, handleRequest, initialize, isRequest, prepareRequestPayload, setRemoteScriptingEngineHandler, setRequest
-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, destroy, finishInit, getDefaultLoggingLevel, getOptionManager, globalInfo, loggingLevelTipText, newOptionManager, reset, setLoggingLevel, toCommandLine
-
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.logging.LoggingSupporter
getLogger, isLoggingEnabled
-
Methods inherited from interface adams.core.option.OptionHandler
cleanUpOptions, getOptionManager, toCommandLine
-
Methods inherited from interface adams.scripting.command.RemoteCommand
afterSendRequest, assembleRequest, beforeSendRequest, getRemoteScriptingEngineHandler, getRequestPayload, getRequestPayloadObjects, handleRequest, isRequest, setRemoteScriptingEngineHandler, setRequest, setRequestPayload
-
Methods inherited from interface adams.scripting.command.RemoteCommandWithResponse
getResponsePayload, getResponsePayloadObjects, setResponsePayload
-
-
-
-
Field Detail
-
m_ResponseConnection
protected Connection m_ResponseConnection
the response connection.
-
m_ErrorMessage
protected String m_ErrorMessage
the error message.
-
-
Method Detail
-
defineOptions
public void defineOptions()
Adds options to the internal list of options.- Specified by:
defineOptionsin interfaceOptionHandler- Overrides:
defineOptionsin classAbstractOptionHandler
-
getDefaultResponseConnection
protected Connection getDefaultResponseConnection()
Returns the default connection to use.- Returns:
- the connection
-
setResponseConnection
public void setResponseConnection(Connection value)
Sets the connection to send the response to.- Specified by:
setResponseConnectionin interfaceRemoteCommandWithResponse- Parameters:
value- the connection
-
getResponseConnection
public Connection getResponseConnection()
Returns the connection to send the response to.- Specified by:
getResponseConnectionin interfaceRemoteCommandWithResponse- Returns:
- the connection
-
responseConnectionTipText
public String responseConnectionTipText()
Returns the tip text for this property.- Specified by:
responseConnectionTipTextin interfaceRemoteCommandWithResponse- Returns:
- tip text for this property suitable for displaying in the gui
-
hasErrorMessage
public boolean hasErrorMessage()
Returns whether an error message is available.- Specified by:
hasErrorMessagein interfaceRemoteCommandWithErrorMessage- Returns:
- true if an error message available
-
getErrorMessage
public String getErrorMessage()
Returns the error message (if any).- Specified by:
getErrorMessagein interfaceRemoteCommandWithErrorMessage- Returns:
- the error message, null if none availabe
-
parse
public String parse(Properties header)
Parses the header information.- Specified by:
parsein interfaceRemoteCommand- Overrides:
parsein classAbstractCommand- Parameters:
header- the header- Returns:
- null if successfully parsed, otherwise error message
-
assembleResponseHeader
protected Properties assembleResponseHeader()
Assembles the response header.- Returns:
- the response header
-
prepareResponsePayload
protected void prepareResponsePayload()
Hook method for preparing the response payload,
Default implementation does nothing.
-
assembleResponse
public String assembleResponse(RemoteCommandProcessor processor)
Assembles the command into a string, including any payload.- Specified by:
assembleResponsein interfaceRemoteCommandWithResponse- Parameters:
processor- for formatting/parsing- Returns:
- the generated string, null if failed to assemble
-
doHandleRequest
protected String doHandleRequest(RemoteScriptingEngine engine, RemoteCommandProcessor processor)
Handles the request.- Specified by:
doHandleRequestin classAbstractCommand- Parameters:
engine- the remote engine handling the request- Returns:
- null if successful, otherwise error message
-
handleResponse
public void handleResponse(RemoteScriptingEngine engine, ResponseHandler handler)
Handles the response.- Specified by:
handleResponsein interfaceRemoteCommandWithResponse- Parameters:
engine- the remote engine handling the responsehandler- for handling the response
-
beforeSendResponse
public void beforeSendResponse()
Hook method before sending the response.
Default implementation does nothing.- Specified by:
beforeSendResponsein interfaceRemoteCommandWithResponse
-
afterSendResponse
public void afterSendResponse(String error)
Hook method after sending the response.
Default implementation does nothing.- Specified by:
afterSendResponsein interfaceRemoteCommandWithResponse- Parameters:
error- null if successful, otherwise error message
-
toString
public String toString()
Returns a short description of the command.- Overrides:
toStringin classAbstractCommand- Returns:
- the description
-
-