IConfCache
, Action<ConfEvent>
, Subscriber<ConfEvent>
, SubscriptionService<ConfCacheEvent>
, AsyncInvokerSupport
public final class DefaultConfCache extends java.lang.Object implements IConfCache, SubscriptionService<ConfCacheEvent>, AsyncInvokerSupport
Constructor | Description |
---|---|
DefaultConfCache() |
Creates a cache which will use the default policy, storage and query
engine.
|
DefaultConfCache(IConfCachePolicy cachePolicy,
IConfCacheStorage cacheStorage,
IConfCacheQueryEngine cacheQueryEngine) |
Creates a new instance of the configuration cache.
|
Modifier and Type | Method | Description |
---|---|---|
void |
add(ICfgObject obj) |
Adds a new configuration object to the cache.
|
void |
addEndpoint(Endpoint endpoint) |
Adds a supported endpoint to the list.
|
java.util.concurrent.Future<IConfCache> |
beginRefresh(AsyncInvoker asyncInvoker,
Action<java.util.concurrent.Future<IConfCache>> finishCallback) |
Asynchronously updates all configuration objects in the cache.
|
void |
clear() |
Removes all cache contents.
|
boolean |
contains(ICfgObject obj) |
Determines whether the cache contains the specified object.
|
void |
deserialize(java.io.InputStream stream) |
Deserializes the cache from the specified stream.
|
void |
deserialize(javax.xml.transform.Source source) |
Deserializes the cache from the specified source.
|
protected void |
deserialize(org.w3c.dom.Node source) |
Deserializes the cache from the specified source.
|
void |
endRefresh(java.util.concurrent.Future<IConfCache> asyncResult) |
To be called when the asynchronous refresh operation is complete.
|
int |
getEndpointCount() |
|
Predicate<ConfEvent> |
getFilter() |
Gets filter predicate that allows checking whether publishing
event should be processed or ignored.
|
IConfCachePolicy |
getPolicy() |
Returns the current policy associated with this cache.
|
void |
handle(ConfEvent configEvent) |
|
void |
refresh() |
Synchronously updates all configuration objects which are currently in the cache.
|
void |
register(Action<ConfCacheEvent> handler,
Predicate<ConfCacheEvent> filter) |
Registers a delegate for receiving notifications from the cache
based on the specified filter.
|
void |
register(Subscriber<ConfCacheEvent> subscriber) |
Registers a subscriber object for receiving notifications from
the cache.
|
void |
remove(ICfgObject obj) |
Removes the specified configuration object from the cache.
|
void |
remove(CfgObjectType type,
int dbid) |
Removes the configuration object with the specified type and dbid
from the cache.
|
boolean |
removeEndpoint(Endpoint endpoint) |
|
<T extends ICfgObject> |
retrieve(java.lang.Class<T> cls,
ICfgQuery query) |
Retrieves a configuration object from the cache using the cache's
query engine.
|
<T extends ICfgObject> |
retrieve(java.lang.Class<T> cls,
CfgObjectType type,
int dbid) |
Retrieves a configuration object from the cache using the cache's
query engine.
|
<T extends ICfgObject> |
retrieveMultiple(java.lang.Class<T> cls) |
Retrieves an enumerable list of all configuration objects in the storage.
|
<T extends ICfgObject> |
retrieveMultiple(java.lang.Class<T> cls,
ICfgQuery query) |
Retrieves an enumerable list of objects from the cache using the cache's query engine.
|
void |
serialize(java.io.OutputStream stream) |
Serializes the cache into the specified stream.
|
void |
serialize(javax.xml.transform.Result result) |
Serializes the cache into the specified result.
|
void |
setInvoker(AsyncInvoker value) |
|
void |
setPolicy(IConfCachePolicy cachePolicy) |
|
void |
unregister(Action<ConfCacheEvent> handler) |
Unregisters the specified delegate from notifications.
|
void |
unregister(Subscriber<ConfCacheEvent> subscriber) |
Unregisters the subscriber from event notifications.
|
void |
update(ICfgObject obj) |
Overwrites a configuration object which already exists in the cache
with a new copy.
|
public DefaultConfCache()
public DefaultConfCache(IConfCachePolicy cachePolicy, IConfCacheStorage cacheStorage, IConfCacheQueryEngine cacheQueryEngine)
cachePolicy
- The cache policycacheStorage
- The storage to be used in this cachecacheQueryEngine
- The query engine to be used to retrieve
data from the storagepublic void setInvoker(AsyncInvoker value)
setInvoker
in interface AsyncInvokerSupport
public int getEndpointCount()
public void addEndpoint(Endpoint endpoint)
endpoint
- The endpoint of a configuration serverpublic boolean removeEndpoint(Endpoint endpoint)
public void add(ICfgObject obj)
add
in interface IConfCache
obj
- A configuration objectpublic void update(ICfgObject obj)
update
in interface IConfCache
obj
- A configuration objectpublic void remove(ICfgObject obj)
remove
in interface IConfCache
obj
- A configuration objectpublic void remove(CfgObjectType type, int dbid)
remove
in interface IConfCache
type
- The type of configuration objectdbid
- The dbid of the configuration objectpublic <T extends ICfgObject> T retrieve(java.lang.Class<T> cls, CfgObjectType type, int dbid)
retrieve
in interface IConfCache
T
- The type of configuration object that should be returnedcls
- class of object to be retrievedtype
- The type of configuration objectdbid
- The dbid of the configuration objectpublic <T extends ICfgObject> T retrieve(java.lang.Class<T> cls, ICfgQuery query)
retrieve
in interface IConfCache
T
- The type of configuration object that should be returnedcls
- class of object to be retrievedquery
- A query based on which the result is obtainedpublic <T extends ICfgObject> java.lang.Iterable<T> retrieveMultiple(java.lang.Class<T> cls, ICfgQuery query)
retrieveMultiple
in interface IConfCache
T
- The types of configuration objects to be included in the listcls
- class of object to be retrievedquery
- A query based on which the result is obtainedpublic <T extends ICfgObject> java.lang.Iterable<T> retrieveMultiple(java.lang.Class<T> cls)
retrieveMultiple
in interface IConfCache
T
- The type of configuration object to include
(use ICfgObject to retrieve an enumeration of all stored objects)cls
- class of object to be retrievedpublic void serialize(java.io.OutputStream stream)
stream
- The stream into which the cache is to be writtenpublic void serialize(javax.xml.transform.Result result)
serialize
in interface IConfCache
result
- The result into which the cache is to be writtenStreamResult
,
DOMResult
public void deserialize(java.io.InputStream stream)
stream
- The stream from which the cache is to be readpublic void deserialize(javax.xml.transform.Source source)
deserialize
in interface IConfCache
source
- The source from which the cache is to be readStreamSource
,
DOMSource
protected void deserialize(org.w3c.dom.Node source)
source
- The source from which the cache is to be readStreamSource
,
DOMSource
public void clear()
clear
in interface IConfCache
public void refresh() throws ConfigException, java.lang.InterruptedException
refresh
in interface IConfCache
ConfigException
- is thrown in case of object(s) reload exceptionjava.lang.InterruptedException
- is thrown if task has been interruptedpublic java.util.concurrent.Future<IConfCache> beginRefresh(AsyncInvoker asyncInvoker, Action<java.util.concurrent.Future<IConfCache>> finishCallback)
AsyncInvoker invoker =
new SingleThreadInvoker("CacheAsyncRefresh");
Future asyncRefresh =
cache.beginRefresh(invoker, null);
// DO SOMETHING...
// To check that refresh is done:
if (asyncRefresh.isDone()) {
// ...
}
// To wait for refresh is done:
asyncRefresh.get();
// After refresh is done and invoker is not needed:
invoker.dispose();
beginRefresh
in interface IConfCache
asyncInvoker
- invoker for refresh task executionfinishCallback
- The callback method to be invoked when the operation completespublic void endRefresh(java.util.concurrent.Future<IConfCache> asyncResult)
endRefresh
in interface IConfCache
asyncResult
- The async result associated with the current operationpublic IConfCachePolicy getPolicy()
getPolicy
in interface IConfCache
public void setPolicy(IConfCachePolicy cachePolicy)
public boolean contains(ICfgObject obj)
contains
in interface IConfCache
obj
- The configuration object to look forpublic void register(Subscriber<ConfCacheEvent> subscriber)
register
in interface SubscriptionService<ConfCacheEvent>
subscriber
- the "subscriber" object which will handle the notificationspublic void register(Action<ConfCacheEvent> handler, Predicate<ConfCacheEvent> filter)
register
in interface SubscriptionService<ConfCacheEvent>
handler
- The delegate which will handle the eventfilter
- A filter to apply to the eventpublic void unregister(Subscriber<ConfCacheEvent> subscriber)
unregister
in interface SubscriptionService<ConfCacheEvent>
subscriber
- the subscriber to unregisterpublic void unregister(Action<ConfCacheEvent> handler)
unregister
in interface SubscriptionService<ConfCacheEvent>
handler
- the function to unregisterpublic Predicate<ConfEvent> getFilter()
Subscriber
getFilter
in interface Subscriber<ConfEvent>
Send comments on this topicTechpubs.webadmin@genesys.com.
Document version: 9.0.006.00
Copyright © 2006–2019 Genesys Telecommunications Laboratories, Inc. All rights reserved.