stella.parameter
Class AbstractDatabaseParameter

java.lang.Object
  extended by util.PropertyContainer
      extended by stella.parameter.AbstractParameter
          extended by stella.parameter.AbstractDatabaseParameter
All Implemented Interfaces:
Cloneable, Parameter, ExitCleaning, Initializable, PropertyBearing
Direct Known Subclasses:
AbstractDatabaseValue

public abstract class AbstractDatabaseParameter
extends AbstractParameter

An abstract implementation of a parameter that connects to a database. It composes with a GenericSql object, which connects on init. Each query to the parameter via the get() and set(java.lang.Object) method first checks if the connections is open, if it was closed unexpectedely and the KEY_ALLOWREOPEN property points to true, its is opened again. If successful, the abstract methods getFromOpenDatabase() or setIntoOpenDatabase(java.lang.Object) methods are called.


Nested Class Summary
 
Nested classes/interfaces inherited from class util.PropertyContainer
PropertyContainer.URLResource
 
Field Summary
private  GenericSql db
          My SQL instance.
private static boolean DEFALLOWREOPEN
          The key to the unique trigger name.
static String KEY_ALLOWREOPEN
          The key to the unique trigger name.
 
Fields inherited from class stella.parameter.AbstractParameter
KEY_FORMAT, KEY_NAME, KEY_PRESERVE, UNKNOWN
 
Fields inherited from class util.PropertyContainer
KEY_LISTSEPARATOR, KEY_LOCALECOUNTRY, KEY_LOCALELANGUAGE, KEY_MAPKEYVALUECHAR, KEY_MAPSEPARATOR, KEY_NOINITONCREATE, KEY_RESOURCEBUNDLES
 
Fields inherited from interface util.PropertyBearing
CONFIG, KEY_CLASS, KEY_URLRESOURCES, KEY_URLUSECONFIG, KEY_URLUSECURRENT, KEY_URLUSEHOME
 
Constructor Summary
protected AbstractDatabaseParameter(Map prop)
          Constructs a new database parameter.
 
Method Summary
 void exit()
          On exit, we close the database, if we are open.
 Object get()
          Gets the parameter from the database.
protected abstract  Object getFromOpenDatabase()
          This method is called if the database is ready for data retrieval.
 void init()
          Initializes the database and tries to open it.
 Object set(Object to)
          Sets the parameter from the database.
protected abstract  Object setIntoOpenDatabase(Object to)
          This method is calles if the database is ready to insert a new value.
 
Methods inherited from class stella.parameter.AbstractParameter
createParameter, delivers, getFormatted, getFormatted, getName, getPreserveFile, getString, getString, register, rescanned, setName, toString
 
Methods inherited from class util.PropertyContainer
augment, augment, augment, clone, createFrom, createFrom, createFrom, defaultBoolean, defaultChar, defaultDouble, defaultFloat, defaultInt, defaultLong, defaultObject, defaultObject, defaultProperties, defaultProperty, getAsBoolean, getAsChar, getAsDouble, getAsEnums, getAsFloat, getAsInt, getAsList, getAsLong, getAsMap, getAsMap, getAsObject, getAsObject, getLocalClassLoader, getLocalized, getLocalized, getLocalizedString, getLocalizedString, getProperties, getPropertiesToKey, getPropertiesToKey, getProperty, getResource, getResourceAsStream, getResourceFromKey, getResources, has, isNew, keyCreate, keyCreate, parseObject, reload, reload, removeProperty, setObject, setProperties, setProperty, stringProperties
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface util.PropertyBearing
defaultBoolean, defaultChar, defaultDouble, defaultFloat, defaultInt, defaultLong, defaultObject, defaultObject, defaultProperties, defaultProperty, getAsBoolean, getAsChar, getAsDouble, getAsFloat, getAsInt, getAsList, getAsLong, getAsMap, getAsObject, getAsObject, getLocalized, getProperties, getProperty, getResource, getResourceAsStream, getResources, has, parseObject, removeProperty, setObject, setProperty, stringProperties
 

Field Detail

KEY_ALLOWREOPEN

public static final String KEY_ALLOWREOPEN
The key to the unique trigger name.

See Also:
Constant Field Values

DEFALLOWREOPEN

private static final boolean DEFALLOWREOPEN
The key to the unique trigger name.

See Also:
Constant Field Values

db

private GenericSql db
My SQL instance.

Constructor Detail

AbstractDatabaseParameter

protected AbstractDatabaseParameter(Map prop)
Constructs a new database parameter. The database is opened on init().

Method Detail

init

public void init()
Initializes the database and tries to open it.

Specified by:
init in interface Initializable
Overrides:
init in class AbstractParameter

exit

public void exit()
On exit, we close the database, if we are open.

Specified by:
exit in interface ExitCleaning
Overrides:
exit in class AbstractParameter

get

public Object get()
Gets the parameter from the database. We check, if the database is open and if it is ready. If not, and the KEY_ALLOWREOPEN property points to true, we reopen.


set

public Object set(Object to)
Sets the parameter from the database. We check, if the database is open and if it is ready. If not, and the KEY_ALLOWREOPEN property points to true, we reopen.

Returns:
The previous value of this parameter.

getFromOpenDatabase

protected abstract Object getFromOpenDatabase()
This method is called if the database is ready for data retrieval.


setIntoOpenDatabase

protected abstract Object setIntoOpenDatabase(Object to)
This method is calles if the database is ready to insert a new value.