Getting list of cache names
967759Oct 11 2012 — edited Oct 12 2012I have been using this code to get the list of all the cache names of my cluster :
------
Cluster cluster=CacheFactory.ensureCluster();
for (Enumeration<String> services = cluster.getServiceNames(); services.hasMoreElements(); )
{
String sName = (String) services.nextElement();
System.out.println("Service:"+sName);
Service service=cluster.getService(sName);
if (service instanceof CacheService){
CacheService cService=(CacheService)service;
Enumeration<String> caches = cService.getCacheNames();
for (caches = cService.getCacheNames(); caches.hasMoreElements();){
// add caches.nextElement() in a list
}
}
}
------
It is working fine but in order to access multiple clusters I have to use Coherence proxy/extend.
When I use proxy/extend, the code above does not work anymore. I explain: when using proxy/extend, cluster.getServiceNames() returns Management and Cluster but does not return the Cache Services anymore.
I have tried to get a cluster object in a different way :
((InvocationService) CacheFactory.getConfigurableCacheFactory().ensureService("ExtendTcpInvocationService")).getCluster;
where ExtendTcpInvocationService is defined with <remote-invocation-scheme> but the result is the same.
To sum up : I would like to get the list of all my cache names in a multi-cluster application ; is it possible?