KickJava   Java API By Example, From Geeks To Geeks.

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


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 com.tc.admin.BaseHelper;
7 import com.tc.admin.ConnectionContext;
8 import com.tc.management.beans.L2MBeanNames;
9 import com.tc.object.ObjectID;
10 import com.tc.objectserver.api.GCStats;
11 import com.tc.objectserver.mgmt.ManagedObjectFacade;
12
13 import java.net.URL JavaDoc;
14
15 import javax.management.ObjectName JavaDoc;
16 import javax.swing.Icon JavaDoc;
17 import javax.swing.ImageIcon JavaDoc;
18
19 public class DSOHelper extends BaseHelper {
20   private static DSOHelper m_helper = new DSOHelper();
21   private Icon JavaDoc m_dsoIcon;
22
23   public static DSOHelper getHelper() {
24     return m_helper;
25   }
26
27   public Icon JavaDoc getDSOIcon() {
28     if (m_dsoIcon == null) {
29       URL JavaDoc url = getClass().getResource(ICONS_PATH + "search_menu.gif");
30
31       if (url != null) {
32         m_dsoIcon = new ImageIcon JavaDoc(url);
33       }
34     }
35
36     return m_dsoIcon;
37   }
38
39   public ObjectName JavaDoc getDSOMBean(ConnectionContext cc) {
40     try {
41       return cc.queryName(L2MBeanNames.DSO.getCanonicalName());
42     } catch (Exception JavaDoc e) {/**/
43     }
44
45     return null;
46   }
47
48   public ManagedObjectFacade lookupFacade(ConnectionContext cc, ObjectID objectID, int batchSize) throws Exception JavaDoc {
49     ObjectName JavaDoc bean = getDSOMBean(cc);
50     String JavaDoc op = "lookupFacade";
51     Object JavaDoc[] args = new Object JavaDoc[] { objectID, new Integer JavaDoc(batchSize) };
52     String JavaDoc[] types = new String JavaDoc[] { "com.tc.object.ObjectID", "int" };
53
54     return (ManagedObjectFacade) cc.invoke(bean, op, args, types);
55   }
56
57   public GCStats[] getGCStats(ConnectionContext cc) throws Exception JavaDoc {
58     ObjectName JavaDoc bean = getDSOMBean(cc);
59     String JavaDoc attr = "GarbageCollectorStats";
60
61     return (GCStats[]) cc.getAttribute(bean, attr);
62   }
63 }
64
Popular Tags