您应该能够使用对象查询语言(OQL)在jhat中查询所有集合或单个集合。
您不一定会调用任意方法,但可以使用可用函数编写一些复杂的查询。
A. Sundararajan有一些关于这个主题的有趣的博客文章,展示你可以做什么。请参阅here和here。
举例来说,你可以发现有以下查询的关键测试的java.util.HashMap
所有实例:
select s from java.util.HashMap s where contains(s.table, function(it) {
if (it && it.key && it.key.value && it.key.value.toString() == 'test') {
return true;
}
return false;
})
这应该找到一个java.util.concurrent.ConcurrentHashMap
相同的密钥:
select s from java.util.concurrent.ConcurrentHashMap s where contains(s.segments, function(it) {
if (!it || !it.table) {
return false;
}
var i, e;
for (i=0; i < it.table.length; i = i + 1) {
e = it.table[i];
if (e) {
return e.key && e.key.value && e.key.value.toString() == 'test';
}
}
return false;
})
谢谢 - 我并没有真正意识到OQL是如此强大。也许当我有时间的时候,我会写一个工具来允许'正确'查询集合,但是这些OQL查询将会做我现在想要的! – Rich 2010-02-20 09:16:49