Author: max.andersen(a)jboss.com
Date: 2006-09-20 17:18:03 -0400 (Wed, 20 Sep 2006)
New Revision: 10500
Modified:
trunk/HibernateExt/tools/src/java/org/hibernate/tool/stat/StatisticsBrowser.java
trunk/HibernateExt/tools/src/java/org/hibernate/tool/stat/StatisticsTreeModel.java
Log:
HBX-759
include Second level cache statistics (no entry browsing yet)
Modified:
trunk/HibernateExt/tools/src/java/org/hibernate/tool/stat/StatisticsBrowser.java
===================================================================
---
trunk/HibernateExt/tools/src/java/org/hibernate/tool/stat/StatisticsBrowser.java 2006-09-20
17:11:37 UTC (rev 10499)
+++
trunk/HibernateExt/tools/src/java/org/hibernate/tool/stat/StatisticsBrowser.java 2006-09-20
21:18:03 UTC (rev 10500)
@@ -15,6 +15,7 @@
import javax.swing.ToolTipManager;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
+import javax.swing.table.TableCellRenderer;
import org.hibernate.stat.Statistics;
@@ -47,7 +48,17 @@
JScrollPane treePane = new JScrollPane(tree);
- final JTable table = new JTable();
+ final JTable table = new JTable() {
+ public TableCellRenderer getDefaultRenderer(Class columnClass) {
+ TableCellRenderer defaultRenderer = super.getDefaultRenderer( columnClass );
+
+ if(defaultRenderer==null) {
+ return super.getDefaultRenderer( Object.class );
+ } else {
+ return defaultRenderer;
+ }
+ }
+ };
JScrollPane tablePane = new JScrollPane(table);
tablePane.getViewport().setBackground( table.getBackground() );
Modified:
trunk/HibernateExt/tools/src/java/org/hibernate/tool/stat/StatisticsTreeModel.java
===================================================================
---
trunk/HibernateExt/tools/src/java/org/hibernate/tool/stat/StatisticsTreeModel.java 2006-09-20
17:11:37 UTC (rev 10499)
+++
trunk/HibernateExt/tools/src/java/org/hibernate/tool/stat/StatisticsTreeModel.java 2006-09-20
21:18:03 UTC (rev 10500)
@@ -1,6 +1,11 @@
package org.hibernate.tool.stat;
+import java.util.Collections;
+import java.util.Map;
+
+import org.hibernate.stat.SecondLevelCacheStatistics;
import org.hibernate.stat.Statistics;
+import org.hibernate.util.IdentityMap;
public class StatisticsTreeModel extends AbstractTreeModel {
@@ -9,9 +14,10 @@
String queries = "Queries";
String entities = "Entities";
String collections = "Collections";
+ String secondlevelcache = "Cache";
+ Map im = IdentityMap.instantiate( 10 );
-
public StatisticsTreeModel(Statistics stats) {
this.stats = stats;
}
@@ -21,7 +27,8 @@
switch(index) {
case 0: return entities;
case 1: return collections;
- case 2: return queries;
+ case 2: return queries;
+ case 3: return secondlevelcache;
}
} else if(parent==entities) {
return stats.getEntityStatistics(stats.getEntityNames()[index]);
@@ -29,19 +36,29 @@
return stats.getCollectionStatistics(stats.getCollectionRoleNames()[index]);
} else if(parent==queries) {
return stats.getQueryStatistics(stats.getQueries()[index]);
+ } else if(parent==secondlevelcache) {
+ return stats.getSecondLevelCacheStatistics(
stats.getSecondLevelCacheRegionNames()[index]);
+ } else if(parent instanceof SecondLevelCacheStatistics) {
+ SecondLevelCacheStatistics stats = (SecondLevelCacheStatistics) parent;
+ return stats.getEntries();
}
return null;
}
public int getChildCount(Object parent) {
if(parent==stats) {
- return 3;
+ return 4;
} else if(parent==entities) {
return stats.getEntityNames().length;
} else if(parent==collections) {
return stats.getCollectionRoleNames().length;
} else if(parent==queries) {
return stats.getQueries().length;
+ } else if(parent==secondlevelcache) {
+ return stats.getSecondLevelCacheRegionNames().length;
+ } else if(parent instanceof SecondLevelCacheStatistics) {
+ /*SecondLevelCacheStatistics stats = (SecondLevelCacheStatistics) parent;
+ return stats.getEntries().size();*/
}
return 0;
}
@@ -71,8 +88,12 @@
return o==entities; // hack
}
+ public boolean isCache(Object o) {
+ return o==secondlevelcache;
+ }
+
public boolean isContainer(Object o) {
- return isEntities( o ) || isQueries( o ) || isCollections( o );
+ return isEntities( o ) || isQueries( o ) || isCollections( o ) || isCache( o );
}
}
\ No newline at end of file