Solaris WBEM Developer's Guide

Writing an Indication Provider

To generate an indication for a CIM event, you need to perform the following tasks:

ProcedureHow To Generate an Event Indication

Steps
  1. Implement the EventProvider interface.

    For example:

    public class sampleEventProvider 
    implements InstanceProvider EventProvider{
    
        // Reference for provider to contact the CIM Object Manager
        private ProviderCIMOMHandle cimom;
       }
  2. Execute each of the methods listed in Table 6–2 for each instance indication that the provider handles.

  3. Create an indication for create, modify, and delete instance event type.

    For example, in the createInstance method:

    public CIMObjectPath createInstance(CIMObjectPath op, 
            CIMInstance ci)
        throws CIMException {
            CIMObjectpath newop = ip.createInstance(op, ci);
           
            CIMInstance indication = new CIMInstance();
            indication.setClassName("CIM_InstCreation");
            
            CIMProperty cp = new CIMProperty();
            cp.setName("SourceInstance");
            cp.setValue(new CIMValue(ci));
            
            Vector v = new Vector();
            v.addElement(cp);
            indication.setProperties(v);
            ...
        }
  4. Deliver the event indication to the CIM Object Manager.

    cimom.deliverEvent(op.getNameSpace(), indication);

Event Provider Methods

An event provider implements the EventProvider interface. This interface contains methods that the CIMOM uses to notify the provider when a client has subscribed for indications of CIM events. This method is also used when a client has cancelled the subscription for CIM events. These methods allow the provider to indicate whether the CIMOM should poll for some event indications and whether the provider should authorize the return of an indication to a handler.

The following table lists the methods in the EventProvider interface that must be implemented by an event provider.

Table 6–2 EventProvider Methods

Method 

Description 

activateFilter

When a client creates a subscription, the CIMOM calls this method to ask the provider to check for CIM events. 

authorizeFilter

When a client creates a subscription, the CIMOM calls this method to test if the specified filter expression is allowed. 

deActivateFilter

When a client removes a subscription, the CIMOM calls this method to ask the provider to deactivate the specified event filter. 

mustPoll

When a client creates a subscription, the CIMOM calls this method to test whether the specified filter expression is allowed by the provider, and if it must be polled. 

The CIMOM passes values for the following arguments to all methods:

In addition, the activateFilter method takes the boolean firstActivation, indicating that this filter is the first filter for this event type. The deActivateFilter method takes the boolean lastActivation, indicating that this filter is the last filter for this event type.

Creating and Delivering Indications

A client application subscribes for indications of CIM events by creating an instance of the CIM_IndicationSubscription class. The CIMOM then forwards the request to the appropriate provider. If the provider implements the EventProvider interface, the CIMOM notifies the provider when to start sending indications for the specified events. The provider performs this notification by calling the provider's activateFilter method. In addition, the CIMOM notifies the provider when to stop sending indications for the specified events by calling the provider's deActivateFilter method.

The provider responds to the CIMOM's requests by creating and delivering an indication each time the provider creates, modifies, or deletes an instance. A provider typically defines a flag variable that is set when the CIMOM calls the activateFilter method. This flag is cleared when the CIMOM calls the deActivateFilter method. Then in each method that creates, modifies, or deletes an instance, the provider checks the status of the activate filter flag. If the flag is set, the provider creates an indication containing the created CIM instance object. The provider uses the deliverEvent method to return the indication to the CIMOM. If the flag is not set, the provider does not create and deliver an indication of the event.

A provider starts delivering indications when the activateFilter method is called. The provider creates instances of concrete subclasses of CIM_Indication and invokes the ProviderCIMOMHandled.deliverIndication method. The CIMOM receives the indication and delivers the indication to the appropriate indication handlers. A provider can handle multiple event types. For example, in the case of life cycle indications, a provider can handle CIM_InstCreation, CIM_InstDeletion, and CIM_InstModification.

To keep track of types that have subscriber interest, the provider can use the firstActivation and lastActivation flags passed in the activateFilter and deActivateFilter calls, respectively. The firstActivation flag is true when the subscription is the first subscription for the particular event type. Similarly, lastActivation is true when the last subscription for the particular event type is removed. By checking these flags, the provider can easily allocate or deallocate resources to monitor the specified event types.

About Authorizations

A provider that handles sensitive data can check authorizations for requests for indications. The provider must implement the Authorizable interface to indicate that the provider handles authorization checking. The provider also implements the authorizeFilter method. The CIMOM calls this method to test whether the owner (UID) of an event handler is authorized to receive the indications that result from evaluating a filter expression. The UID for the owner of the event destination, the event handler, can be different than the owner of the client application requesting the filter activation.