Class AbstractRatOutput
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.option.AbstractOptionHandler
-
- adams.flow.standalone.rats.output.AbstractRatOutput
-
- All Implemented Interfaces:
adams.core.AdditionalInformationHandler
,adams.core.CleanUpHandler
,adams.core.Destroyable
,adams.core.GlobalInfoSupporter
,adams.core.logging.LoggingLevelHandler
,adams.core.logging.LoggingSupporter
,adams.core.option.OptionHandler
,adams.core.QuickInfoSupporter
,adams.core.ShallowCopySupporter<AbstractRatOutput>
,adams.core.SizeOfHandler
,adams.core.Stoppable
,adams.core.StoppableWithFeedback
,adams.event.VariableChangeListener
,RatOutput
,Serializable
- Direct Known Subclasses:
AbstractMetaRatOutput
,BinaryFileWriter
,Branch
,CallableActor
,DistributedEnQueue
,DummyOutput
,EnQueue
,Exec
,FileMover
,FtpUpload
,Publish
,QueueDistribute
,RedisAction
,RedisPublish
,SendEmail
,Serialize
,Socket
,Switch
,TextWriter
,WebserviceOutput
,WebsocketOutput
public abstract class AbstractRatOutput extends adams.core.option.AbstractOptionHandler implements RatOutput, adams.core.ShallowCopySupporter<AbstractRatOutput>, adams.core.QuickInfoSupporter, adams.core.CleanUpHandler
Ancestor for output transmitters.- Version:
- $Revision$
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected Hashtable<String,Object>
m_BackupState
for backing up the state of an actor.protected HashSet<String>
m_DetectedObjectVariables
the variable names (referencing callable actors or storage) that are used within this output.protected HashSet<String>
m_DetectedVariables
the variable names that are used within this output.protected Object
m_Input
the input.protected String
m_LoggingPrefix
the logging prefix.protected Rat
m_Owner
the owner.protected boolean
m_Stopped
whether the reception was stopped.protected HashSet<String>
m_VariablesUpdated
whether the output needs re-setting up because of modified variables.
-
Constructor Summary
Constructors Constructor Description AbstractRatOutput()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract Class[]
accepts()
Returns the type of data that gets accepted.protected Hashtable<String,Object>
backupState()
Backs up the current state of the actor before update the variables.boolean
canInput()
Whether input can be supplied at the moment.protected String
check()
Hook method for performing checks.void
cleanUp()
Cleans up data structures, frees up memory.protected void
configureLogger()
Initializes the logger.protected abstract String
doTransmit()
Performs the actual transmission.protected void
doWait(int msec)
A simple waiting method.protected HashSet<String>
findVariables()
Recursively finds all the variables used in this RatOutput.String
getAdditionalInformation()
Returns the additional information.String
getFullName()
Returns the full name of the receiver.Rat
getOwner()
Returns the actor the transmitter belongs to.protected adams.flow.control.StorageQueueHandler
getQueue(adams.flow.control.StorageName name)
Returns the flow's queue.String
getQuickInfo()
Returns a quick info about the actor, which will be displayed in the GUI.adams.core.Variables
getVariables()
Returns the Variables instance to use.protected String
handleException(String msg, Throwable t)
Outputs the stacktrace along with the message on stderr and returns a combination of both of them as string.protected void
initialize()
Initializes the members.String
initTransmission()
Initializes the transmission.void
input(Object obj)
The data to transmit.protected boolean
isBackedUp(String key)
Checks whether a specified key is present in the current backup state.boolean
isStopped()
Returns whether the transmitter has been stopped.protected void
pruneBackup()
Removes entries from the backup.protected void
pruneBackup(String key)
Removes the object with the specified key from the current backup state.protected void
restoreState(Hashtable<String,Object> state)
Restores the state of the actor before the variables got updated.void
setOwner(Rat value)
Sets the actor the transmitter belongs to.String
setUp()
Hook method for performing checks at setup time.AbstractRatOutput
shallowCopy()
Returns a shallow copy of itself, i.e., based on the commandline options.AbstractRatOutput
shallowCopy(boolean expand)
Returns a shallow copy of itself, i.e., based on the commandline options.void
stopExecution()
Stops the execution.String
transmit()
Performs the transmission.protected void
updateDetectedVariables()
Updates the detected variables.protected void
updatePrefix()
Updates the prefix of the logger.protected String
updateVariables()
Gets called when the actor needs to be re-setUp when a variable changes.void
variableChanged(adams.event.VariableChangeEvent e)
Gets triggered when a variable changed (added, modified, removed).-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, defineOptions, destroy, finishInit, getDefaultLoggingLevel, getOptionManager, globalInfo, loggingLevelTipText, newOptionManager, reset, setLoggingLevel, toCommandLine, toString
-
Methods inherited from class adams.core.logging.LoggingObject
getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
-
-
-
-
Field Detail
-
m_Owner
protected Rat m_Owner
the owner.
-
m_Stopped
protected boolean m_Stopped
whether the reception was stopped.
-
m_LoggingPrefix
protected String m_LoggingPrefix
the logging prefix.
-
m_Input
protected Object m_Input
the input.
-
m_DetectedVariables
protected HashSet<String> m_DetectedVariables
the variable names that are used within this output.
-
m_DetectedObjectVariables
protected HashSet<String> m_DetectedObjectVariables
the variable names (referencing callable actors or storage) that are used within this output.
-
m_VariablesUpdated
protected HashSet<String> m_VariablesUpdated
whether the output needs re-setting up because of modified variables.
-
-
Method Detail
-
initialize
protected void initialize()
Initializes the members.- Overrides:
initialize
in classadams.core.option.AbstractOptionHandler
-
configureLogger
protected void configureLogger()
Initializes the logger.- Overrides:
configureLogger
in classadams.core.logging.LoggingObject
-
getFullName
public String getFullName()
Returns the full name of the receiver.- Specified by:
getFullName
in interfaceRatOutput
- Returns:
- the name
-
updatePrefix
protected void updatePrefix()
Updates the prefix of the logger.
-
handleException
protected String handleException(String msg, Throwable t)
Outputs the stacktrace along with the message on stderr and returns a combination of both of them as string.- Parameters:
msg
- the message for the exceptiont
- the exception- Returns:
- the full error message (message + stacktrace)
-
setOwner
public void setOwner(Rat value)
Sets the actor the transmitter belongs to.
-
getOwner
public Rat getOwner()
Returns the actor the transmitter belongs to.
-
getAdditionalInformation
public String getAdditionalInformation()
Returns the additional information.- Specified by:
getAdditionalInformation
in interfaceadams.core.AdditionalInformationHandler
- Returns:
- the additional information, null or 0-length string for no information
-
getQuickInfo
public String getQuickInfo()
Returns a quick info about the actor, which will be displayed in the GUI.
Default implementation returns null.- Specified by:
getQuickInfo
in interfaceadams.core.QuickInfoSupporter
- Returns:
- null if no info available, otherwise short string
-
accepts
public abstract Class[] accepts()
Returns the type of data that gets accepted.
-
canInput
public boolean canInput()
Whether input can be supplied at the moment.
-
input
public void input(Object obj)
The data to transmit.
-
getVariables
public adams.core.Variables getVariables()
Returns the Variables instance to use.- Returns:
- the variables instance, null if not available
-
findVariables
protected HashSet<String> findVariables()
Recursively finds all the variables used in this RatOutput.- Returns:
- the variables that were found
-
updateDetectedVariables
protected void updateDetectedVariables()
Updates the detected variables.
-
setUp
public String setUp()
Hook method for performing checks at setup time.
-
check
protected String check()
Hook method for performing checks.
Default implementation does nothing.- Returns:
- null if successful, otherwise error message
-
doWait
protected void doWait(int msec)
A simple waiting method.- Parameters:
msec
- the maximum number of milli-seconds to wait, no waiting if 0
-
getQueue
protected adams.flow.control.StorageQueueHandler getQueue(adams.flow.control.StorageName name)
Returns the flow's queue.- Parameters:
name
- the name of the queue- Returns:
- the queue, null if not initialized
- See Also:
QueueInit
-
variableChanged
public void variableChanged(adams.event.VariableChangeEvent e)
Gets triggered when a variable changed (added, modified, removed).- Specified by:
variableChanged
in interfaceRatOutput
- Specified by:
variableChanged
in interfaceadams.event.VariableChangeListener
- Parameters:
e
- the event
-
isBackedUp
protected boolean isBackedUp(String key)
Checks whether a specified key is present in the current backup state.- Parameters:
key
- the key of the object to look for in the backup state- Returns:
- true if key present
-
pruneBackup
protected void pruneBackup(String key)
Removes the object with the specified key from the current backup state.- Parameters:
key
- the key of the object to remove from the backup state
-
pruneBackup
protected void pruneBackup()
Removes entries from the backup.
Default implementation does nothing.- See Also:
AbstractOptionHandler.reset()
-
backupState
protected Hashtable<String,Object> backupState()
Backs up the current state of the actor before update the variables.
Default implementation only returns an empty hashtable.- Returns:
- the backup
- See Also:
updateVariables()
,restoreState(Hashtable)
-
restoreState
protected void restoreState(Hashtable<String,Object> state)
Restores the state of the actor before the variables got updated.
Default implementation does nothing.- Parameters:
state
- the backup of the state to restore from- See Also:
updateVariables()
,backupState()
-
updateVariables
protected String updateVariables()
Gets called when the actor needs to be re-setUp when a variable changes.- Returns:
- null if everything is fine, otherwise error message
-
initTransmission
public String initTransmission()
Initializes the transmission.- Specified by:
initTransmission
in interfaceRatOutput
- Returns:
- null if successfully initialized, otherwise error message
-
doTransmit
protected abstract String doTransmit()
Performs the actual transmission.- Returns:
- null if successful, otherwise error message
-
transmit
public String transmit()
Performs the transmission.
-
shallowCopy
public AbstractRatOutput shallowCopy()
Returns a shallow copy of itself, i.e., based on the commandline options.- Specified by:
shallowCopy
in interfaceadams.core.ShallowCopySupporter<AbstractRatOutput>
- Returns:
- the shallow copy
-
shallowCopy
public AbstractRatOutput shallowCopy(boolean expand)
Returns a shallow copy of itself, i.e., based on the commandline options.- Specified by:
shallowCopy
in interfaceadams.core.ShallowCopySupporter<AbstractRatOutput>
- Parameters:
expand
- whether to expand variables to their current values- Returns:
- the shallow copy
-
stopExecution
public void stopExecution()
Stops the execution.- Specified by:
stopExecution
in interfaceRatOutput
- Specified by:
stopExecution
in interfaceadams.core.Stoppable
-
isStopped
public boolean isStopped()
Returns whether the transmitter has been stopped.
-
cleanUp
public void cleanUp()
Cleans up data structures, frees up memory.- Specified by:
cleanUp
in interfaceadams.core.CleanUpHandler
-
-