4.1

Table Of Contents
2 Define a method to register the objects to monitor with the IPluginEventPublisher instances.
The SolarSystemEventGenerator class defines a method that takes as parameters the type and identifier
of the object to monitor and an IPluginEventPublisher instance with which to monitor the object. The
addPolicyElement() method adds an IPluginEventPublisher instance for each object to the hashtable of
IPluginEventPublisher instances.
public void addPolicyElement(String sdkType, String id, IPluginEventPublisher publisher) {
String key = sdkType + "' / '" + id;
log.info("Registering element to watch : '" + key + "'");
Vector<IPluginEventPublisher> publishers = policyElements.get(key);
if (publishers == null) {
publishers = new Vector<IPluginEventPublisher>();
policyElements.put(key, publishers);
}
publishers.add(publisher);
}
3 (Optional) Define a method to remove objects from the list of objects to monitor.
The SolarSystemEventGenerator class defines a method that takes as parameters the type and identifier
of the object to monitor and an IPluginEventPublisher instance with which the objects are registered. The
removePolicyElement() method removes an IPluginEventPublisher instance for the identified object from
the hashtable of IPluginEventPublisher instances.
public boolean removePolicyElement(
String sdkType, String id, IPluginEventPublisher publisher) {
String key = sdkType + "' / '" + id;
log.info("Unregistering element to watch : '" + key + "'");
Vector<IPluginEventPublisher> publishers = policyElements.get(key);
publishers.remove(publisher);
if (publishers.size() == 0) {
policyElements.remove(key);
}
return (policyElements.size() > 0);
}
You created IPluginEventPublisher instances that publish to Orchestrator policies the events that occur on
objects in the plugged-in technology.
What to do next
Define an event to push from Orchestrator to the plugged-in technology.
Define and Publish Events to Orchestrator
The IPluginEventPublisher interface allows you to publish to the Orchestrator policy engine events that you
define in the plug-in that occur in the plugged-in technology.
You can use the methods of the IPluginEventPublisher interface to set gauges and triggers that Orchestrator
policies monitor.
The SolarSystemEventGenerator class defines a method that generates solar flares of a given magnitude on
Star objects in the solar system application. By implementing a method to create solar flares in the solar system
plug-in, the plug-in adds a function that does not exist in the solar system application. The
generateFlareEvent() method that the plug-in defines registers a policy gauge with the Orchestrator policy
engine. An Orchestrator policy can watch this gauge for solar flares that exceed a certain magnitude.
Chapter 7 Developing Plug-Ins
VMware, Inc. 169