01: /* JFox, the OpenSource J2EE Application Server
02: *
03: * Copyright (C) 2002 huihoo.com
04: * Distributable under GNU LGPL license
05: * See the GNU Lesser General Public License for more details.
06: */
07:
08: package org.huihoo.jfox.jmx.queries;
09:
10: import javax.management.AttributeValueExp;
11: import javax.management.ValueExp;
12: import javax.management.ObjectName;
13: import javax.management.BadStringOperationException;
14: import javax.management.BadBinaryOpValueExpException;
15: import javax.management.BadAttributeValueExpException;
16: import javax.management.InvalidApplicationException;
17: import javax.management.StringValueExp;
18:
19: /**
20: *
21: * @author <a href="mailto:young_yy@hotmail.com">Young Yang</a>
22: */
23:
24: public class ClassAttributeValueExp extends AttributeValueExp {
25:
26: private String attr;
27:
28: public ClassAttributeValueExp() {
29: attr = "Class";
30: }
31:
32: public ValueExp apply(ObjectName objectname)
33: throws BadStringOperationException,
34: BadBinaryOpValueExpException,
35: BadAttributeValueExpException, InvalidApplicationException {
36: getAttribute(objectname);
37: Object obj = getValue(objectname);
38: if (obj instanceof String)
39: return new StringValueExp((String) obj);
40: else
41: throw new BadAttributeValueExpException(obj);
42: }
43:
44: public String toString() {
45: return attr;
46: }
47:
48: protected Object getValue(ObjectName objectname) {
49: String s = null;
50: try {
51: s = server.getObjectInstance(objectname).getClassName();
52: } catch (Exception exception) {
53: }
54: return s;
55: }
56: }
|