1 package net.sf.panoptes.component.jmx.jelly; 2 3 import javax.management.MalformedObjectNameException ; 4 import javax.management.ObjectName ; 5 import javax.management.QueryExp ; 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 20 private Log log = LogFactory.getLog(getClass()); 21 22 private MBeanWrapper mbean; 23 24 25 private XMLOutput output; 26 27 private ObjectName objectName = null; 28 private QueryExp queryExp = null; 29 private String varName = null; 30 31 private boolean visible = true; 32 33 private String childFactoryClass = null; 34 35 private String childDescriberClassName = null; 36 37 40 public void doTag(XMLOutput output) throws JellyTagException { 41 super.doTag(output); 42 43 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 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 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 objectNameString) throws MalformedObjectNameException { 73 objectName = new ObjectName (objectNameString); 74 } 75 76 public void setVisible(boolean visible) { 77 this.visible = visible; 78 } 79 80 public void setVar(String var) { 81 this.varName = var; 82 } 83 84 public void setChildFactory(String className) { 85 this.childFactoryClass = className; 86 } 87 88 public void setChildDescriberClass(String className) { 89 this.childDescriberClassName = className; 90 } 91 92 } 93 | Popular Tags |