public class DatabaseNow extends AbstractRmiListener implements RmiDataListener, Initializable, ExitCleaning, Logging
| Modifier and Type | Class and Description |
|---|---|
static class |
DatabaseNow.Run
A class to create a a database now instance and run it.
|
PropertyResources.Load, PropertyResources.URLResource| Modifier and Type | Field and Description |
|---|---|
private static String |
DEFHOST
The default host.
|
private static String |
DEFMAPPING
All sensors that provide a key here have an sql-field value.
|
private static String |
DEFSENSORS
The default list of sensors.
|
private static String |
DEFWHERE |
private Map |
fields
The mapping of sensor names as in the dataevents to sql fields.
|
static String |
KEY_HOST
The host where the data events are generated.
|
static String |
KEY_MAPPING
A look-up table linking sensor names to sql fields.
|
static String |
KEY_SENSORS
The list of binding names of the sensors.
|
static String |
KEY_WHERE
The key to the where clause for database replacements.
|
private EnvironmentSql |
sql
The sql-interface.
|
private boolean |
virginfail
False if a propbaly recurrent error has occured.
|
KEY_ALIVE, KEY_EXPORTPORT, KEY_INIT, KEY_LISTENERNAME, KEY_RETRY, KEY_RETRYSLEEP, KEY_SHUTDOWNDELAYKEY_NOINITONCREATE, POSTFIX_ALPHABET, POSTFIX_BYTES, POSTFIX_DIR, POSTFIX_EXT, POSTFIX_FILE, POSTFIX_LIST, POSTFIX_MODTIME, POSTFIX_URLKEY_LISTSEPARATOR, KEY_MAPKEYVALUECHAR, KEY_MAPSEPARATORCONFIG, KEY_CLASSKEY_URLRESOURCES, KEY_URLUSECONFIG, KEY_URLUSECURRENT, KEY_URLUSEHOME| Constructor and Description |
|---|
DatabaseNow(Map<String,String> props)
Constructs a new databaseNow! object.
|
| Modifier and Type | Method and Description |
|---|---|
protected boolean |
deregisterAtCaster(RmiCaster test,
Class single)
Unregisters from an rmi-data caster.
|
boolean |
deregisterCaster(Caster dummy)
This weather database never needs external casters, it only registers
at weather sensors.
|
Thread |
getLoggerThread(ThreadGroup grp)
This logger is a pure listener, it has now run method.
|
void |
init()
Initializes the database-now object.
|
protected boolean |
registerAtCaster(RmiCaster test,
Class single)
Registers the database now to this caster, if it is an rmi-data caster.
|
boolean |
registerCaster(Caster dummy)
This weather database never needs external casters, it only registers
at weather sensors.
|
void |
rmiDataAvailable(DataEvent de)
Receives a data event.
|
allBound, blockBinding, blockBinding, disconnect, exit, getIP, getListenerName, isConnected, listenerName, releaseBinding, releaseBinding, rescanned, startBinding, startBindingcontainsRemoteProperty, getRemoteProperties, getRemoteProperty, setRemotePropertyclone, 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, stringProperties, toStringequals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetListenerNamedisconnect, isConnectedexitdefaultBoolean, 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_HOST
public static final String KEY_SENSORS
public static final String KEY_MAPPING
public static final String KEY_WHERE
private static final String DEFHOST
private static final String DEFSENSORS
private static final String DEFMAPPING
private static final String DEFWHERE
private final EnvironmentSql sql
private Map fields
private boolean virginfail
public void init()
AbstractRmiListener.exit() method
is called.KEY_SENSORS
points to the list of binding names of the sensor. Each entry found
here is combined with the sensor's host to yield a binding name.
Entries in the KEY_MAPPING link the sensor name as provided
in the sensor data event to the appropriate SQL field. To allow data
collection from sensors on different host, the KEY_HOST
property is actually a list of hosts, while the KEY_SENSORS
is a double-list (see Strings.doubleTokenize(java.lang.String)). It is
within the responsibility of the user to provide equal-size lists in
the KEY_HOST and the outer KEY_SENSORS double list.init in interface Initializableprotected boolean registerAtCaster(RmiCaster test, Class single)
registerAtCaster in class AbstractRmiListenerprotected boolean deregisterAtCaster(RmiCaster test, Class single)
deregisterAtCaster in class AbstractRmiListenerpublic void rmiDataAvailable(DataEvent de)
RawDataEvent,
first the data events source is matched to the appropriate
KEY_MAPPING sql-field. If the sql-connection is open,
the data is then updated in the database using the
GenericSql#replace method with the KEY_WHERE clause
and using a mapping of the sql-name of the sensor to its value.rmiDataAvailable in interface RmiDataListenerpublic boolean registerCaster(Caster dummy)
registerCaster in interface Loggingpublic boolean deregisterCaster(Caster dummy)
deregisterCaster in interface Loggingpublic Thread getLoggerThread(ThreadGroup grp)
getLoggerThread in interface Logginggrp - The thread group the logger must run in.