01: /*
02: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
03: */
04: package com.tc.admin.dso;
05:
06: import com.tc.admin.BaseHelper;
07: import com.tc.admin.ConnectionContext;
08:
09: import java.io.IOException;
10: import java.net.URL;
11:
12: import javax.management.AttributeNotFoundException;
13: import javax.management.InstanceNotFoundException;
14: import javax.management.MBeanException;
15: import javax.management.MalformedObjectNameException;
16: import javax.management.ObjectName;
17: import javax.management.ReflectionException;
18: import javax.swing.Icon;
19: import javax.swing.ImageIcon;
20:
21: public class ClientsHelper extends BaseHelper {
22: private static ClientsHelper m_helper = new ClientsHelper();
23: private Icon m_clientsIcon;
24: private Icon m_clientIcon;
25:
26: public static ClientsHelper getHelper() {
27: return m_helper;
28: }
29:
30: public Icon getClientsIcon() {
31: if (m_clientsIcon == null) {
32: URL url = getClass().getResource(
33: ICONS_PATH + "hierarchicalLayout.gif");
34: m_clientsIcon = new ImageIcon(url);
35: }
36:
37: return m_clientsIcon;
38: }
39:
40: public Icon getClientIcon() {
41: if (m_clientIcon == null) {
42: URL url = getClass().getResource(
43: ICONS_PATH + "genericvariable_obj.gif");
44: m_clientIcon = new ImageIcon(url);
45: }
46:
47: return m_clientIcon;
48: }
49:
50: public DSOClient[] getClients(ConnectionContext cc)
51: throws MBeanException, AttributeNotFoundException,
52: InstanceNotFoundException, ReflectionException,
53: IOException, MalformedObjectNameException {
54: ObjectName[] clientNames = getClientNames(cc);
55: int count = (clientNames != null) ? clientNames.length : 0;
56: DSOClient[] result = new DSOClient[count];
57:
58: for (int i = 0; i < count; i++) {
59: result[i] = new DSOClient(cc, clientNames[i]);
60: }
61:
62: return result;
63: }
64:
65: public ObjectName[] getClientNames(ConnectionContext cc)
66: throws MBeanException, AttributeNotFoundException,
67: InstanceNotFoundException, ReflectionException,
68: IOException, MalformedObjectNameException {
69: ObjectName dso = DSOHelper.getHelper().getDSOMBean(cc);
70: return (ObjectName[]) cc.getAttribute(dso, "Clients");
71: }
72: }
|