Package net.aifusion.providers
Class BasicProvider
java.lang.Object
net.aifusion.providers.BasicProvider
- All Implemented Interfaces:
CimEventGenerator
,Repository
,Provider
This class represents a basic provider that can be extended by other classes to implement providers. The provider will persist
information if the repository passed in the constructor is persistent.
- 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 repositoryexecuteQuery
(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 providerboolean
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 childrenboolean
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
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
-
BasicProvider
Create a basic provider. If no repository is given (i.e., repository == null), an in-memory cache is initialized within the provider.- Parameters:
repository
- - repository to use for the provider
-
-
Method Details
-
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
-
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
-
getRepository
Description copied from interface:Provider
Get the underlying repository for this provider- Specified by:
getRepository
in interfaceProvider
- Returns:
- - reference to the underlying repository
-
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
-
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
-
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
-
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
-
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
-
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
-
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
-
getURL
Description copied from interface:Provider
Get the URL for this provider
-