KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > admin > dso > GCStatsPanel


1 /*
2  * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
3  */

4 package com.tc.admin.dso;
5
6 import org.dijon.ContainerResource;
7
8 import com.tc.admin.AdminClient;
9 import com.tc.admin.AdminClientContext;
10 import com.tc.admin.ConnectionContext;
11 import com.tc.admin.common.XContainer;
12 import com.tc.admin.common.XObjectTable;
13 import com.tc.objectserver.api.GCStats;
14 import com.tc.stats.DSOMBean;
15
16 import javax.management.Notification JavaDoc;
17 import javax.management.NotificationListener JavaDoc;
18
19 public class GCStatsPanel extends XContainer
20   implements NotificationListener JavaDoc
21 {
22   private ConnectionContext m_cc;
23   private XObjectTable m_table;
24
25   public GCStatsPanel(ConnectionContext cc) {
26     super();
27
28     m_cc = cc;
29
30     AdminClientContext acc = AdminClient.getContext();
31     load((ContainerResource)acc.topRes.getComponent("GCStatsPanel"));
32
33     m_table = (XObjectTable)findComponent("GCStatsTable");
34
35     GCStatsTableModel model = new GCStatsTableModel();
36     m_table.setModel(model);
37
38     DSOHelper helper = DSOHelper.getHelper();
39     GCStats[] gcStats = null;
40
41     try {
42       gcStats = helper.getGCStats(cc);
43       cc.addNotificationListener(helper.getDSOMBean(cc), this);
44     }
45     catch(Exception JavaDoc e) {
46       AdminClient.getContext().log(e);
47       gcStats = new GCStats[]{};
48     }
49
50     model.setGCStats(gcStats);
51   }
52
53   public void handleNotification(Notification JavaDoc notice, Object JavaDoc notUsed) {
54     String JavaDoc type = notice.getType();
55
56     if(DSOMBean.GC_COMPLETED.equals(type)) {
57       GCStatsTableModel model = (GCStatsTableModel)m_table.getModel();
58
59       model.addGCStats((GCStats)notice.getSource());
60     }
61   }
62
63   public void tearDown() {
64     try {
65       if(m_cc != null && m_cc.isConnected()) {
66         DSOHelper helper = DSOHelper.getHelper();
67         m_cc.removeNotificationListener(helper.getDSOMBean(m_cc), this);
68       }
69     }
70     catch(Exception JavaDoc e) {/**/}
71
72     super.tearDown();
73
74     m_cc = null;
75     m_table = null;
76   }
77 }
78
Popular Tags