public class ConfigurationCache extends Object implements ConfigRepositoryIfc
Repository.Meta
Modifier and Type | Field and Description |
---|---|
static String |
CONFIG_DUMP_FILE_PROP_DEF
Field description
|
static String |
CONFIG_DUMP_FILE_PROP_KEY
Field description
|
RELOAD_DELAY, RESOURCE_URI
COMP_REPO_BIND
Constructor and Description |
---|
ConfigurationCache() |
Modifier and Type | Method and Description |
---|---|
void |
addItem(ConfigItem item)
Method description
|
void |
addItem(String compName,
ConfigItem item)
Method description
|
void |
addItem(String key,
Object value)
Method description
|
void |
addItemNoStore(ConfigItem item)
The method adds a new or updates existing Item.
|
void |
addRepoChangeListener(RepositoryChangeListenerIfc<ConfigItem> repoChangeListener)
Method description
|
Collection<ConfigItem> |
allItems()
Method description
|
boolean |
contains(String key)
Method description
|
void |
destroy()
Method destroys this instance of ComponentRepository releasing resources
allocated for this instance of ComponentRepository if possible
|
Object |
get(String compName,
String node,
String key,
Object def)
Method description
|
String[] |
getCompNames()
Method description
|
void |
getDefaults(Map<String,Object> defs,
Map<String,Object> params)
Method description
|
String |
getDefHostname()
Method description
|
Map<String,Object> |
getInitProperties()
Method description
|
ConfigItem |
getItem(String key)
Method description
|
ConfigItem |
getItem(String compName,
String node,
String key)
Method description
|
ConfigItem |
getItemInstance()
Method description
|
Set<ConfigItem> |
getItemsForComponent(String compName)
Method description
|
String[] |
getKeys(String compName,
String node)
Method description
|
Map<String,Object> |
getProperties(String compName)
Method description
|
void |
initRepository(String resource_uri,
Map<String,String> params)
The method is called to initialize the data repository.
|
Iterator<ConfigItem> |
iterator()
Method description
|
void |
putProperties(String compName,
Map<String,Object> props)
Method description
|
void |
reload()
Method description
|
void |
remove(String compName,
String node,
String key)
Method description
|
void |
removeItem(String key)
Method description
|
void |
removeItem(String compName,
ConfigItem item)
Method description
|
void |
removeRepoChangeListener(RepositoryChangeListenerIfc<ConfigItem> repoChangeListener)
Method description
|
void |
set(String compName,
String node,
String key,
Object value)
Method description
|
void |
setAutoloadTimer(long delay)
Method description
|
void |
setDefHostname(String hostname)
Method description
|
void |
setProperties(Map<String,Object> properties)
Method description
|
int |
size()
Method description
|
void |
store()
Method description
|
String |
validateItem(ConfigItem item)
Method description
|
public static final String CONFIG_DUMP_FILE_PROP_DEF
public static final String CONFIG_DUMP_FILE_PROP_KEY
public void addRepoChangeListener(RepositoryChangeListenerIfc<ConfigItem> repoChangeListener)
addRepoChangeListener
in interface ComponentRepository<ConfigItem>
repoChangeListener
- public void removeRepoChangeListener(RepositoryChangeListenerIfc<ConfigItem> repoChangeListener)
removeRepoChangeListener
in interface ComponentRepository<ConfigItem>
repoChangeListener
- public void addItem(String compName, ConfigItem item)
compName
- item
- public void addItemNoStore(ConfigItem item)
ComponentRepository
addItemNoStore
in interface ComponentRepository<ConfigItem>
item
- a Item
with all it's configuration parameters.public void addItem(ConfigItem item) throws TigaseDBException
addItem
in interface ComponentRepository<ConfigItem>
item
- TigaseDBException
public void addItem(String key, Object value) throws ConfigurationException
addItem
in interface ConfigRepositoryIfc
key
- value
- ConfigurationException
public Collection<ConfigItem> allItems() throws TigaseDBException
allItems
in interface ComponentRepository<ConfigItem>
TigaseDBException
public boolean contains(String key)
contains
in interface ComponentRepository<ConfigItem>
key
- boolean
value true
if the item exists
in the repository or false
of it does not.public void destroy()
ComponentRepository
destroy
in interface ComponentRepository<ConfigItem>
public Object get(String compName, String node, String key, Object def)
get
in interface ConfigRepositoryIfc
compName
- node
- key
- def
- public String[] getCompNames()
getCompNames
in interface ConfigRepositoryIfc
public String getDefHostname()
public void getDefaults(Map<String,Object> defs, Map<String,Object> params)
getDefaults
in interface ComponentRepository<ConfigItem>
defs
- params
- public Map<String,Object> getInitProperties()
getInitProperties
in interface ConfigRepositoryIfc
public ConfigItem getItem(String compName, String node, String key)
compName
- node
- key
- public ConfigItem getItem(String key)
getItem
in interface ComponentRepository<ConfigItem>
key
- Item
for a given key or null
if the
item is not in the repository.public ConfigItem getItemInstance()
getItemInstance
in interface ComponentRepository<ConfigItem>
public Set<ConfigItem> getItemsForComponent(String compName)
getItemsForComponent
in interface ConfigRepositoryIfc
compName
- public String[] getKeys(String compName, String node)
getKeys
in interface ConfigRepositoryIfc
compName
- node
- public Map<String,Object> getProperties(String compName) throws ConfigurationException
getProperties
in interface ConfigRepositoryIfc
compName
- ConfigurationException
public void initRepository(String resource_uri, Map<String,String> params) throws DBInitException
Repository
resource_uri
parameter as the database connection string or via params
map if
the required repository parameters are more complex or both.initRepository
in interface Repository
resource_uri
- value in most cases representing the database connection string.params
- is a Map
with repository properties necessary to initialize
and perform all the functions. The initialization parameters are implementation dependent.DBInitException
- if there was an error during repository initialization.
Some implementations, though, perform so called lazy initialization so even though there
is a problem with the underlying repository it may not be signaled through this method
call.public Iterator<ConfigItem> iterator()
iterator
in interface Iterable<ConfigItem>
public void putProperties(String compName, Map<String,Object> props) throws ConfigurationException
putProperties
in interface ConfigRepositoryIfc
compName
- props
- ConfigurationException
public void reload() throws TigaseDBException
reload
in interface ComponentRepository<ConfigItem>
TigaseDBException
public void remove(String compName, String node, String key)
remove
in interface ConfigRepositoryIfc
compName
- node
- key
- public void removeItem(String compName, ConfigItem item)
compName
- item
- public void removeItem(String key) throws TigaseDBException
removeItem
in interface ComponentRepository<ConfigItem>
key
- TigaseDBException
public void set(String compName, String node, String key, Object value)
set
in interface ConfigRepositoryIfc
compName
- node
- key
- value
- public void setDefHostname(String hostname)
setDefHostname
in interface ConfigRepositoryIfc
hostname
- public void setProperties(Map<String,Object> properties)
setProperties
in interface ComponentRepository<ConfigItem>
properties
- public int size()
size
in interface ComponentRepository<ConfigItem>
int
value with number of items in the repository.public void store() throws TigaseDBException
store
in interface ComponentRepository<ConfigItem>
TigaseDBException
public String validateItem(ConfigItem item)
validateItem
in interface ComponentRepository<ConfigItem>
item
- null
on success and an error message otherwise.public void setAutoloadTimer(long delay)
setAutoloadTimer
in interface ComponentRepository<ConfigItem>
delay
- Copyright © 2014 "Tigase, Inc.". All rights reserved.