Package net.aifusion.cimserver
Class CimClient
java.lang.Object
net.aifusion.cimserver.CimClient
- All Implemented Interfaces:
CimEventGenerator
,CimListener
,Repository
,Provider
Class to implement the client side interface for a Cim Server.
The client implements a Provider interface as well as a CimListener to enable the application to receive server-side events.
The client forwards all requests to the server, and does not (currently) cache any data on the client side.
- Author:
- Sharad Singhal
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
addListener
(CimEventType type, CimListener listener) Add a listener to this generatorboolean
contains
(ObjectPath path) Check if a named element exists in the repositoryboolean
delete
(ObjectPath path) Delete a named element from the repositoryboolean
executeQuery
(String query) Execute a query against this provider, and return the result setfilter
(ObjectPath path, CimFilter filter) Find all structure value instances based on some filter criteriaget
(ObjectPath path) Get a named element from the repositorygetElements
(String elementTypes, String localNameSpaces, String elementNames, boolean locateSubTypes) Get elements from this repository.getMethodNames
(ObjectPath path) Get the method names defined in a given CIM classgetMethodParameters
(ObjectPath path, String methodName) Get the parameter list associated with a methodgetMethodReturnType
(ObjectPath path, String methodName) Get the return type associated with a methodGet a list of all name spaces known to this repository.getPropertyNames
(ObjectPath path) Get the property names for a given named element.getPropertyType
(ObjectPath path, String propertyName) Get the data type corresponding to a particular property (or enumeration key)getPropertyValue
(ObjectPath path, String propertyName) Get a property value from this provider, or one of its children.Get the underlying repository for this providergetURL()
Get the URL for this providerint
hashCode()
boolean
hasListener
(CimEventType type, CimListener listener) Check if this event generator has a listener for an event typeinvokeMethod
(ObjectPath path, String methodName, List<CimParameter> methodParameters) Invoke an extrinsic method on a class or instance within this provider, or one of its childrenvoid
Notify this listener of a given event at some event generatorboolean
put
(NamedElement element) Put a named element into the repositoryvoid
registerChildProvider
(Provider child) Register a child provider with this provider.void
removeListener
(CimEventType type, CimListener listener) Remove a listener from this generatorvoid
setKeepAlive
(boolean keepAlive) Set the keep-alive value for connections by the clientvoid
setPropertyValue
(ObjectPath path, String propertyName, DataValue propertyValue) Set a property value within this provider, or one of its childrenvoid
shutdown()
Shut down the repository.void
unregisterChildProvider
(Provider child) Unregister a child provider.
-
Constructor Details
-
CimClient
Create a CimClient using a server URL and an optional proxy- Parameters:
serverURL
- - server to which this client should connectclientURL
- - the URL of this client (if any) for inbound communication. Null if no inbound connections expected.proxyHost
- - outbound HTTP proxy host, if anyproxyPort
- - outbound HTTP proxy port, if any
-
CimClient
Create a new CimClient using a configuration- Parameters:
serverURL
- - CimServer to which this client should connectconfiguration
- - configuration for the client. Maybe null if client configuration is not needed for Http
-
-
Method Details
-
setKeepAlive
public void setKeepAlive(boolean keepAlive) Set the keep-alive value for connections by the client- Parameters:
keepAlive
- - true (default) to keep connections alive. False to close connections after each request
-
getNameSpaces
Description copied from interface:Repository
Get a list of all name spaces known to this repository. Note that because implementations can add or remove name spaces as elements are added or deleted, this list may not be complete, and depends on the repository implementation- Specified by:
getNameSpaces
in interfaceRepository
- Returns:
- - list of name spaces
-
get
Description copied from interface:Repository
Get a named element from the repository- Specified by:
get
in interfaceRepository
- Parameters:
path
- - object path corresponding to the named element- Returns:
- - Named Element corresponding to the element. Null returned if no such element exists in the repository
-
contains
Description copied from interface:Repository
Check if a named element exists in the repository- Specified by:
contains
in interfaceRepository
- Parameters:
path
- - object path corresponding to the named element- Returns:
- - true if the path exists in the repository, false otherwise
-
put
Description copied from interface:Repository
Put a named element into the repository- Specified by:
put
in interfaceRepository
- Parameters:
element
- - element to be added- Returns:
- - true if successfully added, false otherwise
-
delete
Description copied from interface:Repository
Delete a named element from the repository- Specified by:
delete
in interfaceRepository
- Parameters:
path
- - object path corresponding to the named element- Returns:
- - true if deletion succeeded, false otherwise
-
getElements
public List<NamedElement> getElements(String elementTypes, String localNameSpaces, String elementNames, boolean locateSubTypes) Description copied from interface:Repository
Get elements from this repository. Depending on the size of the repository, this method can be very expensive in time and/or memory- Specified by:
getElements
in interfaceRepository
- Parameters:
elementTypes
- - Optional comma separated list of element types to retrieve. Must be a NamedElement type (QualifierType, Enumeration, Interface, Structure, Class, StructureValue or Instance). A null will retrieve all types. Note that standard qualifier types are "built in" and are not returned by this method.localNameSpaces
- - Optional comma separated list of local name spaces to search. A null will retrieve elements from all name spaceselementNames
- - Optional comma-separated list of element names to retrieve. A null will retrieve all elements of the given type. For instances, all instances corresponding to the class name are returnedlocateSubTypes
- - if true, locate all subtypes of the given element types (e.g., all subclasses of the requested class).- Returns:
- - list of elements that match the given criteria. An empty list is returned if no matching elements are found
- See Also:
-
filter
Description copied from interface:Repository
Find all structure value instances based on some filter criteria- Specified by:
filter
in interfaceRepository
- Parameters:
path
- - object path to the structure to usefilter
- - filter to apply- Returns:
- - list of structureValues that pass the given filter. Empty list if none available
-
shutdown
public void shutdown()Description copied from interface:Repository
Shut down the repository. This method MUST be called before exiting to cleanly finish all pending tasks and release resources in the repository- Specified by:
shutdown
in interfaceRepository
-
addListener
Description copied from interface:CimEventGenerator
Add a listener to this generator- Specified by:
addListener
in interfaceCimEventGenerator
- Parameters:
type
- - type of event the listener wantslistener
- - CimListener interested in events- Returns:
- - true if listener was successfully added, false otherwise
-
removeListener
Description copied from interface:CimEventGenerator
Remove a listener from this generator- Specified by:
removeListener
in interfaceCimEventGenerator
- Parameters:
type
- of event the listener wantslistener
- - CimListener to be removed
-
hasListener
Description copied from interface:CimEventGenerator
Check if this event generator has a listener for an event type- Specified by:
hasListener
in interfaceCimEventGenerator
- Parameters:
type
- - type of eventlistener
- - listener to check. If null, check if any listener is registered- Returns:
- - true if the generator has at least one registered listener for the event type, false otherwise
-
registerChildProvider
Description copied from interface:Provider
Register a child provider with this provider. This enables this provider to dispatch queries to the child provider and and delegate selected queries to the child provider.- Specified by:
registerChildProvider
in interfaceProvider
- Parameters:
child
- - child provider to be registered with this provider
-
unregisterChildProvider
Description copied from interface:Provider
Unregister a child provider. This disconnects the child from this provider- Specified by:
unregisterChildProvider
in interfaceProvider
- Parameters:
child
- - child provider to be unregistered
-
getPropertyNames
Description copied from interface:Provider
Get the property names for a given named element. In case the objectPath is an enumeration, the key names are returned- Specified by:
getPropertyNames
in interfaceProvider
- Parameters:
path
- - object path for the CIM element from which property names are desired- Returns:
- - list containing names of the properties. Empty if none defined
-
getPropertyType
Description copied from interface:Provider
Get the data type corresponding to a particular property (or enumeration key)- Specified by:
getPropertyType
in interfaceProvider
- Parameters:
path
- - object path of the CIM element from which the property is selectedpropertyName
- - name of the property or key- Returns:
- - DataType of the corresponding property or key
-
getPropertyValue
Description copied from interface:Provider
Get a property value from this provider, or one of its children.- Specified by:
getPropertyValue
in interfaceProvider
- Parameters:
path
- - object path of the CIM Element from which the property is being readpropertyName
- - case insensitive name of the property being read- Returns:
- - data value containing the property or key value
-
setPropertyValue
Description copied from interface:Provider
Set a property value within this provider, or one of its children- Specified by:
setPropertyValue
in interfaceProvider
- Parameters:
path
- - object path of the CIM Element in which the property is being set. Note that only Classes and Instances have settable propertiespropertyName
- - case insensitive name of the property being setpropertyValue
- - value of the property being set
-
getMethodNames
Description copied from interface:Provider
Get the method names defined in a given CIM class- Specified by:
getMethodNames
in interfaceProvider
- Parameters:
path
- - object path for the CIM class from which method names are desired- Returns:
- - list containing method names. Empty if no methods are defined.
-
getMethodReturnType
Description copied from interface:Provider
Get the return type associated with a method- Specified by:
getMethodReturnType
in interfaceProvider
- Parameters:
path
- - object path for the CIM class from which the method is selectedmethodName
- - name of the method- Returns:
- - data type associated with the method. Null if no such method exists
-
getMethodParameters
Description copied from interface:Provider
Get the parameter list associated with a method- Specified by:
getMethodParameters
in interfaceProvider
- Parameters:
path
- - object path of the CIM class from which the method is desiredmethodName
- - name of the method desired- Returns:
- - list of parameters. Empty if the method does not take parameters.
-
invokeMethod
public DataValue invokeMethod(ObjectPath path, String methodName, List<CimParameter> methodParameters) Description copied from interface:Provider
Invoke an extrinsic method on a class or instance within this provider, or one of its children- Specified by:
invokeMethod
in interfaceProvider
- Parameters:
path
- - object path of the CIM element on which the method is being invokedmethodName
- - case insensitive name of the method being invokedmethodParameters
- - list of parameters to be passed to the method- Returns:
- - value returned from the method invocation
-
executeQuery
Description copied from interface:Provider
Execute a query against this provider, and return the result set- Specified by:
executeQuery
in interfaceProvider
- Parameters:
query
- - query to be executed- Returns:
- - set of results
-
notify
Description copied from interface:CimListener
Notify this listener of a given event at some event generator- Specified by:
notify
in interfaceCimListener
- Parameters:
event
- - event generated by the corresponding event generator
-
getRepository
Description copied from interface:Provider
Get the underlying repository for this provider- Specified by:
getRepository
in interfaceProvider
- Returns:
- - reference to the underlying repository
-
getURL
Description copied from interface:Provider
Get the URL for this provider- Specified by:
getURL
in interfaceCimListener
- Specified by:
getURL
in interfaceProvider
- Returns:
- - URL where this provider can be reached. Null if the provider is not network accessible
-
hashCode
public int hashCode() -
equals
-