私はこれを自分で書かなければなりませんでした。他の人がそれを必要とする場合のコードはここにあります。
@Controller
@RequestMapping(value = "/tools/ehcache")
public class EhcacheManagerController {
private static final String VIEW_URL = "/WEB-INF/views/tools/ehcache/ehcache.jsp";
private static final String ALL = "all";
List<CacheManager> allCacheManagers = CacheManager.ALL_CACHE_MANAGERS;
private static final Log logger = LogFactory.getLog(EhcacheManagerController.class);
@RequestMapping(method = RequestMethod.GET)
protected String loadPage(ModelMap modelMap) throws Exception {
// Manager (keyed by name) --> Cache (keyed by name) --> Peer Information (keyed by peer Name)
Map<String,Map<String,Map<String,String>>> managerMap = new HashMap<String,Map<String,Map<String,String>>>();
for (CacheManager cacheManager : allCacheManagers) {
Map<String,Map<String,String>> cacheMap = new HashMap<String,Map<String,String>>();
managerMap.put(cacheManager.getName(), cacheMap);
String[] cacheNames = cacheManager.getCacheNames();
for (String name : cacheNames) {
Map<String,String> peerInfoMap = new HashMap<String,String>();
cacheMap.put(name,peerInfoMap);
CacheManagerPeerProvider provider = cacheManager.getCacheManagerPeerProvider("RMI");
if (provider == null) {
peerInfoMap.put("nopeer","no status");
break;
}
Cache ehcache = cacheManager.getCache(name);
List<CachePeer> cachePeers = provider.listRemoteCachePeers(ehcache);
for (CachePeer cachePeer : cachePeers) {
StringBuilder cacheStatus = new StringBuilder();
String peerName = cachePeer.getName();
cacheStatus.append("url='").append(cachePeer.getUrl()).append("' ");
cacheStatus.append("keyssize='").append(cachePeer.getKeys().size()).append("' ");
peerInfoMap.put(peerName,cacheStatus.toString());
}
}
}
modelMap.put("managerMap", managerMap);
return VIEW_URL;
}
}
jsp
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>EHCache</title>
</head>
<body>
<h1>EHCache</h1>
<p><a href="/tools/ehcache/clear?name=all">Clear All</a></p>
<c:forEach items="${managerMap}" var="manager">
<h2>Manager: '${manager.key}'</h2>
<c:forEach var="cacheMap" items="${manager.value}">
<h3>Cache: '${cacheMap.key}'</h3>
<p><a href="/tools/ehcache/clear?cacheManagerName=${manager.key}&cacheName=${cacheMap.key}">clear</a></p>
<c:forEach var="peerInfoMap" items="${cacheMap.value}">
<li>peer name = ${peerInfoMap.key} peer status = ${peerInfoMap.value}</li>
</c:forEach>
</c:forEach>
</c:forEach>
</body>
</html>