4.0

Table Of Contents
Define Objects and Methods to Map to the Orchestrator JavaScript API
You can map the object types, classes, and methods of the plugged-in technology and the plug-in itself to
JavaScript types, classes, and methods that you add to the Orchestrator JavaScript API.
You can add objects and functions to the JavaScript API that do not exist in the plugged-in technology by
defining them in the plug-in implementation. Adding objects and functions to the JavaScript API allows you
to include the objects and functions in Orchestrator actions and workflows, to perform operations on objects
in the plugged-in technology.
You map the objects and functions that you define in the plug-in implementation in <scripting-object>
elements in the vso.xml file. For information about how to map objects and functions to the JavaScript API in
the vso.xml file, see “Map the Application in the vso.xml File,” on page 201.
The vso.xml file in the solar system example maps to JavaScript objects all of the objects and methods that the
solar system application defines. The vso.xml file also maps the following objects and methods from the solar
system plug-in implementation to the Orchestrator JavaScript API.
n
SolarSystemEventGenerator scripting class
n
SolarSystemEventGenerator.generateFlareEvent() scripting method
n
SolarSystemTriggerGenerator scripting class
n
SolarSystemTriggerGenerator.createStarFlareTrigger() scripting method
To create a class to map to the Orchestrator JavaScript API, you add an instance of that class to an instance of
the IPluginFactory implementation by defining a method named createScriptingSingleton(). When the
plug-in adaptor instantiates the factory, it also instantiates the class to add to the JavaScript API.
Prerequisites
You created at least one class of the plug-in implementation, for example the adaptor, the factory, or an event
generator implementation.
Procedure
1 Create an instance of a class to map to the Orchestrator JavaScript API in one of the classes of the plug-in
implementation.
The SolarSystemEventGenerator class defines the following constructor to create instances of itself:
public final static SolarSystemEventGenerator _solarSystemEventGenerator =
new SolarSystemEventGenerator();
2 Define a method named createScriptingSingleton() that accesses the IPluginFactory implementation
of the plug-in.
The SolarSystemEventGenerator class creates the following instance of that class:
public static SolarSystemEventGenerator createScriptingSingleton(IPluginFactory factory) {
}
3 Implement the createScriptingSingleton() method to return to the factory an instance of the class to
map to the JavaScript API.
The SolarSystemEventGenerator class returns the _solarSystemEventGenerator instance.
public static SolarSystemEventGenerator createScriptingSingleton(IPluginFactory factory) {
return _solarSystemEventGenerator;
}
Chapter 7 Developing Plug-Ins
VMware, Inc. 185