Writing a Provider Program
This chapter describes how to write a provider program, and includes the following topics:
Note - For detailed information on the WBEM provider APIs (javax.wbem.provider), see file:/usr/sadm/lib/wbem/doc/index.html.
Providers are special classes that communicate with managed resources, such as disk drives and CPUs, to access data and then forward the data to the CIM Object Manager for integration and interpretation. They can relieve the CIM Object Manager, the primary WBEM agent that coordinates Solaris WBEM Services, by assuming the task of managing distinct subsets of WBEM resources. Providers use the javax.wbem.provider API to transfer this data. When the CIM Object Manager receives a request for data from an application that is not available in the CIM Object Manager Repository, it forwards the request, using the provider interfaces, to the appropriate provider.
Solaris software providers exist for a variety of areas: users, groups, aliases, roles, file systems, disks, processes, cron tool, network configuration, product registry, and device/system performance monitoring.
Providers create, modify, and delete instances rather than classes (which serve as templates for the instances). Instances can exist in persistent storage or be used dynamically.
Although providers have their own process and memory and perform work delegated by the CIM Object Manager, the CIM Object Manager must know the location of each provider in order to perform its task of coordinating WBEM. You inform the CIM Object Manager about new or modified providers by including those providers in a MOF file. A MOF file defines the classes and instances that a provider supports. You register a MOF file using the mofcomp(1M) command.
Providers do the following:
Provide data to management applications - When a management application requests data about a managed resource that is not available in the CIM Object Manager Repository, the CIM Object Manager forwards the request to a provider. The provider accesses the data from the managed resource and passes the data back to the CIM Object Manager. If the data received from a managed resource is in a native format (such as C code), the provider maps the data to Java CIM classes prior to passing it to the CIM Object Manager.
Control management resources - When a management application sends data to the CIM Object Manager to control a managed resource, the CIM Object Manager passes the data to the appropriate provider. If the managed resource requires data in a native format, the provider maps the CIM classes to the resource's native format prior to passing it along.
Note - Providers must reside on the same machine as the CIM Object Manager.
Provider Data Sources
Providers can retrieve data from the following:
Non-persistent data - Variables that are local to the provider class that exist only when the provider's methods are run.
Persistent memory that is local to the provider - Used by creating global variables in the provider class. This provider memory is erased when the CIM Object Manager is stopped and restarted.
The CIM Object Manager Repository - This persistent memory is erased when Solaris WBEM Services is uninstalled. The provider must use CIM Object Manager handles and an internal provider to access this memory through the CIM Object Manager.
Files and databases maintained by the provider, or dynamic data - Providers can generate data dynamically by retrieving it from a system. For example, a provider can make a system call to retrieve the number of processes currently running.
Types of Providers
Providers are categorized according to the types of requests they service. Client programs communicate with the CIM Object Manager (and access WBEM data) through the client API (see file:/usr/sadm/lib/wbem/doc/index.html). The CIM Object Manager maps the provider methods to the corresponding client methods in the client API. However, the argument lists and return values of corresponding methods may differ:
If a provider stores data in the CIM Object Manager Repository, then it accesses the Repository using handles to the CIM Object Manager (see "Implementing the Provider Interfaces"), which call the methods of the client API.
If a provider needs to create instances or associations in the CIM Object Manager Repository, then it uses an internal provider (see "Implementing the Provider Interfaces"), which calls methods of Instance or Associator Providers that are internal to WBEM.
Make sure your argument list and return type is correct for the method and class used.
The Solaris WBEM SDK provider types are shown in the following table.
Table 4-1 Provider Types
Supply dynamic instances of a given class, and support instance retrieval, enumeration, modification, and deletion.
Supply methods of one or more classes.
Supply instances of dynamic association classes.
Handle indications of CIM events.
A marker interface that indicates to the CIM Object Manager that the provider does its own authorization check.
A single provider can act as one or more of the above types by registering and implementing the relevant methods.
Provider Naming Conventions
You can include providers in a single Java class file or store each provider in a separate class. The provider name identifies the Java class that serves as the provider for the class. Currently, the CIM Object Manager supports only providers written in the Java language.
Provider and class names must follow these rules:
The class name must be a valid CIM class, that is, that the name contains a prefix of characters, followed by an underscore, followed by more characters.
For example, green_apples and red_apples are valid CIM class names, whereas apples, apples_, and _apples are not.
The provider name specified in the MOF file must match the name of the provider class file.
For example, SimpleCIMInstanceProvider is the provider and Ex_SimpleCIMInstanceProvider is the class.
Note - You must prepend "java:" to every provider qualifier to notify the CIM Object Manager that the provider is written in the Java language.
Follow standard Java class and package naming conventions to create your provider names. The prefix of a package name is written in lowercase ASCII letters and must be one of the top-level domain names (com, edu, gov, mil, net, org), or one of the English two-letter country codes specified in ISO Standards 3166, 1981.
Subsequent components of the package name will vary according to your organization's internal naming conventions. Such conventions might specify that certain directory name components are division, department, project, machine, or login names. For example, the provider name java:com.sun.wbem.cimom indicates the following:
java: - Language used to write the provider
com - Top-level domain name
sun - Company name
wbem - Product name
cimom - Type of class files that implement the CIM Object Manager