Class CimClient

java.lang.Object
net.aifusion.cimserver.CimClient
All Implemented Interfaces:
CimEventGenerator, CimListener, Repository, Provider

public class CimClient extends Object implements Provider, CimListener
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 Details

    • CimClient

      public CimClient(URL serverURL, URL clientURL, String proxyHost, int proxyPort)
      Create a CimClient using a server URL and an optional proxy
      Parameters:
      serverURL - - server to which this client should connect
      clientURL - - the URL of this client (if any) for inbound communication. Null if no inbound connections expected.
      proxyHost - - outbound HTTP proxy host, if any
      proxyPort - - outbound HTTP proxy port, if any
    • CimClient

      public CimClient(URL serverURL, HttpConfiguration configuration)
      Create a new CimClient using a configuration
      Parameters:
      serverURL - - CimServer to which this client should connect
      configuration - - 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

      public List<NameSpacePath> 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 interface Repository
      Returns:
      - list of name spaces
    • get

      public NamedElement get(ObjectPath path)
      Description copied from interface: Repository
      Get a named element from the repository
      Specified by:
      get in interface Repository
      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

      public boolean contains(ObjectPath path)
      Description copied from interface: Repository
      Check if a named element exists in the repository
      Specified by:
      contains in interface Repository
      Parameters:
      path - - object path corresponding to the named element
      Returns:
      - true if the path exists in the repository, false otherwise
    • put

      public boolean put(NamedElement element)
      Description copied from interface: Repository
      Put a named element into the repository
      Specified by:
      put in interface Repository
      Parameters:
      element - - element to be added
      Returns:
      - true if successfully added, false otherwise
    • delete

      public boolean delete(ObjectPath path)
      Description copied from interface: Repository
      Delete a named element from the repository
      Specified by:
      delete in interface Repository
      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 interface Repository
      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 spaces
      elementNames - - 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 returned
      locateSubTypes - - 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

      public List<StructureValue> filter(ObjectPath path, CimFilter filter)
      Description copied from interface: Repository
      Find all structure value instances based on some filter criteria
      Specified by:
      filter in interface Repository
      Parameters:
      path - - object path to the structure to use
      filter - - 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 interface Repository
    • addListener

      public boolean addListener(CimEventType type, CimListener listener)
      Description copied from interface: CimEventGenerator
      Add a listener to this generator
      Specified by:
      addListener in interface CimEventGenerator
      Parameters:
      type - - type of event the listener wants
      listener - - CimListener interested in events
      Returns:
      - true if listener was successfully added, false otherwise
    • removeListener

      public void removeListener(CimEventType type, CimListener listener)
      Description copied from interface: CimEventGenerator
      Remove a listener from this generator
      Specified by:
      removeListener in interface CimEventGenerator
      Parameters:
      type - of event the listener wants
      listener - - CimListener to be removed
    • hasListener

      public boolean hasListener(CimEventType type, CimListener listener)
      Description copied from interface: CimEventGenerator
      Check if this event generator has a listener for an event type
      Specified by:
      hasListener in interface CimEventGenerator
      Parameters:
      type - - type of event
      listener - - 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

      public void registerChildProvider(Provider child)
      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 interface Provider
      Parameters:
      child - - child provider to be registered with this provider
    • unregisterChildProvider

      public void unregisterChildProvider(Provider child)
      Description copied from interface: Provider
      Unregister a child provider. This disconnects the child from this provider
      Specified by:
      unregisterChildProvider in interface Provider
      Parameters:
      child - - child provider to be unregistered
    • getPropertyNames

      public List<String> getPropertyNames(ObjectPath path)
      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 interface Provider
      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

      public DataType getPropertyType(ObjectPath path, String propertyName)
      Description copied from interface: Provider
      Get the data type corresponding to a particular property (or enumeration key)
      Specified by:
      getPropertyType in interface Provider
      Parameters:
      path - - object path of the CIM element from which the property is selected
      propertyName - - name of the property or key
      Returns:
      - DataType of the corresponding property or key
    • getPropertyValue

      public DataValue getPropertyValue(ObjectPath path, String propertyName)
      Description copied from interface: Provider
      Get a property value from this provider, or one of its children.
      Specified by:
      getPropertyValue in interface Provider
      Parameters:
      path - - object path of the CIM Element from which the property is being read
      propertyName - - case insensitive name of the property being read
      Returns:
      - data value containing the property or key value
    • setPropertyValue

      public void setPropertyValue(ObjectPath path, String propertyName, DataValue propertyValue)
      Description copied from interface: Provider
      Set a property value within this provider, or one of its children
      Specified by:
      setPropertyValue in interface Provider
      Parameters:
      path - - object path of the CIM Element in which the property is being set. Note that only Classes and Instances have settable properties
      propertyName - - case insensitive name of the property being set
      propertyValue - - value of the property being set
    • getMethodNames

      public List<String> getMethodNames(ObjectPath path)
      Description copied from interface: Provider
      Get the method names defined in a given CIM class
      Specified by:
      getMethodNames in interface Provider
      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

      public DataType getMethodReturnType(ObjectPath path, String methodName)
      Description copied from interface: Provider
      Get the return type associated with a method
      Specified by:
      getMethodReturnType in interface Provider
      Parameters:
      path - - object path for the CIM class from which the method is selected
      methodName - - name of the method
      Returns:
      - data type associated with the method. Null if no such method exists
    • getMethodParameters

      public List<CimParameter> getMethodParameters(ObjectPath path, String methodName)
      Description copied from interface: Provider
      Get the parameter list associated with a method
      Specified by:
      getMethodParameters in interface Provider
      Parameters:
      path - - object path of the CIM class from which the method is desired
      methodName - - 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 interface Provider
      Parameters:
      path - - object path of the CIM element on which the method is being invoked
      methodName - - case insensitive name of the method being invoked
      methodParameters - - list of parameters to be passed to the method
      Returns:
      - value returned from the method invocation
    • executeQuery

      public List<StructureValue> executeQuery(String query)
      Description copied from interface: Provider
      Execute a query against this provider, and return the result set
      Specified by:
      executeQuery in interface Provider
      Parameters:
      query - - query to be executed
      Returns:
      - set of results
    • notify

      public void notify(CimEvent event)
      Description copied from interface: CimListener
      Notify this listener of a given event at some event generator
      Specified by:
      notify in interface CimListener
      Parameters:
      event - - event generated by the corresponding event generator
    • getRepository

      public Repository getRepository()
      Description copied from interface: Provider
      Get the underlying repository for this provider
      Specified by:
      getRepository in interface Provider
      Returns:
      - reference to the underlying repository
    • getURL

      public URL getURL()
      Description copied from interface: Provider
      Get the URL for this provider
      Specified by:
      getURL in interface CimListener
      Specified by:
      getURL in interface Provider
      Returns:
      - URL where this provider can be reached. Null if the provider is not network accessible
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object