01: /*
02: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright
03: * notice. All rights reserved.
04: */
05: package com.tc.admin.dso;
06:
07: import com.tc.admin.BaseHelper;
08: import com.tc.admin.ConnectionContext;
09: import com.tc.management.beans.L2MBeanNames;
10: import com.tc.object.ObjectID;
11: import com.tc.objectserver.api.GCStats;
12: import com.tc.objectserver.mgmt.ManagedObjectFacade;
13:
14: import java.io.IOException;
15: import java.net.URL;
16:
17: import javax.management.AttributeNotFoundException;
18: import javax.management.InstanceNotFoundException;
19: import javax.management.MBeanException;
20: import javax.management.MalformedObjectNameException;
21: import javax.management.ObjectName;
22: import javax.management.ReflectionException;
23: import javax.swing.Icon;
24: import javax.swing.ImageIcon;
25:
26: public class DSOHelper extends BaseHelper {
27: private static DSOHelper m_helper = new DSOHelper();
28: private Icon m_dsoIcon;
29:
30: public static DSOHelper getHelper() {
31: return m_helper;
32: }
33:
34: public Icon getDSOIcon() {
35: if (m_dsoIcon == null) {
36: URL url = getClass().getResource(
37: ICONS_PATH + "search_menu.gif");
38:
39: if (url != null) {
40: m_dsoIcon = new ImageIcon(url);
41: }
42: }
43:
44: return m_dsoIcon;
45: }
46:
47: public ObjectName getDSOMBean(ConnectionContext cc)
48: throws IOException, MalformedObjectNameException {
49: return cc.queryName(L2MBeanNames.DSO.getCanonicalName());
50: }
51:
52: public ManagedObjectFacade lookupFacade(ConnectionContext cc,
53: ObjectID objectID, int batchSize) throws Exception {
54: ObjectName bean = getDSOMBean(cc);
55: String op = "lookupFacade";
56: Object[] args = new Object[] { objectID, new Integer(batchSize) };
57: String[] types = new String[] { "com.tc.object.ObjectID", "int" };
58:
59: return (ManagedObjectFacade) cc.invoke(bean, op, args, types);
60: }
61:
62: public GCStats[] getGCStats(ConnectionContext cc)
63: throws IOException, MalformedObjectNameException,
64: AttributeNotFoundException, ReflectionException,
65: MBeanException, InstanceNotFoundException {
66: ObjectName bean = getDSOMBean(cc);
67: String attr = "GarbageCollectorStats";
68:
69: return (GCStats[]) cc.getAttribute(bean, attr);
70: }
71: }
|