4.0

Table Of Contents
Procedure
1 Create one or more instances of the IPluginEventPublisher interface with which to register the objects to
monitor.
The SolarSystemEventGenerator class creates a hashtable to contain all of the IPluginEventPublisher
instances.
private Hashtable<String, Vector<IPluginEventPublisher>> policyElements =
new Hashtable<String, Vector<IPluginEventPublisher>>();
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.
Chapter 7 Developing Plug-Ins
VMware, Inc. 173