public class DataBaseConfigService extends java.lang.Object implements ConfigService
ConfigService
that adds additional properties from a database table.
This is a wrapper that decorates a previously installed ConfigService
.
The name of the table to store the properties is taken from a property database.properties
from the nested service. If this property is not found then this service will just foward to the nested service.
There is a nasty potential circular dependency where the DatabaseService
needed to
query the database table may need the ConfigService
and may end up calling back to this class.
during setup. This is particularly nasty if there is a CachedConfigService
in the stack as we have to make sure that
the cache does not end up holding state from before the DB is read or from a transient database error state.Modifier and Type | Field and Description |
---|---|
static java.lang.String |
NAME |
static java.lang.String |
VALUE |
Constructor and Description |
---|
DataBaseConfigService(AppContext ctx) |
Modifier and Type | Method and Description |
---|---|
void |
addListener(ConfigServiceListener listener)
register a ConfigServiceListener
|
void |
cleanup()
AppContext is being closed. |
void |
clearServiceProperties()
clear any cached properties.
|
AppContext |
getContext() |
java.util.Properties |
getServiceProperties()
return the set of properties defined by the service
|
java.lang.Class<ConfigService> |
getType()
Returns the type of service the class should be registered under.
|
void |
setProperty(java.lang.String name,
java.lang.String value)
Set a property
This method is for making persistent changes to the configuration.
|
public static final java.lang.String VALUE
public static final java.lang.String NAME
public DataBaseConfigService(AppContext ctx) throws java.sql.SQLException
java.sql.SQLException
public void clearServiceProperties()
ConfigService
clearServiceProperties
in interface ConfigService
public java.util.Properties getServiceProperties()
ConfigService
getServiceProperties
in interface ConfigService
public AppContext getContext()
getContext
in interface Contexed
public void setProperty(java.lang.String name, java.lang.String value) throws java.lang.UnsupportedOperationException
ConfigService
UnsupportedOperationException
setProperty
in interface ConfigService
java.lang.UnsupportedOperationException
public void cleanup()
AppContextCleanup
AppContext
is being closed.
Only use this for cleanup that can't be handled by
normal garbage collection or for state which is never returned by reference.cleanup
in interface AppContextCleanup
public void addListener(ConfigServiceListener listener)
ConfigService
addListener
in interface ConfigService
public java.lang.Class<ConfigService> getType()
AppContextService
getType
in interface AppContextService<ConfigService>