KickJava   Java API By Example, From Geeks To Geeks.

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


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
9 import java.io.IOException JavaDoc;
10 import java.net.URL JavaDoc;
11
12 import javax.management.AttributeNotFoundException JavaDoc;
13 import javax.management.InstanceNotFoundException JavaDoc;
14 import javax.management.MBeanException JavaDoc;
15 import javax.management.ObjectName JavaDoc;
16 import javax.management.ReflectionException JavaDoc;
17 import javax.swing.Icon JavaDoc;
18 import javax.swing.ImageIcon JavaDoc;
19
20 public class ClientsHelper extends BaseHelper {
21   private static ClientsHelper m_helper = new ClientsHelper();
22   private Icon JavaDoc m_clientsIcon;
23   private Icon JavaDoc m_clientIcon;
24
25   public static ClientsHelper getHelper() {
26     return m_helper;
27   }
28
29   public Icon JavaDoc getClientsIcon() {
30     if(m_clientsIcon == null) {
31       URL JavaDoc url = getClass().getResource(ICONS_PATH+"hierarchicalLayout.gif");
32       m_clientsIcon = new ImageIcon JavaDoc(url);
33     }
34
35     return m_clientsIcon;
36   }
37
38   public Icon JavaDoc getClientIcon() {
39     if(m_clientIcon == null) {
40       URL JavaDoc url = getClass().getResource(ICONS_PATH+"genericvariable_obj.gif");
41       m_clientIcon = new ImageIcon JavaDoc(url);
42     }
43
44     return m_clientIcon;
45   }
46
47   public DSOClient[] getClients(ConnectionContext cc)
48     throws MBeanException JavaDoc,
49            AttributeNotFoundException JavaDoc,
50            InstanceNotFoundException JavaDoc,
51            ReflectionException JavaDoc,
52            IOException JavaDoc
53   {
54     ObjectName JavaDoc[] 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 JavaDoc[] getClientNames(ConnectionContext cc)
66     throws MBeanException JavaDoc,
67            AttributeNotFoundException JavaDoc,
68            InstanceNotFoundException JavaDoc,
69            ReflectionException JavaDoc,
70            IOException JavaDoc
71   {
72     ObjectName JavaDoc dso = DSOHelper.getHelper().getDSOMBean(cc);
73     return (ObjectName JavaDoc[])cc.getAttribute(dso, "Clients");
74   }
75 }
76
Popular Tags