javax.management.Attribute#getValue ( )源码实例Demo

下面列出了javax.management.Attribute#getValue ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: Tomcat8-Source-Read   文件: BaseModelMBean.java
/**
 * Send an <code>AttributeChangeNotification</code> to all registered
 * listeners.
 *
 * @param oldValue The original value of the <code>Attribute</code>
 * @param newValue The new value of the <code>Attribute</code>
 *
 * @exception MBeanException if an object initializer throws an
 *  exception
 * @exception RuntimeOperationsException wraps IllegalArgumentException
 *  when the specified notification is <code>null</code> or invalid
 */
@Override
public void sendAttributeChangeNotification
    (Attribute oldValue, Attribute newValue)
    throws MBeanException, RuntimeOperationsException {

    // Calculate the class name for the change notification
    String type = null;
    if (newValue.getValue() != null)
        type = newValue.getValue().getClass().getName();
    else if (oldValue.getValue() != null)
        type = oldValue.getValue().getClass().getName();
    else
        return;  // Old and new are both null == no change

    AttributeChangeNotification notification =
        new AttributeChangeNotification
        (this, 1, System.currentTimeMillis(),
         "Attribute value has changed",
         oldValue.getName(), type,
         oldValue.getValue(), newValue.getValue());
    sendAttributeChangeNotification(notification);

}
 
/**
 * Set the value of a specific attribute of this MBean.
 *
 * @param attribute The identification of the attribute to be set
 *  and the new value
 *
 * @exception AttributeNotFoundException if this attribute is not
 *  supported by this MBean
 * @exception MBeanException if the initializer of an object
 *  throws an exception
 * @exception ReflectionException if a Java reflection exception
 *  occurs when invoking the getter
 */
 @Override
public void setAttribute(Attribute attribute) throws AttributeNotFoundException, MBeanException,
        ReflectionException {

    // Validate the input parameters
    if (attribute == null) {
        throw new RuntimeOperationsException(
                new IllegalArgumentException("Attribute is null"),
                "Attribute is null");
    }

    String name = attribute.getName();
    Object value = attribute.getValue();
    if (name == null) {
        throw new RuntimeOperationsException(
                new IllegalArgumentException("Attribute name is null"),
                "Attribute name is null");
    }

    ContextResourceLink crl = doGetManagedResource();

    if ("global".equals(name)) {
        crl.setGlobal((String) value);
    } else if ("description".equals(name)) {
        crl.setDescription((String) value);
    } else if ("name".equals(name)) {
        crl.setName((String) value);
    } else if ("type".equals(name)) {
        crl.setType((String) value);
    } else {
        crl.setProperty(name, "" + value);
    }

    // cannot use side-effects.  It's removed and added back each time
    // there is a modification in a resource.
    NamingResources nr = crl.getNamingResources();
    nr.removeResourceLink(crl.getName());
    nr.addResourceLink(crl);
}
 
源代码3 项目: jdk1.8-source-analysis   文件: JmxMBeanServer.java
/**
 * Clone attribute.
 */
private Attribute cloneAttribute(Attribute attribute) {
    if (attribute != null) {
        if (!attribute.getClass().equals(Attribute.class)) {
            return new Attribute(attribute.getName(), attribute.getValue());
        }
    }
    return attribute;
}
 
源代码4 项目: jdk1.8-source-analysis   文件: MBeanSupport.java
public final void setAttribute(Attribute attribute)
        throws AttributeNotFoundException,
               InvalidAttributeValueException,
               MBeanException,
               ReflectionException {
    final String name = attribute.getName();
    final Object value = attribute.getValue();
    perInterface.setAttribute(resource, name, value, getCookie());
}
 
源代码5 项目: JDKSourceCode1.8   文件: MBeanSupport.java
public final void setAttribute(Attribute attribute)
        throws AttributeNotFoundException,
               InvalidAttributeValueException,
               MBeanException,
               ReflectionException {
    final String name = attribute.getName();
    final Object value = attribute.getValue();
    perInterface.setAttribute(resource, name, value, getCookie());
}
 
源代码6 项目: dragonwell8_jdk   文件: MBeanSupport.java
public final void setAttribute(Attribute attribute)
        throws AttributeNotFoundException,
               InvalidAttributeValueException,
               MBeanException,
               ReflectionException {
    final String name = attribute.getName();
    final Object value = attribute.getValue();
    perInterface.setAttribute(resource, name, value, getCookie());
}
 
源代码7 项目: TencentKona-8   文件: JmxMBeanServer.java
/**
 * Clone attribute.
 */
private Attribute cloneAttribute(Attribute attribute) {
    if (attribute != null) {
        if (!attribute.getClass().equals(Attribute.class)) {
            return new Attribute(attribute.getName(), attribute.getValue());
        }
    }
    return attribute;
}
 
源代码8 项目: openjdk-jdk8u   文件: JmxMBeanServer.java
/**
 * Clone attribute.
 */
private Attribute cloneAttribute(Attribute attribute) {
    if (attribute != null) {
        if (!attribute.getClass().equals(Attribute.class)) {
            return new Attribute(attribute.getName(), attribute.getValue());
        }
    }
    return attribute;
}
 
源代码9 项目: openjdk-jdk8u   文件: MBeanSupport.java
public final void setAttribute(Attribute attribute)
        throws AttributeNotFoundException,
               InvalidAttributeValueException,
               MBeanException,
               ReflectionException {
    final String name = attribute.getName();
    final Object value = attribute.getValue();
    perInterface.setAttribute(resource, name, value, getCookie());
}
 
源代码10 项目: JDKSourceCode1.8   文件: JmxMBeanServer.java
/**
 * Clone attribute.
 */
private Attribute cloneAttribute(Attribute attribute) {
    if (attribute != null) {
        if (!attribute.getClass().equals(Attribute.class)) {
            return new Attribute(attribute.getName(), attribute.getValue());
        }
    }
    return attribute;
}
 
源代码11 项目: jdk8u60   文件: MBeanSupport.java
public final void setAttribute(Attribute attribute)
        throws AttributeNotFoundException,
               InvalidAttributeValueException,
               MBeanException,
               ReflectionException {
    final String name = attribute.getName();
    final Object value = attribute.getValue();
    perInterface.setAttribute(resource, name, value, getCookie());
}
 
源代码12 项目: jdk8u60   文件: RequiredModelMBean.java
public void sendAttributeChangeNotification(Attribute inOldVal,
                                            Attribute inNewVal)
    throws MBeanException, RuntimeOperationsException {
    final String mth =
        "sendAttributeChangeNotification(Attribute, Attribute)";
    if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
        MODELMBEAN_LOGGER.logp(Level.FINER,
                RequiredModelMBean.class.getName(),mth,
            "Entry");
    }

    // do we really want to do this?
    if ((inOldVal == null) || (inNewVal == null))
        throw new RuntimeOperationsException(new
           IllegalArgumentException("Attribute object must not be null"),
           "Exception occurred trying to send " +
           "attribute change notification of a ModelMBean");


    if (!(inOldVal.getName().equals(inNewVal.getName())))
        throw new RuntimeOperationsException(new
            IllegalArgumentException("Attribute names are not the same"),
            "Exception occurred trying to send " +
            "attribute change notification of a ModelMBean");


    Object newVal = inNewVal.getValue();
    Object oldVal = inOldVal.getValue();
    String className = "unknown";
    if (newVal != null)
        className = newVal.getClass().getName();
    if (oldVal != null)
        className = oldVal.getClass().getName();

    AttributeChangeNotification myNtfyObj = new
        AttributeChangeNotification(this,
                                    1,
                                    ((new Date()).getTime()),
                                    "AttributeChangeDetected",
                                    inOldVal.getName(),
                                    className,
                                    inOldVal.getValue(),
                                    inNewVal.getValue());

    sendAttributeChangeNotification(myNtfyObj);

    if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
        MODELMBEAN_LOGGER.logp(Level.FINER,
                RequiredModelMBean.class.getName(),mth,
            "Exit");
    }

}
 
源代码13 项目: Tomcat8-Source-Read   文件: ContextResourceMBean.java
/**
 * Set the value of a specific attribute of this MBean.
 *
 * @param attribute The identification of the attribute to be set
 *  and the new value
 *
 * @exception AttributeNotFoundException if this attribute is not
 *  supported by this MBean
 * @exception MBeanException if the initializer of an object
 *  throws an exception
 * @exception ReflectionException if a Java reflection exception
 *  occurs when invoking the getter
 */
 @Override
public void setAttribute(Attribute attribute) throws AttributeNotFoundException, MBeanException,
        ReflectionException {

    // Validate the input parameters
    if (attribute == null) {
        throw new RuntimeOperationsException(
                new IllegalArgumentException("Attribute is null"),
                "Attribute is null");
    }
    String name = attribute.getName();
    Object value = attribute.getValue();
    if (name == null) {
        throw new RuntimeOperationsException(
                new IllegalArgumentException("Attribute name is null"),
                "Attribute name is null");
    }

    ContextResource cr = doGetManagedResource();

    if ("auth".equals(name)) {
        cr.setAuth((String)value);
    } else if ("description".equals(name)) {
        cr.setDescription((String)value);
    } else if ("name".equals(name)) {
        cr.setName((String)value);
    } else if ("scope".equals(name)) {
        cr.setScope((String)value);
    } else if ("type".equals(name)) {
        cr.setType((String)value);
    } else {
        cr.setProperty(name, "" + value);
    }

    // cannot use side-effects.  It's removed and added back each time
    // there is a modification in a resource.
    NamingResources nr = cr.getNamingResources();
    nr.removeResource(cr.getName());
    nr.addResource(cr);
}
 
public void sendAttributeChangeNotification(Attribute inOldVal,
                                            Attribute inNewVal)
    throws MBeanException, RuntimeOperationsException {
    final String mth =
        "sendAttributeChangeNotification(Attribute, Attribute)";
    if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
        MODELMBEAN_LOGGER.logp(Level.FINER,
                RequiredModelMBean.class.getName(),mth,
            "Entry");
    }

    // do we really want to do this?
    if ((inOldVal == null) || (inNewVal == null))
        throw new RuntimeOperationsException(new
           IllegalArgumentException("Attribute object must not be null"),
           "Exception occurred trying to send " +
           "attribute change notification of a ModelMBean");


    if (!(inOldVal.getName().equals(inNewVal.getName())))
        throw new RuntimeOperationsException(new
            IllegalArgumentException("Attribute names are not the same"),
            "Exception occurred trying to send " +
            "attribute change notification of a ModelMBean");


    Object newVal = inNewVal.getValue();
    Object oldVal = inOldVal.getValue();
    String className = "unknown";
    if (newVal != null)
        className = newVal.getClass().getName();
    if (oldVal != null)
        className = oldVal.getClass().getName();

    AttributeChangeNotification myNtfyObj = new
        AttributeChangeNotification(this,
                                    1,
                                    ((new Date()).getTime()),
                                    "AttributeChangeDetected",
                                    inOldVal.getName(),
                                    className,
                                    inOldVal.getValue(),
                                    inNewVal.getValue());

    sendAttributeChangeNotification(myNtfyObj);

    if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
        MODELMBEAN_LOGGER.logp(Level.FINER,
                RequiredModelMBean.class.getName(),mth,
            "Exit");
    }

}
 
源代码15 项目: dragonwell8_jdk   文件: XMBeanAttributes.java
private boolean isViewable(Attribute attribute) {
    Object data = attribute.getValue();
    return XDataViewer.isViewableValue(data);

}
 
源代码16 项目: openjdk-jdk8u   文件: XMBeanAttributes.java
private boolean isViewable(Attribute attribute) {
    Object data = attribute.getValue();
    return XDataViewer.isViewableValue(data);

}
 
源代码17 项目: TencentKona-8   文件: XMBeanAttributes.java
private boolean isViewable(Attribute attribute) {
    Object data = attribute.getValue();
    return XDataViewer.isViewableValue(data);

}
 
源代码18 项目: JDKSourceCode1.8   文件: RequiredModelMBean.java
public void sendAttributeChangeNotification(Attribute inOldVal,
                                            Attribute inNewVal)
    throws MBeanException, RuntimeOperationsException {
    final String mth =
        "sendAttributeChangeNotification(Attribute, Attribute)";
    if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
        MODELMBEAN_LOGGER.logp(Level.FINER,
                RequiredModelMBean.class.getName(),mth,
            "Entry");
    }

    // do we really want to do this?
    if ((inOldVal == null) || (inNewVal == null))
        throw new RuntimeOperationsException(new
           IllegalArgumentException("Attribute object must not be null"),
           "Exception occurred trying to send " +
           "attribute change notification of a ModelMBean");


    if (!(inOldVal.getName().equals(inNewVal.getName())))
        throw new RuntimeOperationsException(new
            IllegalArgumentException("Attribute names are not the same"),
            "Exception occurred trying to send " +
            "attribute change notification of a ModelMBean");


    Object newVal = inNewVal.getValue();
    Object oldVal = inOldVal.getValue();
    String className = "unknown";
    if (newVal != null)
        className = newVal.getClass().getName();
    if (oldVal != null)
        className = oldVal.getClass().getName();

    AttributeChangeNotification myNtfyObj = new
        AttributeChangeNotification(this,
                                    1,
                                    ((new Date()).getTime()),
                                    "AttributeChangeDetected",
                                    inOldVal.getName(),
                                    className,
                                    inOldVal.getValue(),
                                    inNewVal.getValue());

    sendAttributeChangeNotification(myNtfyObj);

    if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
        MODELMBEAN_LOGGER.logp(Level.FINER,
                RequiredModelMBean.class.getName(),mth,
            "Exit");
    }

}
 
源代码19 项目: TencentKona-8   文件: RequiredModelMBean.java
public void sendAttributeChangeNotification(Attribute inOldVal,
                                            Attribute inNewVal)
    throws MBeanException, RuntimeOperationsException {
    final String mth =
        "sendAttributeChangeNotification(Attribute, Attribute)";
    if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
        MODELMBEAN_LOGGER.logp(Level.FINER,
                RequiredModelMBean.class.getName(),mth,
            "Entry");
    }

    // do we really want to do this?
    if ((inOldVal == null) || (inNewVal == null))
        throw new RuntimeOperationsException(new
           IllegalArgumentException("Attribute object must not be null"),
           "Exception occurred trying to send " +
           "attribute change notification of a ModelMBean");


    if (!(inOldVal.getName().equals(inNewVal.getName())))
        throw new RuntimeOperationsException(new
            IllegalArgumentException("Attribute names are not the same"),
            "Exception occurred trying to send " +
            "attribute change notification of a ModelMBean");


    Object newVal = inNewVal.getValue();
    Object oldVal = inOldVal.getValue();
    String className = "unknown";
    if (newVal != null)
        className = newVal.getClass().getName();
    if (oldVal != null)
        className = oldVal.getClass().getName();

    AttributeChangeNotification myNtfyObj = new
        AttributeChangeNotification(this,
                                    1,
                                    ((new Date()).getTime()),
                                    "AttributeChangeDetected",
                                    inOldVal.getName(),
                                    className,
                                    inOldVal.getValue(),
                                    inNewVal.getValue());

    sendAttributeChangeNotification(myNtfyObj);

    if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
        MODELMBEAN_LOGGER.logp(Level.FINER,
                RequiredModelMBean.class.getName(),mth,
            "Exit");
    }

}
 
源代码20 项目: openjdk-jdk8u   文件: RequiredModelMBean.java
public void sendAttributeChangeNotification(Attribute inOldVal,
                                            Attribute inNewVal)
    throws MBeanException, RuntimeOperationsException {
    final String mth =
        "sendAttributeChangeNotification(Attribute, Attribute)";
    if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
        MODELMBEAN_LOGGER.logp(Level.FINER,
                RequiredModelMBean.class.getName(),mth,
            "Entry");
    }

    // do we really want to do this?
    if ((inOldVal == null) || (inNewVal == null))
        throw new RuntimeOperationsException(new
           IllegalArgumentException("Attribute object must not be null"),
           "Exception occurred trying to send " +
           "attribute change notification of a ModelMBean");


    if (!(inOldVal.getName().equals(inNewVal.getName())))
        throw new RuntimeOperationsException(new
            IllegalArgumentException("Attribute names are not the same"),
            "Exception occurred trying to send " +
            "attribute change notification of a ModelMBean");


    Object newVal = inNewVal.getValue();
    Object oldVal = inOldVal.getValue();
    String className = "unknown";
    if (newVal != null)
        className = newVal.getClass().getName();
    if (oldVal != null)
        className = oldVal.getClass().getName();

    AttributeChangeNotification myNtfyObj = new
        AttributeChangeNotification(this,
                                    1,
                                    ((new Date()).getTime()),
                                    "AttributeChangeDetected",
                                    inOldVal.getName(),
                                    className,
                                    inOldVal.getValue(),
                                    inNewVal.getValue());

    sendAttributeChangeNotification(myNtfyObj);

    if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
        MODELMBEAN_LOGGER.logp(Level.FINER,
                RequiredModelMBean.class.getName(),mth,
            "Exit");
    }

}
 
 方法所在类
 同类方法