public abstract class ConfigRepository<Item extends RepositoryItem> extends Object implements ComponentRepository<Item>, Initializable, UnregisterAware
Repository.Meta, Repository.SchemaId
Modifier and Type | Field and Description |
---|---|
protected long |
autoReloadInterval |
protected Map<String,Item> |
items |
protected int |
itemsHash |
COMP_REPO_BIND
Constructor and Description |
---|
ConfigRepository() |
Modifier and Type | Method and Description |
---|---|
void |
addItem(Item item)
The method adds a new or updates existing Item in the repository.
|
void |
addItemNoStore(Item item)
The method adds a new or updates existing Item.
|
void |
addRepoChangeListener(RepositoryChangeListenerIfc<Item> repoChangeListener)
Adds a listener for repository Item change.
|
Collection<Item> |
allItems()
Returns a collection with all items stored in the repository.
|
void |
beforeUnregister()
Method called before bean unregister.
|
boolean |
contains(String key)
The method checks whether the item is stored in the repository.
|
abstract String |
getConfigKey() |
Item[] |
getDefaultItems() |
String[] |
getDefaultPropetyItems()
Deprecated.
|
void |
getDefaults(Map<String,Object> defs,
Map<String,Object> params)
Deprecated.
|
Item |
getItem(String key)
The method returns all item configuration parameters for a key or
null if the item does not exist in
the repository. |
String[] |
getItemsOld()
Deprecated.
|
abstract String |
getPropertyKey()
Deprecated.
|
void |
initialize()
Method will be called, when bean will be created, configured and ready to use.
|
protected void |
initItemsMap()
Method create instance of items Map.
|
protected boolean |
isInitialized() |
boolean |
itemChanged(Item oldItem,
Item newItem) |
Iterator<Item> |
iterator() |
void |
reload()
This method is called to reload items from the database or other permanent storage.
|
void |
removeItem(String key)
The method is called to remove given Item from the memory cache and permanent storage.
|
void |
removeItemNoStore(String key) |
void |
removeRepoChangeListener(RepositoryChangeListenerIfc<Item> repoChangeListener)
Removes a listener for repository Item change.
|
void |
setAutoloadTimer(long delay)
Sets autoload task to periodically reload data from database.
|
void |
setAutoReloadInterval(long autoLoadInterval) |
void |
setItemsOld(String[] items_arr)
Deprecated.
|
void |
setProperties(Map<String,Object> properties)
Deprecated.
|
int |
size()
The method returns number of items in the repository.
|
void |
store()
The method is called to store all data in the database.
|
String |
toString() |
String |
validateItem(Item item)
Performs Item validation to check whether it meets the repository policy.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
destroy, getItemInstance
forEach, spliterator
initRepository
@ConfigField(desc="Automatic items load interval", alias="repo-autoreload-interval") protected long autoReloadInterval
protected Map<String,Item extends RepositoryItem> items
protected int itemsHash
public void setAutoloadTimer(long delay)
ComponentRepository
setAutoloadTimer
in interface ComponentRepository<Item extends RepositoryItem>
delay
- in seconds between each database reload.public void setAutoReloadInterval(long autoLoadInterval)
public void addRepoChangeListener(RepositoryChangeListenerIfc<Item> repoChangeListener)
ComponentRepository
addRepoChangeListener
in interface ComponentRepository<Item extends RepositoryItem>
public void removeRepoChangeListener(RepositoryChangeListenerIfc<Item> repoChangeListener)
ComponentRepository
removeRepoChangeListener
in interface ComponentRepository<Item extends RepositoryItem>
public abstract String getConfigKey()
public Item[] getDefaultItems()
@Deprecated public String[] getDefaultPropetyItems()
@Deprecated public abstract String getPropertyKey()
public void addItem(Item item)
ComponentRepository
addItem
in interface ComponentRepository<Item extends RepositoryItem>
item
- a Item
with all it's configuration parameters.public void addItemNoStore(Item item)
ComponentRepository
addItemNoStore
in interface ComponentRepository<Item extends RepositoryItem>
item
- a Item
with all it's configuration parameters.public Collection<Item> allItems()
ComponentRepository
allItems
in interface ComponentRepository<Item extends RepositoryItem>
public boolean contains(String key)
ComponentRepository
contains
in interface ComponentRepository<Item extends RepositoryItem>
key
- a String
with key to search for.boolean
value true
if the item exists in the repository or false
of it does not.@Deprecated public void getDefaults(Map<String,Object> defs, Map<String,Object> params)
ComponentRepository
getDefaults
in interface ComponentRepository<Item extends RepositoryItem>
defs
- is a Map
collection where all repository configuration defaults must be put.params
- is a Map
collection with some preset properties for the server. These settings can be
used to adjust repository defaults, for example they can contain database connection URL or initial list of
virtual domains.public Item getItem(String key)
ComponentRepository
null
if the item does not exist in
the repository.getItem
in interface ComponentRepository<Item extends RepositoryItem>
key
- a String
with item identifier to search for.Item
for a given key or null
if the item is not in the repository.@Deprecated public String[] getItemsOld()
@Deprecated public void setItemsOld(String[] items_arr)
public Iterator<Item> iterator()
iterator
in interface Iterable<Item extends RepositoryItem>
public void reload()
ComponentRepository
reload
in interface ComponentRepository<Item extends RepositoryItem>
public void removeItem(String key)
ComponentRepository
removeItem
in interface ComponentRepository<Item extends RepositoryItem>
key
- a String
with domain name to remove.public void removeItemNoStore(String key)
removeItemNoStore
in interface ComponentRepository<Item extends RepositoryItem>
@Deprecated public void setProperties(Map<String,Object> properties)
ComponentRepository
setProperties
in interface ComponentRepository<Item extends RepositoryItem>
properties
- a Map
with configuration settings. Content of this Map
must not be
modified. This read-only collection.public int size()
ComponentRepository
size
in interface ComponentRepository<Item extends RepositoryItem>
int
value with number of items in the repository.public void store()
ComponentRepository
store
in interface ComponentRepository<Item extends RepositoryItem>
public String validateItem(Item item)
ComponentRepository
null
, otherwise it returns an error description.validateItem
in interface ComponentRepository<Item extends RepositoryItem>
item
- is an Item
object to perform validation checking upon.null
on success and an error message otherwise.public void beforeUnregister()
UnregisterAware
beforeUnregister
in interface UnregisterAware
public void initialize()
Initializable
initialize
in interface Initializable
protected void initItemsMap()
protected boolean isInitialized()
Copyright © 2004–2020 "Tigase, Inc.". All rights reserved.