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 String
m_ErrorMessage
the error message.protected Connection
m_ResponseConnection
the 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 void
afterSendResponse(String error)
Hook method after sending the response.String
assembleResponse(RemoteCommandProcessor processor)
Assembles the command into a string, including any payload.protected Properties
assembleResponseHeader()
Assembles the response header.void
beforeSendResponse()
Hook method before sending the response.void
defineOptions()
Adds options to the internal list of options.protected String
doHandleRequest(RemoteScriptingEngine engine, RemoteCommandProcessor processor)
Handles the request.protected Connection
getDefaultResponseConnection()
Returns the default connection to use.String
getErrorMessage()
Returns the error message (if any).Connection
getResponseConnection()
Returns the connection to send the response to.void
handleResponse(RemoteScriptingEngine engine, ResponseHandler handler)
Handles the response.boolean
hasErrorMessage()
Returns whether an error message is available.String
parse(Properties header)
Parses the header information.protected void
prepareResponsePayload()
Hook method for preparing the response payload,
Default implementation does nothing.String
responseConnectionTipText()
Returns the tip text for this property.void
setResponseConnection(Connection value)
Sets the connection to send the response to.String
toString()
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:
defineOptions
in interfaceOptionHandler
- Overrides:
defineOptions
in 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:
setResponseConnection
in interfaceRemoteCommandWithResponse
- Parameters:
value
- the connection
-
getResponseConnection
public Connection getResponseConnection()
Returns the connection to send the response to.- Specified by:
getResponseConnection
in interfaceRemoteCommandWithResponse
- Returns:
- the connection
-
responseConnectionTipText
public String responseConnectionTipText()
Returns the tip text for this property.- Specified by:
responseConnectionTipText
in 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:
hasErrorMessage
in interfaceRemoteCommandWithErrorMessage
- Returns:
- true if an error message available
-
getErrorMessage
public String getErrorMessage()
Returns the error message (if any).- Specified by:
getErrorMessage
in interfaceRemoteCommandWithErrorMessage
- Returns:
- the error message, null if none availabe
-
parse
public String parse(Properties header)
Parses the header information.- Specified by:
parse
in interfaceRemoteCommand
- Overrides:
parse
in 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:
assembleResponse
in 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:
doHandleRequest
in 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:
handleResponse
in 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:
beforeSendResponse
in interfaceRemoteCommandWithResponse
-
afterSendResponse
public void afterSendResponse(String error)
Hook method after sending the response.
Default implementation does nothing.- Specified by:
afterSendResponse
in interfaceRemoteCommandWithResponse
- Parameters:
error
- null if successful, otherwise error message
-
toString
public String toString()
Returns a short description of the command.- Overrides:
toString
in classAbstractCommand
- Returns:
- the description
-
-