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: * @version $Revision: 1.8 $
13: * @serial include
14: */
15: class ClassAttributeValueExp extends AttributeValueExp {
16: private static final long serialVersionUID = -1081892073854801359L;
17:
18: /**
19: * @serial Not used, here only for serialization compatibility
20: */
21: private String attr;
22:
23: private transient MBeanServer server;
24:
25: ClassAttributeValueExp() {
26: super ("classname");
27: }
28:
29: public void setMBeanServer(MBeanServer server) {
30: super .setMBeanServer(server);
31: this .server = server;
32: }
33:
34: public ValueExp apply(ObjectName name)
35: throws BadStringOperationException,
36: BadBinaryOpValueExpException,
37: BadAttributeValueExpException, InvalidApplicationException {
38: try {
39: // getObjectInstance is called for compatibility with the RI;
40: // in fact, when used under security manager, calling this method requires
41: // the proper permission to call getObjectInstance.
42: String className = server.getObjectInstance(name)
43: .getClassName();
44: return new StringValueExp(className);
45: } catch (InstanceNotFoundException ignored) {
46: }
47: throw new BadAttributeValueExpException(null);
48: }
49: }
|