public abstract class AbstractStatusRequestor extends AbstractCachedParameter implements StatusRequesting
StatusRequesting parameter. The KEY_COMMAND points to the
class name of the command that is to be sent for an update of this parameter
value. The AbstractCachedParameter.KEY_CACHE points to the time (in ms) the cached value
stays valid.PropertyResources.Load, PropertyResources.URLResource| Modifier and Type | Field and Description |
|---|---|
private static boolean |
DEFDISABLE
The default disable behaviour.
|
private static long |
DEFTIMEOUT
The default status-request maximum time.
|
static String |
KEY_COMMAND
The name of the command class to send for an update.
|
static String |
KEY_DISABLE
The key pointing to true if command sending is disabled.
|
static String |
KEY_TIMEOUT
The max.
|
private static Object |
lock
A lock object to delay the
AbstractCachedParameter.get() method until update occured. |
private CommandLaunching |
server
The command launcher that takes the
urge command. |
private CommandEvent |
urge
The command to send that urges a status message sent back.
|
KEY_CACHEKEY_FORMAT, KEY_NAME, KEY_PRESERVE, UNKNOWNKEY_NOINITONCREATE, POSTFIX_ALPHABET, POSTFIX_BYTES, POSTFIX_DIR, POSTFIX_EXT, POSTFIX_FILE, POSTFIX_LIST, POSTFIX_MODTIME, POSTFIX_URLKEY_LISTSEPARATOR, KEY_MAPKEYVALUECHAR, KEY_MAPSEPARATORNAMING_EXTENSIONCONFIG, KEY_CLASSKEY_URLRESOURCES, KEY_URLUSECONFIG, KEY_URLUSECURRENT, KEY_URLUSEHOME| Modifier | Constructor and Description |
|---|---|
protected |
AbstractStatusRequestor(Map<String,String> prop)
Constructs a new status requestor.
|
| Modifier and Type | Method and Description |
|---|---|
protected Object |
getUncached()
Gets this parameter value.
|
void |
init()
Inits the status requestor.
|
private CommandEvent |
instantiateUrge(String comname)
Tries to instantiate the command that should be sent to the command
handling instance.
|
protected abstract boolean |
isStatusRequested(ErrorEvent ee)
Returns true, if the error event received is of the correct type for
this parameter.
|
void |
registerError(ErrorEvent ee)
Test, if the error event received is the correct error event via a call
to
isStatusRequested(stella.ErrorEvent). |
boolean |
registerLauncher(CommandLaunching launch)
Registers a command launcher.
|
protected double |
rescanned(String key,
String old,
String newval)
If the bind property changed, we deregister from our current binding
and re-instantiate a new binding thread.
|
get, getCache, getCacheFormatted, setcreateParameter, delivers, exit, getFormatted, getFormatted, getName, getPreserveFile, getString, getString, overrideDefaultName, register, setName, toStringclone, createFrom, createFrom, createFrom, createInstance, getApplet, getAsResources, getLocate, getPropertiesToKey, getPropertiesToKey, getResource, getResourceAsStream, getResourceFromKey, getResources, hasLocalURLs, initProperties, keyCreate, keyCreate, reload, setAppletaugment, augment, augment, augment, augment, defaultBoolean, defaultChar, defaultDouble, defaultFloat, defaultInt, defaultLong, defaultObject, defaultObject, defaultProperties, defaultProperty, getAsBoolean, getAsChar, getAsDouble, getAsEnums, getAsFloat, getAsInt, getAsList, getAsLong, getAsMap, getAsMap, getAsObject, getAsObject, getProperties, getProperty, has, isNew, parseObject, parseObject, reload, removeProperty, requires, setObject, setProperties, setProperty, stringPropertiesequals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetCache, getCacheFormattedgetForErrordefaultBoolean, defaultChar, defaultDouble, defaultFloat, defaultInt, defaultLong, defaultObject, defaultObject, defaultProperties, defaultProperty, getAsBoolean, getAsChar, getAsDouble, getAsFloat, getAsInt, getAsList, getAsLong, getAsMap, getAsObject, getAsObject, getProperties, getProperty, has, parseObject, removeProperty, setObject, setProperty, stringPropertiespublic static final String KEY_COMMAND
public static final String KEY_DISABLE
public static final String KEY_TIMEOUT
private static final boolean DEFDISABLE
private static final long DEFTIMEOUT
private CommandEvent urge
private CommandLaunching server
urge command.private static Object lock
AbstractCachedParameter.get() method until update occured.protected AbstractStatusRequestor(Map<String,String> prop)
KEY_COMMAND class
is not found or cannot be used to instantiate a CommandEvent.
The cache time and the disable flag are defaulted.public void init()
throws InitException
KEY_COMMAND in daughter
classes.init in interface Initializableinit in class AbstractParameterInitExceptionprivate CommandEvent instantiateUrge(String comname)
protected double rescanned(String key, String old, String newval)
rescanned in class AbstractParameterpublic boolean registerLauncher(CommandLaunching launch)
urge it is recognized as the correct launcher. Only
then, true is returned.registerLauncher in interface StatusRequestingprotected Object getUncached()
urge command is sent to the
registered command launcher server. The method now waits on
the error event returned from the server. As soon as this error event
is received in the registerError(stella.ErrorEvent) method, the cache is updated
and the value returned.KEY_DISABLE
flag is introduced. If this is set to true, command sending is
prevented,
and the cache value is returned. This is only useful, if
at least two parameters listen to the same status event. Then, only
the parameter with the shortest cache time should carry a non-disabled
flag. It is important to avoid dead-lock situations by using different
cache times on these parameters. Keep in mind that all parameters will
be updated at the highest frequency, regardlessgetUncached in class AbstractCachedParameterpublic void registerError(ErrorEvent ee)
isStatusRequested(stella.ErrorEvent). If so, the #getFor method is
called and the cache is updated with the value returned.registerError in interface ErrorDependingParameterprotected abstract boolean isStatusRequested(ErrorEvent ee)