ManagedEntity[] hosts = new InventoryNavigator(rootFolder).searchManagedEntities("HostSystem");
CacheInstance vicf = new CacheInstance(si);
vicf.watch(vms, new String[] {"name", "runtime.powerState", "summary"});
vicf.watch(hosts, new String[] {"name", "summary"});
vicf.start();
//check if the caching is ready to use; otherwise wait
while(!vicf.isReady())
{
Thread.sleep(1000);