1 7 8 package javax.management; 9 10 11 import javax.management.MBeanServer ; 13 14 20 public class AttributeValueExp implements ValueExp { 21 22 23 24 private static final long serialVersionUID = -7768025046539163385L; 25 26 29 private String attr; 30 31 36 @Deprecated 37 public AttributeValueExp() { 38 } 39 40 47 public AttributeValueExp(String attr) { 48 this.attr = attr; 49 } 50 51 56 public String getAttributeName() { 57 return attr; 58 } 59 60 73 public ValueExp apply(ObjectName name) throws BadStringOperationException , BadBinaryOpValueExpException , 74 BadAttributeValueExpException , InvalidApplicationException { 75 Object result = getAttribute(name); 76 77 if (result instanceof Number ) { 78 return new NumericValueExp ((Number )result); 79 } else if (result instanceof String ) { 80 return new StringValueExp ((String )result); 81 } else if (result instanceof Boolean ) { 82 return new BooleanValueExp ((Boolean )result); 83 } else { 84 throw new BadAttributeValueExpException (result); 85 } 86 } 87 88 91 public String toString() { 92 return attr; 93 } 94 95 96 101 104 public void setMBeanServer(MBeanServer s) { 105 } 106 107 108 118 protected Object getAttribute(ObjectName name) { 119 try { 120 122 MBeanServer server = QueryEval.getMBeanServer(); 123 124 return server.getAttribute(name, attr); 125 } catch (Exception re) { 126 return null; 127 } 128 } 129 130 } 131 | Popular Tags |