|
Platform SDK Java 8.5 API Reference | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.genesyslab.platform.applicationblocks.com.ConfService
public class ConfService
This class holds a reference to the connection to Configuration Server (ConfServerProtocol
).
Please, use this class to create new instances of configuration objects, subscribe to events, register on
notifications.
ConfServiceFactory
Constructor Summary | |
---|---|
protected |
ConfService(Protocol protocol)
Creates a new instance of the class. |
Method Summary | ||
---|---|---|
protected boolean |
addObjectOnRetrieve(ICfgObject object)
|
|
|
beginRetrieveMultipleObjects(java.lang.Class<T> cls,
ICfgQuery query,
Action<AsyncRequestResult<T>> finishCallback)
Starts reading of configuration objects collection from server. |
|
|
beginRetrieveMultipleObjects(java.lang.Class<T> cls,
ICfgQuery query,
Action<java.util.Collection<T>> dataCallback,
Action<AsyncRequestResult<T>> finishCallback)
Starts reading of configuration objects collection from server. |
|
|
beginRetrieveMultipleObjects(java.lang.Class<T> cls,
ICfgQuery query,
Action<java.util.Collection<T>> dataCallback,
Action<AsyncRequestResult<T>> finishCallback,
long timeout)
Starts reading of configuration objects collection from server. |
|
|
createMultipleObjects(ConfDataCollection<? extends ConfObjectBase> confObjects,
java.lang.String[] objectsPaths,
int[] foldersDbids)
Wraps a single configuration structure with COM configuration object using the passed parameters. |
|
java.util.Collection<ICfgObject> |
createMultipleObjects(ConfObjectsCollection confObjects)
Creates collection of COM configuration objects using the passed parameters. |
|
java.util.Collection<ICfgObject> |
createMultipleObjectsFromXML(org.w3c.dom.Node confObjectsContainer)
Creates a list of configuration objects based on XML received from Configuration Server. Usage sample:
|
|
java.util.Collection<ICfgObject> |
createMultipleObjectsFromXML(org.w3c.dom.NodeList confObjects)
Creates a list of configuration objects based on XML received from Configuration Server. |
|
|
createMultipleObjectsFromXML(org.w3c.dom.NodeList confObjects,
java.lang.String[] objectsPaths,
int[] foldersDbids)
Creates a list of COM configuration objects using the passed parameters. |
|
|
createMultipleObjectsFromXML(org.w3c.dom.Node confObjectsContainer,
java.lang.String[] objectsPaths,
int[] foldersDbids)
Creates a list of COM configuration objects using the passed parameters. |
|
ICfgObject |
createObject(ConfObjectBase confObject,
boolean isSaved)
Wraps a single configuration structure with COM configuration object using the passed parameters. |
|
ICfgObject |
createObject(ConfObjectBase confObject,
java.lang.String objectPath,
int folderDbid,
boolean isSaved)
Wraps a single configuration structure with COM configuration object using the passed parameters. |
|
ICfgObject |
createObjectFromXML(org.w3c.dom.Node confObject,
boolean isSaved)
Creates a single COM configuration object using the passed parameters. |
|
ICfgObject |
createObjectFromXML(org.w3c.dom.Node confObject,
java.lang.String objectPath,
int folderDbid,
boolean isSaved)
Creates a single COM configuration object using the passed parameters. |
|
void |
deleteObject(ICfgObject cfgObject)
Deletes configuration object from the Configuration Server. |
|
|
endRetrieveMultipleObjects(AsyncRequestResult<T> rqResult)
Waits until asynchronous reading operation done and return requested data. |
|
protected void |
exceptionIfDisposed()
Ensures that this ConfService instance is not disposed. |
|
IConfCache |
getCache()
Returns an instance of the configuration cache or null if caching is not enabled. |
|
protected AsyncInvoker |
getInvokerNotNull()
|
|
protected ILogger |
getLogger()
|
|
CfgMetadata |
getMetaData()
Returns reference to the configuration Metadata. |
|
IConfServicePolicy |
getPolicy()
Returns the policy associated with this service. |
|
Protocol |
getProtocol()
Returns a reference to the protocol connection to Configuration Server. |
|
boolean |
isDisposed()
|
|
protected KeyValueCollection |
prepareReadObjectsFilter(ICfgFilterBasedQuery query)
|
|
protected Message |
prepareRequestReadBriefInfoMessage(ICfgQuery query)
|
|
protected Message |
prepareRequestReadObjectsMessage(ICfgQuery query)
Create Configuration Protocol Request Message for configuration objects reading. |
|
void |
refreshObject(ICfgObject cfgObject)
Reloads configuration object data from the Configuration Server. |
|
void |
register(Action<ConfEvent> handler,
Predicate<ConfEvent> filter)
Registers custom handler for ConfigurationEvent's handling. |
|
void |
register(Subscriber<ConfEvent> subscriber)
Registers custom handler for ConfigurationEvent's handling. |
|
|
retrieveMultipleObjects(java.lang.Class<T> cls,
ICfgQuery query)
Reads collection of configuration objects from server. |
|
|
retrieveMultipleObjects(java.lang.Class<T> cls,
ICfgQuery query,
long timeout)
Retrieves a list of typed objects based on the specified query. |
|
ICfgObject |
retrieveObject(CfgObjectType objectType,
int dbId)
Reads configuration object from server by object type and DBID. |
|
|
retrieveObject(java.lang.Class<T> cls,
ICfgQuery query)
Reads configuration object from server. |
|
|
retrieveObject(ICfgQuery<T> query)
Retrieves an object based on the specified query. |
|
protected
|
retrieveObject(T confObj,
ICfgQuery query)
Deprecated. |
|
protected
|
retrieveObject(T confObj,
ICfgQuery query,
boolean isBriefInfo)
Reads or refreshes configuration object from server. |
|
void |
saveObject(ICfgObject cfgObject)
Saves local object modifications to the configuration server or create new one if it has been created locally. |
|
void |
setBrokerInvoker(AsyncInvoker invoker)
Sets user defined custom invoker for ConfEvent broker. |
|
void |
setInvoker(AsyncInvoker invoker)
Sets user defined custom invoker for callback notifications on asynchronous multiple objects reading operations. |
|
void |
setUserMessageHandler(MessageHandler msgHandler)
Sets extra MessageHandler for custom handling of incoming asynchronous protocol messages on the channel. It will be called in the protocol invoker thread after procession by the ConfService internal handler. |
|
Subscription |
subscribe(ICfgObject obj)
Subscribes to receiving notifications from Configuration Server. |
|
Subscription |
subscribe(NotificationQuery query)
Subscribes to receiving notifications from Configuration Server. |
|
void |
unregister(Action<ConfEvent> handler)
Unregisters custom ConfigurationEvent's handler. |
|
void |
unregister(Subscriber<ConfEvent> subscriber)
Unregisters custom ConfigurationEvent's handler. |
|
void |
unsubscribe(Subscription subscription)
Unsubscribes from the subscription on the Configuration server. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
protected ConfService(Protocol protocol)
protocol
- A reference to a connection to Configuration ServerMethod Detail |
---|
public boolean isDisposed()
protected void exceptionIfDisposed()
java.lang.IllegalStateException
- if service is disposed.public CfgMetadata getMetaData()
IConfService
getMetaData
in interface IConfService
protected ILogger getLogger()
public Protocol getProtocol()
getProtocol
in interface IConfService
public void setUserMessageHandler(MessageHandler msgHandler)
setUserMessageHandler
in interface IConfService
msgHandler
- user handlerprotected AsyncInvoker getInvokerNotNull()
public void setInvoker(AsyncInvoker invoker)
setInvoker
in interface IConfService
setInvoker
in interface AsyncInvokerSupport
invoker
- user defined invoker
java.lang.IllegalStateException
- if service is already disposed.beginRetrieveMultipleObjects(Class, ICfgQuery, Action)
,
beginRetrieveMultipleObjects(Class, ICfgQuery, Action, Action)
public void setBrokerInvoker(AsyncInvoker invoker)
setBrokerInvoker
in interface IConfService
invoker
- user defined invoker
java.lang.IllegalStateException
- if service is already disposed.public IConfCache getCache()
IConfService
getCache
in interface IConfService
public IConfServicePolicy getPolicy()
IConfService
getPolicy
in interface IConfService
public ICfgObject retrieveObject(CfgObjectType objectType, int dbId) throws ConfigException
retrieveObject
in interface IConfService
objectType
- type of configuration object to be readdbId
- object DBID
ConfigException
- in case of problems while reading data from server.
java.lang.IllegalStateException
- if service is already disposed.public <T extends ICfgObject> T retrieveObject(ICfgQuery<T> query) throws ConfigException
retrieveObject
in interface IConfService
query
- the query by which to retrieve the object
ConfigException
- in case of problems while reading data from server.
java.lang.IllegalArgumentException
- if query type is unsupported.
java.lang.IllegalStateException
- if service is already disposed.public <T extends ICfgObject> T retrieveObject(java.lang.Class<T> cls, ICfgQuery query) throws ConfigException
retrieveObject
in interface IConfService
T
- specific wrapping class of particular configuration object typecls
- class used for generic matchingquery
- query for object reading
ConfigException
- in case of problems while reading data from server.
java.lang.IllegalArgumentException
- if query type is unsupported.
java.lang.IllegalStateException
- if service is already disposed.retrieveObject(com.genesyslab.platform.configuration.protocol.types.CfgObjectType, int)
public <T extends ICfgObject> java.util.Collection<T> retrieveMultipleObjects(java.lang.Class<T> cls, ICfgQuery query) throws ConfigException, java.lang.InterruptedException
beginRetrieveMultipleObjects(Class, ICfgQuery, Action)
.
retrieveMultipleObjects
in interface IConfService
T
- specific wrapping class of particular configuration objects typecls
- class used for generic matchingquery
- query for objects reading
ConfigException
- in case of problems while reading data from server.
java.lang.InterruptedException
- in case of forced interrupt.
java.lang.IllegalStateException
- if service is already disposed.
java.lang.IllegalArgumentException
- if query type is unsupported.public <T extends ICfgObject> java.util.Collection<T> retrieveMultipleObjects(java.lang.Class<T> cls, ICfgQuery query, long timeout) throws ConfigException, java.lang.InterruptedException
retrieveMultipleObjects
in interface IConfService
T
- The type of objects to retrievequery
- the query by which to retrieve the objectstimeout
- timeout in milliseconds which will be used for waiting messages from server
(excluding parsing time of messages)
java.lang.IllegalStateException
- if service is already disposed.
java.lang.IllegalArgumentException
- if query type is unsupported.
ConfigException
- in case of problems while reading data from server.
java.lang.InterruptedException
public void saveObject(ICfgObject cfgObject) throws ConfigException
saveObject
in interface IConfService
cfgObject
- configuration object instance
ConfigException
- in case of problems on object update or create operations.
java.lang.IllegalStateException
- if service is already disposed.public void deleteObject(ICfgObject cfgObject) throws ConfigException
deleteObject
in interface IConfService
cfgObject
- configuration object instance
ConfigException
- in case of problems on object remove operation.
java.lang.IllegalStateException
- if service is already disposed.public void refreshObject(ICfgObject cfgObject) throws ConfigException
refreshObject
in interface IConfService
cfgObject
- configuration object instance
ConfigException
- in case of problems on object read operation.
java.lang.IllegalStateException
- if service is already disposed.public void register(Subscriber<ConfEvent> subscriber)
register
in interface SubscriptionService<ConfEvent>
subscriber
- user defined events handler
java.lang.IllegalStateException
- if service is already disposed.unregister(Subscriber)
public void register(Action<ConfEvent> handler, Predicate<ConfEvent> filter)
register
in interface SubscriptionService<ConfEvent>
handler
- user defined events handlerfilter
- configuration events filter
java.lang.IllegalStateException
- if service is already disposed.unregister(Action)
public void unregister(Subscriber<ConfEvent> subscriber)
unregister
in interface SubscriptionService<ConfEvent>
subscriber
- user defined events handlerregister(Subscriber)
,
register(Action, Predicate)
public void unregister(Action<ConfEvent> handler)
unregister
in interface SubscriptionService<ConfEvent>
handler
- user defined events handlerregister(Subscriber)
,
register(Action, Predicate)
public Subscription subscribe(NotificationQuery query) throws ConfigException
Register
method
so that events reach the event handler.
subscribe
in interface IConfService
query
- query for subscription
ConfigException
- exception while working with server side.
java.lang.IllegalStateException
- if service is already disposed.unsubscribe(Subscription)
public Subscription subscribe(ICfgObject obj) throws ConfigException
Register
method
so that events reach the event handler.
subscribe
in interface IConfService
obj
- object to listen events on
ConfigException
- exception while working with server side.
java.lang.IllegalStateException
- if service is already disposed.unsubscribe(Subscription)
public void unsubscribe(Subscription subscription) throws ConfigException
unsubscribe
in interface IConfService
subscription
- subscription holder got with call to
subscribe(ICfgObject)
or subscribe(NotificationQuery)
.
ConfigException
- exception while working with server side.
java.lang.IllegalStateException
- if service is already disposed.subscribe(ICfgObject)
,
subscribe(NotificationQuery)
protected <T extends ICfgObject> T retrieveObject(T confObj, ICfgQuery query) throws ConfigException
confObj
- object instance to refresh or nullquery
- query for object reading
ConfigException
- in case of problems while reading data from server.
java.lang.IllegalStateException
- if service is already disposed.retrieveObject(com.genesyslab.platform.configuration.protocol.types.CfgObjectType, int)
,
retrieveObject(ICfgObject, ICfgQuery, boolean)
protected <T extends ICfgObject> T retrieveObject(T confObj, ICfgQuery query, boolean isBriefInfo) throws ConfigException
confObj
- object instance to refresh or nullquery
- query for object readingisBriefInfo
- flag for objects' brief info request (is used when confObj is null)
ConfigException
- in case of problems while reading data from server
java.lang.IllegalStateException
- if service is already disposed.retrieveObject(com.genesyslab.platform.configuration.protocol.types.CfgObjectType, int)
protected KeyValueCollection prepareReadObjectsFilter(ICfgFilterBasedQuery query)
protected Message prepareRequestReadBriefInfoMessage(ICfgQuery query)
public <T extends ICfgObject> AsyncRequestResult<T> beginRetrieveMultipleObjects(java.lang.Class<T> cls, ICfgQuery query, Action<AsyncRequestResult<T>> finishCallback) throws ConfigException
setInvoker(AsyncInvoker)
before this method invocation if we have non-null callback.
// application initialization AsyncInvoker inv = InvokerFactory.namedInvoker("my"); confService.setInvoker(inv); // … Action<AsyncRequestResult<CfgApplication>> callback = new Action<AsyncRequestResult<CfgApplication>>() { public void handle(final AsyncRequestResult<CfgApplication> obj) { try { Collection<CfgApplication> applications = obj.get(); // todo : process the result } catch (Exception e) { e.printStackTrace(); } } }; // Start application configuration objects reading: AsyncRequestResult<CfgApplication> asyncRequest = confService.beginRetrieveMultipleObjects(CfgApplication.class, new CfgApplicationQuery(), callback); // application deinitialization confService.setInvoker(null); InvokerFactory. releaseInvoker("my");
beginRetrieveMultipleObjects
in interface IConfService
T
- specific wrapping class of particular configuration objects typecls
- class used for generic matchingquery
- query for objects readingfinishCallback
- user defined callback action for data readiness notification or null
ConfigException
- in case of problems while reading data from server.
java.lang.IllegalArgumentException
- if query type is unsupported.
java.lang.IllegalStateException
- if service is already disposed.setInvoker(AsyncInvoker)
public <T extends ICfgObject> AsyncRequestResult<T> beginRetrieveMultipleObjects(java.lang.Class<T> cls, ICfgQuery query, Action<java.util.Collection<T>> dataCallback, Action<AsyncRequestResult<T>> finishCallback) throws ConfigException
setInvoker(AsyncInvoker)
before this method invocation if we have non-null callback.
beginRetrieveMultipleObjects
in interface IConfService
T
- specific wrapping class of particular configuration objects typecls
- class used for generic matchingquery
- query for objects readingdataCallback
- user defined callback action for data parts arrival notification or nullfinishCallback
- user defined callback action for data readiness notification or null
ConfigException
- in case of problems while reading data from server.
java.lang.IllegalArgumentException
- if query type is unsupported.
java.lang.IllegalStateException
- if service is already disposed.endRetrieveMultipleObjects(AsyncRequestResult)
,
setInvoker(AsyncInvoker)
public <T extends ICfgObject> AsyncRequestResult<T> beginRetrieveMultipleObjects(java.lang.Class<T> cls, ICfgQuery query, Action<java.util.Collection<T>> dataCallback, Action<AsyncRequestResult<T>> finishCallback, long timeout) throws ConfigException
setInvoker(AsyncInvoker)
before this method invocation if we have non-null callback.
beginRetrieveMultipleObjects
in interface IConfService
T
- specific wrapping class of particular configuration objects typecls
- class used for generic matchingquery
- query for objects readingdataCallback
- user defined callback action for data parts arrival notification or nullfinishCallback
- user defined callback action for data readiness notification or nulltimeout
- timeout in milliseconds which will be used for waiting messages from server
(excluding parsing time of messages)
ConfigException
- in case of problems while reading data from server.
java.lang.IllegalArgumentException
- if query type is unsupported.
java.lang.IllegalStateException
- if service is already disposed.endRetrieveMultipleObjects(AsyncRequestResult)
,
setInvoker(AsyncInvoker)
public <T extends ICfgObject> java.util.Collection<T> endRetrieveMultipleObjects(AsyncRequestResult<T> rqResult) throws ConfigException, java.lang.InterruptedException
endRetrieveMultipleObjects
in interface IConfService
T
- specific wrapping class of particular configuration object typerqResult
- future object instance created on asynchronous operation start
ConfigException
- in case of exception in configuration information reading.
java.lang.InterruptedException
- if operation was interrupted in some way.
java.lang.IllegalArgumentException
- if query type is unsupported.public ICfgObject createObjectFromXML(org.w3c.dom.Node confObject, java.lang.String objectPath, int folderDbid, boolean isSaved) throws ConfigException
createObjectFromXML
in interface IConfService
confObject
- The XML node describing a single configuration object
as received from Configuration ServerobjectPath
- The folder path of the object in Configuration ServerfolderDbid
- The DBID of the folder in which the object residesisSaved
- Specifies whether the object has been previously saved
in the configuration database
ConfigException
- in case of object instantiation problems.
java.lang.IllegalStateException
- if service is already disposed.public ICfgObject createObjectFromXML(org.w3c.dom.Node confObject, boolean isSaved) throws ConfigException
createObjectFromXML
in interface IConfService
confObject
- The XML node describing a single configuration object as received from Configuration Server.isSaved
- Specifies whether the object has been previously saved in the configuration database.
ConfigException
- in case of object instantiation problems.
java.lang.IllegalStateException
- if service is already disposed.public <T extends ICfgObject> java.util.Collection<T> createMultipleObjectsFromXML(org.w3c.dom.Node confObjectsContainer, java.lang.String[] objectsPaths, int[] foldersDbids) throws ConfigException
createMultipleObjectsFromXML
in interface IConfService
confObjectsContainer
- Parent node containing set of XML nodes
describing configuration objects as received from Configuration ServerobjectsPaths
- The folders paths of objects in Configuration ServerfoldersDbids
- The DBIDs of folders where objects reside
ConfigException
- in case of objects instantiation problems.
java.lang.IllegalStateException
- if service is already disposed.public <T extends ICfgObject> java.util.Collection<T> createMultipleObjectsFromXML(org.w3c.dom.NodeList confObjects, java.lang.String[] objectsPaths, int[] foldersDbids) throws ConfigException
confObjects
- List of XML nodes describing configuration
objects as received from Configuration ServerobjectsPaths
- The folders paths of objects in Configuration ServerfoldersDbids
- The DBIDs of folders where objects reside
ConfigException
- in case of objects instantiation problems.
java.lang.IllegalStateException
- if service is already disposed.public ICfgObject createObject(ConfObjectBase confObject, java.lang.String objectPath, int folderDbid, boolean isSaved) throws ConfigException
IConfService
createObject
in interface IConfService
confObject
- initial content of the object to be createdobjectPath
- The folder path of the object in Configuration ServerfolderDbid
- The DBID of the folder in which the object residesisSaved
- specifies whether the object has been previously saved in the configuration database
ConfigException
- in case of problems in communication with server.public ICfgObject createObject(ConfObjectBase confObject, boolean isSaved) throws ConfigException
createObject
in interface IConfService
confObject
- initial content of the object to be createdisSaved
- specifies whether the object has been previously saved in the configuration database
ConfigException
- in case of problems in the given structure.
java.lang.IllegalStateException
- if service is already disposed.
java.lang.IllegalArgumentException
- if given objects structure is null or invalid.public <T extends ICfgObject> java.util.Collection<T> createMultipleObjects(ConfDataCollection<? extends ConfObjectBase> confObjects, java.lang.String[] objectsPaths, int[] foldersDbids) throws ConfigException
createMultipleObjects
in interface IConfService
confObjects
- collection with initial contents of objects to be created
ConfigException
- in case of problems in the given structure.
java.lang.IllegalStateException
- if service is already disposed.
java.lang.NullPointerException
- if given collection is null.
java.lang.IllegalArgumentException
- if given object structure in the collection is null or invalid.public java.util.Collection<ICfgObject> createMultipleObjects(ConfObjectsCollection confObjects) throws ConfigException
createMultipleObjects
in interface IConfService
confObjects
- collection of objects declarations to be created
ConfigException
- in case of problems in communication with server.
java.lang.IllegalStateException
- if service is already disposed.
java.lang.IllegalArgumentException
- if given object structure in the collection is null or invalid.public java.util.Collection<ICfgObject> createMultipleObjectsFromXML(org.w3c.dom.Node confObjectsContainer) throws ConfigException
List<CfgObject> objs = cfgService.createMultipleObjectsFromXML(
eventObjectsRead.getConfObject().getDocumentElement()
);
createMultipleObjectsFromXML
in interface IConfService
confObjectsContainer
- parent node containing set of XML nodes
describing configuration objects as received from
Configuration Server
ConfigException
- in case of objects instantiation problems.
java.lang.IllegalStateException
- if service is already disposed.public java.util.Collection<ICfgObject> createMultipleObjectsFromXML(org.w3c.dom.NodeList confObjects) throws ConfigException
confObjects
- list of XML nodes describing
configuration objects as received from Configuration Server
ConfigException
- in case of objects instantiation problemsprotected Message prepareRequestReadObjectsMessage(ICfgQuery query)
query
- query for configuration object(s)
java.lang.IllegalArgumentException
- if query type is unsupportedprotected boolean addObjectOnRetrieve(ICfgObject object)
|
Platform SDK Java 8.5 API Reference | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |