home *** CD-ROM | disk | FTP | other *** search
- package javax.management;
-
- import java.security.AccessController;
- import java.security.PrivilegedActionException;
-
- public class AttributeValueExp implements ValueExp {
- private static final long serialVersionUID = -7768025046539163385L;
- private String attr;
- private transient MBeanServer server;
-
- public AttributeValueExp() {
- }
-
- public AttributeValueExp(String attr) {
- this.attr = attr;
- }
-
- public String getAttributeName() {
- return this.attr;
- }
-
- public ValueExp apply(ObjectName name) throws BadStringOperationException, BadBinaryOpValueExpException, BadAttributeValueExpException, InvalidApplicationException {
- try {
- Object value = this.getAttribute(name);
- if (value == null) {
- return this.createValueExp(name);
- } else if (value instanceof Number) {
- return new NumericValueExp((Number)value);
- } else if (value instanceof Boolean) {
- return new BooleanValueExp((Boolean)value);
- } else if (value instanceof String) {
- return new StringValueExp((String)value);
- } else {
- throw new BadAttributeValueExpException(value);
- }
- } catch (RuntimeOperationsException var3) {
- throw new BadAttributeValueExpException(this.getAttributeName());
- }
- }
-
- public void setMBeanServer(MBeanServer server) {
- this.server = server;
- }
-
- protected Object getAttribute(ObjectName name) {
- try {
- return this.server.getAttribute(name, this.getAttributeName());
- } catch (MBeanException var6) {
- } catch (AttributeNotFoundException var7) {
- } catch (InstanceNotFoundException var8) {
- } catch (ReflectionException var9) {
- }
-
- throw new RuntimeOperationsException();
- }
-
- private ValueExp createValueExp(ObjectName name) throws BadAttributeValueExpException {
- try {
- MBeanInfo info = (MBeanInfo)AccessController.doPrivileged(new 1(this, name));
- MBeanAttributeInfo[] attrs = info.getAttributes();
-
- for(int i = 0; i < attrs.length; ++i) {
- MBeanAttributeInfo attribute = attrs[i];
- if (attribute.getName().equals(this.getAttributeName())) {
- String type = attribute.getType();
- if (type.equals("java.lang.String")) {
- return new StringValueExp((String)null);
- }
-
- throw new BadAttributeValueExpException((Object)null);
- }
- }
- } catch (PrivilegedActionException var7) {
- }
-
- throw new BadAttributeValueExpException((Object)null);
- }
-
- // $FF: synthetic method
- static MBeanServer access$000(AttributeValueExp x0) {
- return x0.server;
- }
- }
-