4.1

Table Of Contents
2 Create a class loader to load the configuration adapter classes into the configuration server.
Orchestrator defines a utility class named Localizator to locate packages of classes.
The SolarSystemConfigurationAdaptor class creates an instance of Localizator that calls the
java.lang.Class.getClassLoader() method and directs it to the package of configuration classes.
private static final Localizator local =
new Localizator(SolarSystemConfigurationAdaptor.class.getClassLoader(),
"com/vmware/orchestrator/api/sample/solarsystem/config/package");
3 Define methods to obtain and set the configurable values.
The SolarSystemConfigurationAdaptor class uses the Localizator.getResourceString() method to get
the properties of Pluto from the plug-in configuration server and adds them to a hashtable. The
SolarSystemConfigurationAdaptor class also defines methods to set whether Pluto is a planet and to set
the user's home planet.
public Map<String, String> getPlutoClassifyList(){
Map<String, String> ret = new Hashtable<String, String>();
ret.put("no", local.getResourceString("select.pluto.classify.dwarfPlanet"));
ret.put("yes", local.getResourceString("select.pluto.classify.planet"));
return ret;
}
public List<Planet> getAllPlanets(){
return SolarSystemRepository.getUniqueInstance().getAllPlanets();
}
public String getHomePlanet() {
return homePlanet;
}
public void setHomePlanet(String homePlanet) {
this.homePlanet = homePlanet;
}
public void setPlutoClassifiedAsAPlanet(String plutoClassifiedAsAPlanet) {
this.plutoClassifiedAsAPlanet = plutoClassifiedAsAPlanet;
}
public String getPlutoClassifiedAsAPlanet() {
return plutoClassifiedAsAPlanet;
}
4 Implement the IConfigurationAdaptor.saveConfiguration() method to save configuration information
to the configuration server by setting plug-in properties.
The SolarSystemConfigurationAdaptor.loadConfiguration() method creates a Properties list to contain
the configurable properties. The values that SolarSystemConfigurationAdaptor.saveConfiguration()
method adds to the list are the values that the methods defined in Step 3 set. The
SolarSystemConfigurationAdaptor.saveConfiguration() method calls the
SDKHelper.savePropertiesForPluginName() to save the Properties list to the configuration server.
public void saveConfiguration(OutputStream stream) throws IOException {
System.out.println("home planet: " + homePlanet);
System.out.println("is pluto classified as a planet: " + plutoClassifiedAsAPlanet);
Properties prop = new Properties();
prop.setProperty("solar.system.home.planet", homePlanet);
prop.setProperty("solar.system.isPlutoClassifiedAsAPlanet", plutoClassifiedAsAPlanet);
if (stream == null) {
SDKHelper.savePropertiesForPluginName(prop, pluginName);
}
}
vCenter Orchestrator Developer's Guide
188 VMware, Inc.