1 7 8 package javax.management; 9 10 11 19 class QualifiedAttributeValueExp extends AttributeValueExp { 20 21 22 23 private static final long serialVersionUID = 8832517277410933254L; 24 25 28 private String className; 29 30 31 34 public QualifiedAttributeValueExp() { 35 } 36 37 41 public QualifiedAttributeValueExp(String className, String attr) { 42 super(attr); 43 this.className = className; 44 } 45 46 47 50 public String getAttrClassName() { 51 return className; 52 } 53 54 66 public ValueExp apply(ObjectName name) throws BadStringOperationException , BadBinaryOpValueExpException , 67 BadAttributeValueExpException , InvalidApplicationException { 68 try { 69 MBeanServer server = QueryEval.getMBeanServer(); 70 String v = server.getObjectInstance(name).getClassName(); 71 72 if (v.equals(className)) { 73 return super.apply(name); 74 } 75 throw new InvalidApplicationException ("Class name is " + v + 76 ", should be " + className); 77 78 } catch (Exception e) { 79 throw new InvalidApplicationException ("Qualified attribute: " + e); 80 84 } 85 } 86 87 90 public String toString() { 91 if (className != null) { 92 return className + "." + super.toString(); 93 } else { 94 return super.toString(); 95 } 96 } 97 98 } 99 | Popular Tags |