KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > panoptes > component > jmx > jelly > MBeanQueryTag


1 package net.sf.panoptes.component.jmx.jelly;
2
3 import javax.management.MalformedObjectNameException JavaDoc;
4 import javax.management.ObjectName JavaDoc;
5 import javax.management.QueryExp JavaDoc;
6
7 import net.sf.panoptes.model.node.NodeDescriber;
8 import net.sf.panoptes.component.jmx.model.MBeanWrapper;
9 import net.sf.panoptes.component.jmx.model.MBeanQuery;
10
11 import org.apache.commons.jelly.JellyTagException;
12 import org.apache.commons.jelly.MissingAttributeException;
13 import org.apache.commons.jelly.XMLOutput;
14 import org.apache.commons.logging.Log;
15 import org.apache.commons.logging.LogFactory;
16
17 public class MBeanQueryTag extends NodeTag {
18
19     /** The Log to which logging calls will be made. */
20     private Log log = LogFactory.getLog(getClass());
21
22     private MBeanWrapper mbean;
23
24     /** Jelly XMLOutput */
25     private XMLOutput output;
26
27     private ObjectName JavaDoc objectName = null;
28     private QueryExp JavaDoc queryExp = null;
29     private String JavaDoc varName = null;
30
31     private boolean visible = true;
32
33     private String JavaDoc childFactoryClass = null;
34
35     private String JavaDoc childDescriberClassName = null;
36
37     /*
38      * @see org.apache.commons.jelly.Tag#doTag(org.apache.commons.jelly.XMLOutput)
39      */

40     public void doTag(XMLOutput output) throws JellyTagException {
41         super.doTag(output);
42
43         // check for missing attributes
44
if (objectName == null) {
45             throw new MissingAttributeException("objectName");
46         }
47         
48         MBeanQuery query = new MBeanQuery(getParentNode());
49         try {
50             if (childFactoryClass != null) query.setChildFactoryClass(Class.forName(childFactoryClass));
51         } catch (Exception JavaDoc e) {
52             throw new JellyTagException("Invalid child class: " + childFactoryClass, e);
53         }
54         
55         try {
56             if (childDescriberClassName != null) query.setChildDescriber((NodeDescriber) Class.forName(childDescriberClassName).newInstance());
57         } catch (Exception JavaDoc e) {
58             throw new JellyTagException("Invalid child desciber class", e);
59         }
60         
61         query.setQuery(objectName, queryExp);
62         doDefault(query);
63         if (visible) getParentNode().addChild(query);
64
65         if (varName != null) {
66             context.setVariable(varName, query);
67         }
68
69         this.output = output;
70     }
71
72     public void setObjectName(String JavaDoc objectNameString) throws MalformedObjectNameException JavaDoc {
73         objectName = new ObjectName JavaDoc(objectNameString);
74     }
75     
76     public void setVisible(boolean visible) {
77         this.visible = visible;
78     }
79     
80     public void setVar(String JavaDoc var) {
81         this.varName = var;
82     }
83     
84     public void setChildFactory(String JavaDoc className) {
85         this.childFactoryClass = className;
86     }
87     
88     public void setChildDescriberClass(String JavaDoc className) {
89         this.childDescriberClassName = className;
90     }
91
92 }
93
Popular Tags