Java Code Examples for javax.management.Attribute#getValue()

The following examples show how to use javax.management.Attribute#getValue() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BaseModelMBean.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
/**
 * 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);

}
 
Example 2
Source File: ContextResourceLinkMBean.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
/**
 * 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);
}
 
Example 3
Source File: MBeanSupport.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
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());
}
 
Example 4
Source File: JmxMBeanServer.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
/**
 * 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;
}
 
Example 5
Source File: MBeanSupport.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
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());
}
 
Example 6
Source File: JmxMBeanServer.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example 7
Source File: JmxMBeanServer.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example 8
Source File: MBeanSupport.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
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());
}
 
Example 9
Source File: MBeanSupport.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
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());
}
 
Example 10
Source File: MBeanSupport.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
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());
}
 
Example 11
Source File: JmxMBeanServer.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example 12
Source File: XMBeanAttributes.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
private boolean isViewable(Attribute attribute) {
    Object data = attribute.getValue();
    return XDataViewer.isViewableValue(data);

}
 
Example 13
Source File: XMBeanAttributes.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
private boolean isViewable(Attribute attribute) {
    Object data = attribute.getValue();
    return XDataViewer.isViewableValue(data);

}
 
Example 14
Source File: XMBeanAttributes.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
private boolean isViewable(Attribute attribute) {
    Object data = attribute.getValue();
    return XDataViewer.isViewableValue(data);

}
 
Example 15
Source File: RequiredModelMBean.java    From jdk1.8-source-analysis with Apache License 2.0 4 votes vote down vote up
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");
    }

}
 
Example 16
Source File: RequiredModelMBean.java    From JDKSourceCode1.8 with MIT License 4 votes vote down vote up
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");
    }

}
 
Example 17
Source File: RequiredModelMBean.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
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");
    }

}
 
Example 18
Source File: RequiredModelMBean.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
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");
    }

}
 
Example 19
Source File: ContextResourceMBean.java    From Tomcat8-Source-Read with MIT License 4 votes vote down vote up
/**
 * 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);
}
 
Example 20
Source File: RequiredModelMBean.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
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");
    }

}