4.1

Table Of Contents
The findAll() method returns a QueryResult object that contains a list of the objects of the corresponding type
that the plugged-in technology contains. For information about QueryResult objects, see “QueryResult
Class,” on page 217.
Prerequisites
n
Set up the factory implementation class.
n
Create a public constructor that implements the IPluginFactory interface.
Procedure
1 Declare the IPluginFactory.findAll() method to obtain a QueryResult object.
public QueryResult findAll(String type, String query) {
}
2 Write in the logs the type of the objects that the plug-in factory finds and any additional query that narrows
the search.
public QueryResult findAll(String type, String query) {
log.debug("findAll: " + type + ", " + query);
}
3 Call the appropriate methods from the plugged-in technology to obtain objects of each different type.
The SolarSystemFactory class uses an if-else statement to call the SolarSystemRepository.getStar(),
getAllPlanets(), and getAllMoons() methods.
public QueryResult findAll(String type, String query) {
log.debug("findAll: " + type + ", " + query);
List list; // The list can contain any element from the plug-in
if (type.equals("Star")) {
list = new Vector();
list.add(SolarSystemRepository.getUniqueInstance().getStar());
}
else if (type.equals("Planet")) {
list = SolarSystemRepository.getUniqueInstance().getAllPlanets();
}
else if (type.equals("Moon")) {
list = SolarSystemRepository.getUniqueInstance().getAllMoons();
}
else if (type.equals("Galaxy")) {
list = new Vector();
}
else {
throw new IndexOutOfBoundsException("Type " + type +
" unknown for SolarSystem plug-in ");
}
return new QueryResult(list);
}
The SolarSystemFactory implementation of the findAll() method does not define a custom query to
narrow the search, so it returns a list of all the objects of each given type in the QueryResult object.
You defined methods to find objects by their type in the plugged-in technology.
What to do next
Define methods in the plug-in factory to find all objects that relate to other objects by a certain relation type.
vCenter Orchestrator Developer's Guide
160 VMware, Inc.