Sun WBEM SDK Developer's Guide

Creating an Event Filter

Event filters describe the types of events to be delivered and the conditions under which they are delivered. An application creates an event filter by creating an instance of the CIM_IndicationFilter class and defining values for its properties. Event filters belong to a namespace. Each event filter works only on events that belong to the namespace to which the filter also belongs.

The CIM_IndicationFilter class has string properties that an application can set to uniquely identify the filter, specify a query string, and the query language to parse the query string, as shown in the following table. Currently, only the WBEM Query Language is supported.

Table 6–1 Properties in the CIM_IndicationFilter Class

Property 

Description 

Required/Optional 

SystemCreationClassName

The name of the system on which the creation class for the filter resides or to which it applies. 

Optional. The default for this key property is the CIM_System.CreationClassName.

SystemName

The name of the system on which the filter resides or to which it applies. 

Optional. The default for this key property is the name of the system on which the CIM Object Manager is running. 

CreationClassName

The name of the class or subclass used to create the filter.  

Optional. The CIM Object Manager assigns CIM_IndicationFilter as the default for this key property.

Name

The unique name of the filter. 

Required. The client application must assign a unique name. 

SourceNamespace

The path to a local namespace where the CIM indications originate. 

Optional. The default is \root\cimv2.

Query

A query expression that defines the conditions under which indications will be generated. Currently, only Level 1 WBEM Query Language expressions are supported. To learn how to construct WQL query expressions, see Querying.

Required. 

QueryLanguage

The language in which the query is expressed. 

Required. The default is WQL (WBEM Query Language). 

How to Create an Event Filter
  1. Create an instance of the CIM_IndicationFilter class. For example.

    CIMClass cimfilter = cc.getClass
            (new CIMObjectPath(“CIM_IndicationFilter”),
             true, true, true, null);CIMInstance ci = cimfilter.newInstance();

  2. Specify the name of the event filter. For example.

    Name = “filter_all_new_solarisdiskdrives”

  3. Create a WQL string to identify event indications to be returned. For example.

    String filterString = “SELECT * 
            FROM CIM_InstCreation WHERE sourceInstance 
            is ISA Solaris_DiskDrive”;

  4. Set property values in the cimfilter instance to identify the name of the filter, the filter string to select CIM events, and the query language to parse the query string.

    Currently, only the WBEM Query Language can be used to part query strings. For example.

    ci.setProperty(“Name”, new 
            CIMValue("filter_all_new_solarisdiskdrives”));
    ci.setProperty("Query", new CIMValue(filterString));
    ci.setProperty("QueryLanguage", new CIMValue("WQL");)

  5. Create an instance from the cimfilter instance, called filter, and store it in the CIM Object Manager Repository.

    CIMObjectPath filter = cc.createInstance(new CIMObjectPath(), ci);