Class DbProperties
java.lang.Object
de.businesscode.bcdui.toolbox.config.DbProperties
this class loads the configuration properties from database,
this class is thread-safe and can also be used as a singleton,
the
getProperties(String)
method is used to retrieve properties and
it will keep the internal data up-to-date in case refreshCycleSec
has
been set in constructor. You may want to set setListener(Listener)
to
listen to updates.
This class has no threads monitoring the age of data, so the reload does not happen
fully on its own, rather the aging is checked on following methods:
getProperties(String)
, reloadIfAged()
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionDbProperties
(String bindingSetId, int refreshCycleSec) create DbProperties instance, the properties are NOT initialized/loaded, considerreload()
orscheduleReload()
-
Method Summary
Modifier and TypeMethodDescriptionlong
getProperties
(String scopeId) boolean
reload()
triggers reload of properties, this is a *blocking* call, if you want to reload properties asynchronously usescheduleReload()
method, however only one concurrent reload is processed, so that if multiple threads call this method simultaneously the first one initiates a reload while other calls are discarded and this method returns immediately with 'false'void
this method has no effect in case no refreshCycle was set during construction, otherwise it schedules load in case of aged datavoid
triggers scheduled reload of properties and returns immediately, however, the load is performed only once in a time, even though this method is called from multiple threads simulatenously, while loading other calls to this methds are ignored.void
scheduleReload
(long refreshCycleSec) unlikescheduleReload()
this method schedules the reload only in case the last reload time is older than given 'maturedTimeMs' such thatgetLastRefreshTime()
+ maturedTimeMs <= current timevoid
setListener
(DbProperties.Listener listener)
-
Constructor Details
-
DbProperties
create DbProperties instance, the properties are NOT initialized/loaded, considerreload()
orscheduleReload()
- Parameters:
bindingSetId
-refreshCycleSec
- to refresh the properties, may be 0 to disable auto-refresh cycle- Throws:
BindingException
- if binding-set could not be obtained or was not foundRuntimeException
- in case name of DataSource could not be obtained
-
-
Method Details
-
setListener
-
reload
public boolean reload()triggers reload of properties, this is a *blocking* call, if you want to reload properties asynchronously usescheduleReload()
method, however only one concurrent reload is processed, so that if multiple threads call this method simultaneously the first one initiates a reload while other calls are discarded and this method returns immediately with 'false'- Returns:
- true if properties have been reloaded or false if another concurrent reload is in process, so this call has had no effect
-
scheduleReload
public void scheduleReload()triggers scheduled reload of properties and returns immediately, however, the load is performed only once in a time, even though this method is called from multiple threads simulatenously, while loading other calls to this methds are ignored. calling this methods effectively is same asscheduleReload(long)
with 0 as parameter. -
scheduleReload
public void scheduleReload(long refreshCycleSec) unlikescheduleReload()
this method schedules the reload only in case the last reload time is older than given 'maturedTimeMs' such thatgetLastRefreshTime()
+ maturedTimeMs <= current time- Parameters:
refreshCycleSec
- the mature time offset or 0 to schedule immediately
-
getLastRefreshTime
public long getLastRefreshTime()- Returns:
- the last refresh ms
-
getProperties
- Parameters:
scopeId
-- Returns:
- property-set for given scope, may be NULL if no such scope exists
-
reloadIfAged
public void reloadIfAged()this method has no effect in case no refreshCycle was set during construction, otherwise it schedules load in case of aged data
-