Implementing Indication Providers

I have left the indication provider until last because it is different from the other providers ”it does not wait passively for the WBEM server to invoke it; instead it waits patiently for an external event to occur and then invokes the WBEM server.

openPegasus does not yet conform to the complete indication provider interface described on page 207; authorizeFilter() , (de)activateFilter() , mustPoll() are not supported. As these will appear in openPegasus in the near-future and invalidate everything in the section, I have kept the description of the current interface short.

The indication provider code is very similar to that of a "normal" provider. The first routine of importance is enableIndications() which the openPegasus WBEM server invokes to inform the provider that it should start sending indications (someone has subscribed for them). The parameters to this function include a call-back object in the WBEM server to be used when an event occurs. Normally, it is enough just to store these locally:

 void MyIndicationProvider::enableIndications: :enableIndications (     IndicationResponseHandler & handler)     {     enabled = true;     myHandler = &handler;     return;     } 

The provider then awaits an event which should cause an indication to be raised and simply creates it:

 CIMInstance indicationInstance(CIMName("MyIndication")); // create an instance of MyIndication class CIMObjectPath path ; path.setNameSpace("root/SampleProvider"); path.setClassName("MyIndication"); indicationInstance.setPath(path); ...create and add the properties.... ...e.g., indicationInstance.addProperty CIMDateTime currentDateTime =                    CIMDateTime::getCurrentDateTime(); indicationInstance.addProperty(CIMProperty("IndicationTime",                                      currentDateTime)); Array<String> correlatedIndications; indicationInstance.addProperty(CIMProperty(                                 "CorrelatedIndications",                                 correlatedIndications)); // deliver the instance we have created myHandler->deliver(indicationInstance); 

This is sufficient (perhaps with a few more properties set to give more information about the event) for the indication to reach the handler, listener and consumer.

start sidebar
Summary of openPegasus Providers

openPegasus currently expects providers to be written in C++. It provides a method of tying providers for classes to C++ routines in a library. When the WBEM server needs a provider it loads the code dynamically.

Writing one's first provider is quite error prone (e.g., linkage to the mof ), but openPegasus provides many useful routines to manipulate lists, object paths, strings, etc. It also has many useful example providers. Writing one's second provider is easy: lots of cut and paste.

end sidebar

A Practical Approach to WBEM[s]CIM Management
A Practical Approach to WBEM[s]CIM Management
ISBN: 849323061
Year: 2006
Pages: 152 © 2008-2017.
If you may any questions please contact us: