KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > panoptes > component > jmx > model > DomainQuery


1 /*
2  * Created on 08.mar.2003
3  *
4  * To change this generated comment go to
5  * Window>Preferences>Java>Code Generation>Code and Comments
6  */

7 package net.sf.panoptes.component.jmx.model;
8
9 import java.util.ArrayList JavaDoc;
10 import java.util.List JavaDoc;
11
12 import net.sf.panoptes.model.node.Node;
13 import net.sf.panoptes.model.node.NodeDescriptor;
14 import net.sf.panoptes.model.node.NodeSupport;
15
16 /**
17  * Represents a component query node which will list the query results
18  * as it's children.
19  *
20  * @see net.sf.panoptes.model.component.IComponent
21  * @see net.sf.panoptes.model.component.registry.ComponentName
22  * @see net.sf.panoptes.model.node.NodeSupport
23  * @author Dag Liodden
24  *
25  */

26 public class DomainQuery extends NodeSupport {
27     private boolean global;
28     private List JavaDoc domainCache = null;
29     /**
30      * Constructs a new object which will query a registry for components.
31      *
32      * @param componentRegistry the registry to query
33      * @param query the query
34      */

35     public DomainQuery(NodeSupport parent, boolean global) {
36         super(parent);
37         this.global = global;
38     }
39
40     public void init() {
41
42     }
43
44     /* (non-Javadoc)
45      * @see net.sf.panoptes.view.configurator.NodeSupport#getConfigDescriptor()
46      */

47     public NodeDescriptor getConfigDescriptor() {
48         if (super.getConfigDescriptor() != null)
49             return super.getConfigDescriptor();
50         else
51             return new NodeDescriptor("Domains", "Domains", Node.ICON_DOMAIN);
52     }
53
54     public List JavaDoc getChildren() {
55         return getDomains();
56     }
57
58
59     private List JavaDoc getDomains() {
60         if (domainCache == null) {
61             domainCache = new ArrayList JavaDoc();
62             try {
63                 if (global)
64                     domainCache.addAll(ServerRegistry.getInstance().queryDomains());
65                 else
66                     domainCache.addAll(
67                         (((MBeanServerNode) getContext().get(MBeanServerNode.MBEANSERVERNODE_KEY))
68                             .getDomains()));
69             } catch (Exception JavaDoc e) {
70                 log.error("Unable to execute query", e);
71             }
72
73         }
74         return domainCache;
75     }
76     public boolean mightHaveChildren() {
77         return true;
78     }
79
80     public void refresh() {
81         domainCache = null;
82         getDomains();
83     }
84
85     /* (non-Javadoc)
86      * @see net.sf.panoptes.model.node.Node#getBean()
87      */

88     public Object JavaDoc getBean() {
89         return this;
90     }
91
92
93 }
94
Popular Tags