4.1

Table Of Contents
Prerequisites
n
Set up the event generator class to create event generator instances.
n
Create instances of the IPluginEventPublisher interface.
Procedure
1 Create functions that define event listeners and the events that the event listeners monitor.
The SolarSystemEventGenerator class declares an interface from which to create listener instances, and
adds a method to the interface to create flare events of a certain magnitude on a given Star object.
public interface StarFlareEventListener{
void starFlareEvent(String starid, double magnitude);
}
2 Create listener instances to listen for the events that the plug-in defines.
The SolarSystemEventGenerator instantiates the StarFlareEventListener interface to create a listener
named starFlareEventListener.
private StarFlareEventListener starFlareEventListener;
3 Create functions to generate events in the plugged-in technology.
The SolarSystemEventGenerator defines the generateFlareEvent() method that takes an object type,
identifier, and a magnitude value as parameters. The method writes in the logs that the plug-in generated
a flare event on a given object.
public void generateFlareEvent(String sdkType, String id, double magnitude) {
String key = sdkType + "' / '" + id;
log.info("Generate Flare Event for : '" + key + "'");
}
4 Register the objects to monitor with IPluginEventPublisher instances.
The SolarSystemEventGenerator.generateFlareEvent() method adds IPluginEventPublisher instances
for each object to the policyElements hashtable of publishers that the SolarSystemEventGenerator class
creates.
public void generateFlareEvent(String sdkType, String id, double magnitude) {
String key = sdkType + "' / '" + id;
log.info("Generate Flare Event for : '" + key + "'");
Vector<IPluginEventPublisher> publishers = policyElements.get(key);
}
5 Call the IPluginEventPublisher.pushGauge() or IPluginEventPublisher.pushTrigger() methods to
publish gauges or triggers to the Orchestrator policy engine.
The SolarSystemEventGenerator.generateFlareEvent() method calls the pushGauge() method to publish
a gauge with the Orchestrator policy engine. The generateFlareEvent() method passes the object type,
identifier, and magnitude value to the pushGauge() method, sets the gauge name to Flare and the type of
value that the gauge monitors to magnitude.
public void generateFlareEvent(String sdkType, String id, double magnitude) {
String key = sdkType + "' / '" + id;
log.info("Generate Flare Event for : '" + key + "'");
Vector<IPluginEventPublisher> publishers = policyElements.get(key);
if (publishers != null) {
for (IPluginEventPublisher publisher : publishers) {
publisher.pushGauge(sdkType, id, "Flare", "magnitude", magnitude);
}
}
vCenter Orchestrator Developer's Guide
170 VMware, Inc.