home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2004 December / PCpro_2004_12.ISO / files / webserver / xampp / xampp-tomcat-addon-1.4.9-installer.exe / jmx.jar / javax / management / AttributeValueExp.class (.txt) < prev    next >
Encoding:
Java Class File  |  2002-10-28  |  3.8 KB  |  84 lines

  1. package javax.management;
  2.  
  3. import java.security.AccessController;
  4. import java.security.PrivilegedActionException;
  5.  
  6. public class AttributeValueExp implements ValueExp {
  7.    private static final long serialVersionUID = -7768025046539163385L;
  8.    private String attr;
  9.    private transient MBeanServer server;
  10.  
  11.    public AttributeValueExp() {
  12.    }
  13.  
  14.    public AttributeValueExp(String attr) {
  15.       this.attr = attr;
  16.    }
  17.  
  18.    public String getAttributeName() {
  19.       return this.attr;
  20.    }
  21.  
  22.    public ValueExp apply(ObjectName name) throws BadStringOperationException, BadBinaryOpValueExpException, BadAttributeValueExpException, InvalidApplicationException {
  23.       try {
  24.          Object value = this.getAttribute(name);
  25.          if (value == null) {
  26.             return this.createValueExp(name);
  27.          } else if (value instanceof Number) {
  28.             return new NumericValueExp((Number)value);
  29.          } else if (value instanceof Boolean) {
  30.             return new BooleanValueExp((Boolean)value);
  31.          } else if (value instanceof String) {
  32.             return new StringValueExp((String)value);
  33.          } else {
  34.             throw new BadAttributeValueExpException(value);
  35.          }
  36.       } catch (RuntimeOperationsException var3) {
  37.          throw new BadAttributeValueExpException(this.getAttributeName());
  38.       }
  39.    }
  40.  
  41.    public void setMBeanServer(MBeanServer server) {
  42.       this.server = server;
  43.    }
  44.  
  45.    protected Object getAttribute(ObjectName name) {
  46.       try {
  47.          return this.server.getAttribute(name, this.getAttributeName());
  48.       } catch (MBeanException var6) {
  49.       } catch (AttributeNotFoundException var7) {
  50.       } catch (InstanceNotFoundException var8) {
  51.       } catch (ReflectionException var9) {
  52.       }
  53.  
  54.       throw new RuntimeOperationsException();
  55.    }
  56.  
  57.    private ValueExp createValueExp(ObjectName name) throws BadAttributeValueExpException {
  58.       try {
  59.          MBeanInfo info = (MBeanInfo)AccessController.doPrivileged(new 1(this, name));
  60.          MBeanAttributeInfo[] attrs = info.getAttributes();
  61.  
  62.          for(int i = 0; i < attrs.length; ++i) {
  63.             MBeanAttributeInfo attribute = attrs[i];
  64.             if (attribute.getName().equals(this.getAttributeName())) {
  65.                String type = attribute.getType();
  66.                if (type.equals("java.lang.String")) {
  67.                   return new StringValueExp((String)null);
  68.                }
  69.  
  70.                throw new BadAttributeValueExpException((Object)null);
  71.             }
  72.          }
  73.       } catch (PrivilegedActionException var7) {
  74.       }
  75.  
  76.       throw new BadAttributeValueExpException((Object)null);
  77.    }
  78.  
  79.    // $FF: synthetic method
  80.    static MBeanServer access$000(AttributeValueExp x0) {
  81.       return x0.server;
  82.    }
  83. }
  84.