01: /*
02: * Copyright (C) The MX4J Contributors.
03: * All rights reserved.
04: *
05: * This software is distributed under the terms of the MX4J License version 1.0.
06: * See the terms of the MX4J License in the documentation provided with this software.
07: */
08:
09: package javax.management;
10:
11: /**
12: * The ValueExp that represent the value of an attribute of a specific MBean.
13: *
14: * @version $Revision: 1.6 $
15: * @serial include
16: */
17: class QualifiedAttributeValueExp extends AttributeValueExp {
18: private static final long serialVersionUID = 8832517277410933254L;
19:
20: /**
21: * The MBean class name
22: */
23: private String className;
24:
25: private transient MBeanServer server;
26:
27: QualifiedAttributeValueExp(String className, String attr) {
28: super (attr);
29: this .className = className;
30: }
31:
32: public void setMBeanServer(MBeanServer server) {
33: super .setMBeanServer(server);
34: this .server = server;
35: }
36:
37: public ValueExp apply(ObjectName name)
38: throws BadStringOperationException,
39: BadBinaryOpValueExpException,
40: BadAttributeValueExpException, InvalidApplicationException {
41: try {
42: // getObjectInstance is called for compatibility with the RI;
43: // in fact, when used under security manager, calling this method requires
44: // the proper permission to call getObjectInstance.
45: String cls = server.getObjectInstance(name).getClassName();
46: if (cls.equals(className))
47: return super .apply(name);
48: } catch (InstanceNotFoundException ignored) {
49: }
50: throw new InvalidApplicationException(className);
51: }
52: }
|