Java 类javax.management.AttributeChangeNotification 实例源码

项目:tomcat7    文件:BaseModelMBean.java   
/**
 * Send an <code>AttributeChangeNotification</code> to all registered
 * listeners.
 *
 * @param notification The <code>AttributeChangeNotification</code>
 *  that will be passed
 *
 * @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
    (AttributeChangeNotification notification)
    throws MBeanException, RuntimeOperationsException {

    if (notification == null)
        throw new RuntimeOperationsException
            (new IllegalArgumentException("Notification is null"),
             "Notification is null");
    if (attributeBroadcaster == null)
        return; // This means there are no registered listeners
    if( log.isDebugEnabled() )
        log.debug( "AttributeChangeNotification " + notification );
    attributeBroadcaster.sendNotification(notification);

}
项目:tomcat7    文件: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);

}
项目:tomcat7    文件:BaseAttributeFilter.java   
/**
 * <p>Test whether notification enabled for this event.
 * Return true if:</p>
 * <ul>
 * <li>This is an attribute change notification</li>
 * <li>Either the set of accepted names is empty (implying that all
 *     attribute names are of interest) or the set of accepted names
 *     includes the name of the attribute in this notification</li>
 * </ul>
 */
@Override
public boolean isNotificationEnabled(Notification notification) {

    if (notification == null)
        return (false);
    if (!(notification instanceof AttributeChangeNotification))
        return (false);
    AttributeChangeNotification acn =
        (AttributeChangeNotification) notification;
    if (!AttributeChangeNotification.ATTRIBUTE_CHANGE.equals(acn.getType()))
        return (false);
    synchronized (names) {
        if (names.size() < 1)
            return (true);
        else
            return (names.contains(acn.getAttributeName()));
    }

}
项目:tomcat7    文件:TestSlowQueryReport.java   
@Override
public void handleNotification(Notification notification,
                               Object handback) {
    notificationCount.incrementAndGet();
    System.out.println("\nReceived notification:");
    System.out.println("\tClassName: " + notification.getClass().getName());
    System.out.println("\tSource: " + notification.getSource());
    System.out.println("\tType: " + notification.getType());
    System.out.println("\tMessage: " + notification.getMessage());
    if (notification instanceof AttributeChangeNotification) {
        AttributeChangeNotification acn =
            (AttributeChangeNotification) notification;
        System.out.println("\tAttributeName: " + acn.getAttributeName());
        System.out.println("\tAttributeType: " + acn.getAttributeType());
        System.out.println("\tNewValue: " + acn.getNewValue());
        System.out.println("\tOldValue: " + acn.getOldValue());
    }
}
项目:lams    文件:ModelMBeanNotificationPublisher.java   
/**
 * Send the supplied {@link Notification} using the wrapped
 * {@link ModelMBean} instance.
 * @param notification the {@link Notification} to be sent
 * @throws IllegalArgumentException if the supplied {@code notification} is {@code null}
 * @throws UnableToSendNotificationException if the supplied {@code notification} could not be sent
 */
@Override
public void sendNotification(Notification notification) {
    Assert.notNull(notification, "Notification must not be null");
    replaceNotificationSourceIfNecessary(notification);
    try {
        if (notification instanceof AttributeChangeNotification) {
            this.modelMBean.sendAttributeChangeNotification((AttributeChangeNotification) notification);
        }
        else {
            this.modelMBean.sendNotification(notification);
        }
    }
    catch (MBeanException ex) {
        throw new UnableToSendNotificationException("Unable to send notification [" + notification + "]", ex);
    }
}
项目:lams    文件:BaseModelMBean.java   
/**
 * Send an <code>AttributeChangeNotification</code> to all registered
 * listeners.
 *
 * @param notification The <code>AttributeChangeNotification</code>
 *  that will be passed
 *
 * @exception MBeanException if an object initializer throws an
 *  exception
 * @exception RuntimeOperationsException wraps IllegalArgumentException
 *  when the specified notification is <code>null</code> or invalid
 */
public void sendAttributeChangeNotification
    (AttributeChangeNotification notification)
    throws MBeanException, RuntimeOperationsException {

    if (notification == null)
        throw new RuntimeOperationsException
            (new IllegalArgumentException("Notification is null"),
             "Notification is null");
    if (attributeBroadcaster == null)
        return; // This means there are no registered listeners
    if( log.isDebugEnabled() )
        log.debug( "AttributeChangeNotification " + notification );
    attributeBroadcaster.sendNotification(notification);

}
项目:lams    文件: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
 */
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);

}
项目:lams    文件:BaseAttributeFilter.java   
/**
 * <p>Test whether notification enabled for this event.
 * Return true if:</p>
 * <ul>
 * <li>This is an attribute change notification</li>
 * <li>Either the set of accepted names is empty (implying that all
 *     attribute names are of interest) or the set of accepted names
 *     includes the name of the attribute in this notification</li>
 * </ul>
 */
public boolean isNotificationEnabled(Notification notification) {

    if (notification == null)
        return (false);
    if (!(notification instanceof AttributeChangeNotification))
        return (false);
    AttributeChangeNotification acn =
        (AttributeChangeNotification) notification;
    if (!AttributeChangeNotification.ATTRIBUTE_CHANGE.equals(acn.getType()))
        return (false);
    synchronized (names) {
        if (names.size() < 1)
            return (true);
        else
            return (names.contains(acn.getAttributeName()));
    }

}
项目:OpenJSharp    文件:CommunicatorServer.java   
/**
 * Returns an array of MBeanNotificationInfo objects describing
 * the notification types sent by this CommunicatorServer.
 * There is only one type of notifications sent by the CommunicatorServer:
 * it is <tt>{@link javax.management.AttributeChangeNotification}</tt>,
 * sent when the <tt>State</tt> attribute of this CommunicatorServer
 * changes.
 */
@Override
public MBeanNotificationInfo[] getNotificationInfo() {

    // Initialize notifInfos on first call to getNotificationInfo()
    //
    if (notifInfos == null) {
        notifInfos = new MBeanNotificationInfo[1];
        String[] notifTypes = {
            AttributeChangeNotification.ATTRIBUTE_CHANGE};
        notifInfos[0] = new MBeanNotificationInfo( notifTypes,
                 AttributeChangeNotification.class.getName(),
                 "Sent to notify that the value of the State attribute "+
                 "of this CommunicatorServer instance has changed.");
    }

    return notifInfos.clone();
}
项目:monarch    文件:MX4JModelMBean.java   
public void sendAttributeChangeNotification(Attribute oldAttribute, Attribute newAttribute)
    throws MBeanException, RuntimeOperationsException {
  if (oldAttribute == null || newAttribute == null)
    throw new RuntimeOperationsException(new IllegalArgumentException(
        LocalizedStrings.MX4JModelMBean_ATTRIBUTE_CANNOT_BE_NULL.toLocalizedString()));
  if (!oldAttribute.getName().equals(newAttribute.getName()))
    throw new RuntimeOperationsException(new IllegalArgumentException(
        LocalizedStrings.MX4JModelMBean_ATTRIBUTE_NAMES_CANNOT_BE_DIFFERENT.toLocalizedString()));

  // TODO: the source must be the object name of the MBean if the listener was registered through
  // MBeanServer
  Object oldValue = oldAttribute.getValue();
  AttributeChangeNotification n = new AttributeChangeNotification(this, 1,
      System.currentTimeMillis(), "Attribute value changed", oldAttribute.getName(),
      oldValue == null ? null : oldValue.getClass().getName(), oldValue, newAttribute.getValue());
  sendAttributeChangeNotification(n);
}
项目:monarch    文件:MX4JModelMBean.java   
public void sendAttributeChangeNotification(AttributeChangeNotification notification)
    throws MBeanException, RuntimeOperationsException {
  if (notification == null)
    throw new RuntimeOperationsException(new IllegalArgumentException(
        LocalizedStrings.MX4JModelMBean_NOTIFICATION_CANNOT_BE_NULL.toLocalizedString()));

  getAttributeChangeBroadcaster().sendNotification(notification);

  Logger modelMBeanLogger = getModelMBeanLogger(notification.getType());
  if (modelMBeanLogger != null)
    if (modelMBeanLogger.isEnabledFor(Logger.DEBUG))
      modelMBeanLogger.debug("ModelMBean log: " + new Date() + " - " + notification);

  Logger logger = getLogger();
  if (logger.isEnabledFor(Logger.DEBUG))
    logger.debug("Attribute change notification " + notification + " sent");
}
项目:apache-tomcat-7.0.73-with-comment    文件:BaseModelMBean.java   
/**
 * Send an <code>AttributeChangeNotification</code> to all registered
 * listeners.
 *
 * @param notification The <code>AttributeChangeNotification</code>
 *  that will be passed
 *
 * @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
    (AttributeChangeNotification notification)
    throws MBeanException, RuntimeOperationsException {

    if (notification == null)
        throw new RuntimeOperationsException
            (new IllegalArgumentException("Notification is null"),
             "Notification is null");
    if (attributeBroadcaster == null)
        return; // This means there are no registered listeners
    if( log.isDebugEnabled() )
        log.debug( "AttributeChangeNotification " + notification );
    attributeBroadcaster.sendNotification(notification);

}
项目:apache-tomcat-7.0.73-with-comment    文件: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);

}
项目:apache-tomcat-7.0.73-with-comment    文件:BaseAttributeFilter.java   
/**
 * <p>Test whether notification enabled for this event.
 * Return true if:</p>
 * <ul>
 * <li>This is an attribute change notification</li>
 * <li>Either the set of accepted names is empty (implying that all
 *     attribute names are of interest) or the set of accepted names
 *     includes the name of the attribute in this notification</li>
 * </ul>
 */
@Override
public boolean isNotificationEnabled(Notification notification) {

    if (notification == null)
        return (false);
    if (!(notification instanceof AttributeChangeNotification))
        return (false);
    AttributeChangeNotification acn =
        (AttributeChangeNotification) notification;
    if (!AttributeChangeNotification.ATTRIBUTE_CHANGE.equals(acn.getType()))
        return (false);
    synchronized (names) {
        if (names.size() < 1)
            return (true);
        else
            return (names.contains(acn.getAttributeName()));
    }

}
项目:apache-tomcat-7.0.73-with-comment    文件:TestSlowQueryReport.java   
@Override
public void handleNotification(Notification notification,
                               Object handback) {
    notificationCount.incrementAndGet();
    System.out.println("\nReceived notification:");
    System.out.println("\tClassName: " + notification.getClass().getName());
    System.out.println("\tSource: " + notification.getSource());
    System.out.println("\tType: " + notification.getType());
    System.out.println("\tMessage: " + notification.getMessage());
    if (notification instanceof AttributeChangeNotification) {
        AttributeChangeNotification acn =
            (AttributeChangeNotification) notification;
        System.out.println("\tAttributeName: " + acn.getAttributeName());
        System.out.println("\tAttributeType: " + acn.getAttributeType());
        System.out.println("\tNewValue: " + acn.getNewValue());
        System.out.println("\tOldValue: " + acn.getOldValue());
    }
}
项目:jdk8u-jdk    文件:ScanManager.java   
/**
 * Enqueue a state changed notification for the given states.
 **/
private void queueStateChangedNotification(
                long sequence,
                long time,
                ScanState old,
                ScanState current) {
    final AttributeChangeNotification n =
            new AttributeChangeNotification(SCAN_MANAGER_NAME,sequence,time,
            "ScanManager State changed to "+current,"State",
            ScanState.class.getName(),old.toString(),current.toString());
    // Queue the notification. We have created an unlimited queue, so
    // this method should always succeed.
    try {
        if (!pendingNotifs.offer(n,2,TimeUnit.SECONDS)) {
            LOG.fine("Can't queue Notification: "+n);
        }
    } catch (InterruptedException x) {
            LOG.fine("Can't queue Notification: "+x);
    }
}
项目:jdk8u-jdk    文件:CommunicatorServer.java   
/**
 * Returns an array of MBeanNotificationInfo objects describing
 * the notification types sent by this CommunicatorServer.
 * There is only one type of notifications sent by the CommunicatorServer:
 * it is <tt>{@link javax.management.AttributeChangeNotification}</tt>,
 * sent when the <tt>State</tt> attribute of this CommunicatorServer
 * changes.
 */
@Override
public MBeanNotificationInfo[] getNotificationInfo() {

    // Initialize notifInfos on first call to getNotificationInfo()
    //
    if (notifInfos == null) {
        notifInfos = new MBeanNotificationInfo[1];
        String[] notifTypes = {
            AttributeChangeNotification.ATTRIBUTE_CHANGE};
        notifInfos[0] = new MBeanNotificationInfo( notifTypes,
                 AttributeChangeNotification.class.getName(),
                 "Sent to notify that the value of the State attribute "+
                 "of this CommunicatorServer instance has changed.");
    }

    return notifInfos.clone();
}
项目:jdk8u-jdk    文件:SimpleStandard.java   
/**
 * Operation: reset to their initial values the "State" and "NbChanges"
 * attributes of the "SimpleStandard" standard MBean.
 */
public void reset() {
    checkSubject();
    AttributeChangeNotification acn =
        new AttributeChangeNotification(this,
                                        0,
                                        0,
                                        "NbChanges reset",
                                        "NbChanges",
                                        "Integer",
                                        new Integer(nbChanges),
                                        new Integer(0));
    state = "initial state";
    nbChanges = 0;
    nbResets++;
    sendNotification(acn);
}
项目:jdk8u-jdk    文件:SimpleStandard.java   
/**
 * Operation: reset to their initial values the "State" and "NbChanges"
 * attributes of the "SimpleStandard" standard MBean.
 */
public void reset() {
    checkSubject("reset");
    AttributeChangeNotification acn =
        new AttributeChangeNotification(this,
                                        0,
                                        0,
                                        "NbChanges reset",
                                        "NbChanges",
                                        "Integer",
                                        new Integer(nbChanges),
                                        new Integer(0));
    state = "initial state";
    nbChanges = 0;
    nbResets++;
    sendNotification(acn);
}
项目:jdk8u-jdk    文件:SimpleStandard.java   
/**
 * Operation: reset to their initial values the "State" and "NbChanges"
 * attributes of the "SimpleStandard" standard MBean.
 */
public void reset() {
    AttributeChangeNotification acn =
        new AttributeChangeNotification(this,
                                        0,
                                        0,
                                        "NbChanges reset",
                                        "NbChanges",
                                        "Integer",
                                        new Integer(nbChanges),
                                        new Integer(0));
    state = "initial state";
    nbChanges = 0;
    nbResets++;
    sendNotification(acn);
}
项目:openjdk-jdk10    文件:SimpleStandard.java   
/**
 * Operation: reset to their initial values the "State" and "NbChanges"
 * attributes of the "SimpleStandard" standard MBean.
 */
public void reset() {
    checkSubject();
    AttributeChangeNotification acn =
        new AttributeChangeNotification(this,
                                        0,
                                        0,
                                        "NbChanges reset",
                                        "NbChanges",
                                        "Integer",
                                        new Integer(nbChanges),
                                        new Integer(0));
    state = "initial state";
    nbChanges = 0;
    nbResets++;
    sendNotification(acn);
}
项目:openjdk-jdk10    文件:SimpleStandard.java   
/**
 * Operation: reset to their initial values the "State" and "NbChanges"
 * attributes of the "SimpleStandard" standard MBean.
 */
public void reset() {
    checkSubject("reset");
    AttributeChangeNotification acn =
        new AttributeChangeNotification(this,
                                        0,
                                        0,
                                        "NbChanges reset",
                                        "NbChanges",
                                        "Integer",
                                        new Integer(nbChanges),
                                        new Integer(0));
    state = "initial state";
    nbChanges = 0;
    nbResets++;
    sendNotification(acn);
}
项目:openjdk-jdk10    文件:SimpleStandard.java   
/**
 * Operation: reset to their initial values the "State" and "NbChanges"
 * attributes of the "SimpleStandard" standard MBean.
 */
public void reset() {
    AttributeChangeNotification acn =
        new AttributeChangeNotification(this,
                                        0,
                                        0,
                                        "NbChanges reset",
                                        "NbChanges",
                                        "Integer",
                                        new Integer(nbChanges),
                                        new Integer(0));
    state = "initial state";
    nbChanges = 0;
    nbResets++;
    sendNotification(acn);
}
项目:rocketmq-flink-plugin    文件:JMXNotificationClient.java   
@Override
public void handleNotification(Notification notification, Object handback) {
    echo("\n<notification>");
    echo("\t<currentDatetime>" + DATE_FORMAT.format(Calendar.getInstance().getTime()) + "</currentDatetime>");
    echo("\t<notificationTimestamp>" + notification.getTimeStamp() + "</notificationTimestamp>");
    echo("\t<notificationDatetime>" + DATE_FORMAT.format(new Date(notification.getTimeStamp())) + "</notificationDatetime>");
    echo("\t<configName>" + handback.toString() + "</configName>");
    echo("\t<className>" + notification.getClass().getName() + "</className>");
    echo("\t<source>" + notification.getSource() + "</source>");
    echo("\t<type>" + notification.getType() + "</type>");
    echo("\t<message>" + notification.getMessage() + "</message>");
    if (notification instanceof AttributeChangeNotification) {
        echo("\t<attributeChanges>");
        AttributeChangeNotification acn = (AttributeChangeNotification) notification;
        echo("\t\t<attributeName>" + acn.getAttributeName() + "</attributeName>");
        echo("\t\t<attributeType>" + acn.getAttributeType() + "</attributeType>");
        echo("\t\t<newValue>" + acn.getNewValue() + "</newValue>");
        echo("\t\t<oldValue>" + acn.getOldValue() + "</oldValue>");
        echo("\t</attributeChanges>");
    }
    echo("\n</notification>");
}
项目:lazycat    文件: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);

}
项目:lazycat    文件:BaseAttributeFilter.java   
/**
 * <p>
 * Test whether notification enabled for this event. Return true if:
 * </p>
 * <ul>
 * <li>This is an attribute change notification</li>
 * <li>Either the set of accepted names is empty (implying that all
 * attribute names are of interest) or the set of accepted names includes
 * the name of the attribute in this notification</li>
 * </ul>
 */
@Override
public boolean isNotificationEnabled(Notification notification) {

    if (notification == null)
        return (false);
    if (!(notification instanceof AttributeChangeNotification))
        return (false);
    AttributeChangeNotification acn = (AttributeChangeNotification) notification;
    if (!AttributeChangeNotification.ATTRIBUTE_CHANGE.equals(acn.getType()))
        return (false);
    synchronized (names) {
        if (names.size() < 1)
            return (true);
        else
            return (names.contains(acn.getAttributeName()));
    }

}
项目:openjdk9    文件:ScanManager.java   
/**
 * Enqueue a state changed notification for the given states.
 **/
private void queueStateChangedNotification(
                long sequence,
                long time,
                ScanState old,
                ScanState current) {
    final AttributeChangeNotification n =
            new AttributeChangeNotification(SCAN_MANAGER_NAME,sequence,time,
            "ScanManager State changed to "+current,"State",
            ScanState.class.getName(),old.toString(),current.toString());
    // Queue the notification. We have created an unlimited queue, so
    // this method should always succeed.
    try {
        if (!pendingNotifs.offer(n,2,TimeUnit.SECONDS)) {
            LOG.fine("Can't queue Notification: "+n);
        }
    } catch (InterruptedException x) {
            LOG.fine("Can't queue Notification: "+x);
    }
}
项目:openjdk9    文件:SimpleStandard.java   
/**
 * Operation: reset to their initial values the "State" and "NbChanges"
 * attributes of the "SimpleStandard" standard MBean.
 */
public void reset() {
    checkSubject();
    AttributeChangeNotification acn =
        new AttributeChangeNotification(this,
                                        0,
                                        0,
                                        "NbChanges reset",
                                        "NbChanges",
                                        "Integer",
                                        new Integer(nbChanges),
                                        new Integer(0));
    state = "initial state";
    nbChanges = 0;
    nbResets++;
    sendNotification(acn);
}
项目:openjdk9    文件:SimpleStandard.java   
/**
 * Operation: reset to their initial values the "State" and "NbChanges"
 * attributes of the "SimpleStandard" standard MBean.
 */
public void reset() {
    checkSubject("reset");
    AttributeChangeNotification acn =
        new AttributeChangeNotification(this,
                                        0,
                                        0,
                                        "NbChanges reset",
                                        "NbChanges",
                                        "Integer",
                                        new Integer(nbChanges),
                                        new Integer(0));
    state = "initial state";
    nbChanges = 0;
    nbResets++;
    sendNotification(acn);
}
项目:openjdk9    文件:SimpleStandard.java   
/**
 * Operation: reset to their initial values the "State" and "NbChanges"
 * attributes of the "SimpleStandard" standard MBean.
 */
public void reset() {
    AttributeChangeNotification acn =
        new AttributeChangeNotification(this,
                                        0,
                                        0,
                                        "NbChanges reset",
                                        "NbChanges",
                                        "Integer",
                                        new Integer(nbChanges),
                                        new Integer(0));
    state = "initial state";
    nbChanges = 0;
    nbResets++;
    sendNotification(acn);
}
项目:spring4-understanding    文件:ModelMBeanNotificationPublisher.java   
/**
 * Send the supplied {@link Notification} using the wrapped
 * {@link ModelMBean} instance.
 * @param notification the {@link Notification} to be sent
 * @throws IllegalArgumentException if the supplied {@code notification} is {@code null}
 * @throws UnableToSendNotificationException if the supplied {@code notification} could not be sent
 */
@Override
public void sendNotification(Notification notification) {
    Assert.notNull(notification, "Notification must not be null");
    replaceNotificationSourceIfNecessary(notification);
    try {
        if (notification instanceof AttributeChangeNotification) {
            this.modelMBean.sendAttributeChangeNotification((AttributeChangeNotification) notification);
        }
        else {
            this.modelMBean.sendNotification(notification);
        }
    }
    catch (MBeanException ex) {
        throw new UnableToSendNotificationException("Unable to send notification [" + notification + "]", ex);
    }
}
项目:spring4-understanding    文件:NotificationListenerTests.java   
@Override
public void handleNotification(Notification notification, Object handback) {
    if (notification instanceof AttributeChangeNotification) {
        AttributeChangeNotification attNotification = (AttributeChangeNotification) notification;
        String attributeName = attNotification.getAttributeName();

        Integer currentCount = (Integer) this.attributeCounts.get(attributeName);

        if (currentCount != null) {
            int count = currentCount.intValue() + 1;
            this.attributeCounts.put(attributeName, new Integer(count));
        } else {
            this.attributeCounts.put(attributeName, new Integer(1));
        }

        this.attributeHandbacks.put(attributeName, handback);
    }
}
项目:my-spring-cache-redis    文件:ModelMBeanNotificationPublisher.java   
/**
 * Send the supplied {@link Notification} using the wrapped
 * {@link ModelMBean} instance.
 * @param notification the {@link Notification} to be sent
 * @throws IllegalArgumentException if the supplied {@code notification} is {@code null}
 * @throws UnableToSendNotificationException if the supplied {@code notification} could not be sent
 */
@Override
public void sendNotification(Notification notification) {
    Assert.notNull(notification, "Notification must not be null");
    replaceNotificationSourceIfNecessary(notification);
    try {
        if (notification instanceof AttributeChangeNotification) {
            this.modelMBean.sendAttributeChangeNotification((AttributeChangeNotification) notification);
        }
        else {
            this.modelMBean.sendNotification(notification);
        }
    }
    catch (MBeanException ex) {
        throw new UnableToSendNotificationException("Unable to send notification [" + notification + "]", ex);
    }
}
项目:gemfirexd-oss    文件:MX4JModelMBean.java   
public void sendAttributeChangeNotification(Attribute oldAttribute, Attribute newAttribute) throws MBeanException, RuntimeOperationsException
{
   if (oldAttribute == null || newAttribute == null) throw new RuntimeOperationsException(new IllegalArgumentException(LocalizedStrings.MX4JModelMBean_ATTRIBUTE_CANNOT_BE_NULL.toLocalizedString()));
   if (!oldAttribute.getName().equals(newAttribute.getName())) throw new RuntimeOperationsException(new IllegalArgumentException(LocalizedStrings.MX4JModelMBean_ATTRIBUTE_NAMES_CANNOT_BE_DIFFERENT.toLocalizedString()));

   // TODO: the source must be the object name of the MBean if the listener was registered through MBeanServer
   Object oldValue = oldAttribute.getValue();
   AttributeChangeNotification n = new AttributeChangeNotification(this,
                                                                   1,
                                                                   System.currentTimeMillis(),
                                                                   "Attribute value changed",
                                                                   oldAttribute.getName(),
                                                                   oldValue == null ? null : oldValue.getClass().getName(),
                                                                   oldValue,
                                                                   newAttribute.getValue());
   sendAttributeChangeNotification(n);
}
项目:netvirt    文件:NvpnNbrControlPathAlarm.java   
@Override
public void raiseAlarm(String alarmName, String additionalText, String source, String detailsInfo) {
    if (alarmName == null || source == null || detailsInfo == null) {
        LOG.error("NvpnNbrControlPathAlarm.raiseAlarm has bad argument");
        return;
    }
    ArrayList<String> raiseAlarmObject = new ArrayList<>();
    raiseAlarmObject.add(alarmName);
    raiseAlarmObject.add(additionalText);
    raiseAlarmObject.add(source);
    raiseAlarmObject.add(detailsInfo);
    sendNotification(new AttributeChangeNotification(this,
        sequenceNumber.getAndIncrement(), System.currentTimeMillis(),
        NvpnJMXAlarmAgent.OP_RAISEALARM, "raiseAlarmObject", "List",
        "", raiseAlarmObject));
}
项目:netvirt    文件:NvpnNbrControlPathAlarm.java   
@Override
public void clearAlarm(String alarmName, String additionalText, String source, String detailsInfo) {
    if (alarmName == null || source == null || detailsInfo == null) {
        LOG.error("NvpnNbrControlPathAlarm.clearAlarm has bad argument");
        return;
    }
    ArrayList<String> clearAlarmObject = new ArrayList<>();
    clearAlarmObject.add(alarmName);
    clearAlarmObject.add(additionalText);
    clearAlarmObject.add(source);
    clearAlarmObject.add(detailsInfo);
    sendNotification(new AttributeChangeNotification(this,
            sequenceNumber.getAndIncrement(), System.currentTimeMillis(),
            NvpnJMXAlarmAgent.OP_CLEARALARM, "clearAlarmObject", "List",
            "", clearAlarmObject));
}
项目:jdk8u_jdk    文件:ScanManager.java   
/**
 * Enqueue a state changed notification for the given states.
 **/
private void queueStateChangedNotification(
                long sequence,
                long time,
                ScanState old,
                ScanState current) {
    final AttributeChangeNotification n =
            new AttributeChangeNotification(SCAN_MANAGER_NAME,sequence,time,
            "ScanManager State changed to "+current,"State",
            ScanState.class.getName(),old.toString(),current.toString());
    // Queue the notification. We have created an unlimited queue, so
    // this method should always succeed.
    try {
        if (!pendingNotifs.offer(n,2,TimeUnit.SECONDS)) {
            LOG.fine("Can't queue Notification: "+n);
        }
    } catch (InterruptedException x) {
            LOG.fine("Can't queue Notification: "+x);
    }
}
项目:jdk8u_jdk    文件:CommunicatorServer.java   
/**
 * Returns an array of MBeanNotificationInfo objects describing
 * the notification types sent by this CommunicatorServer.
 * There is only one type of notifications sent by the CommunicatorServer:
 * it is <tt>{@link javax.management.AttributeChangeNotification}</tt>,
 * sent when the <tt>State</tt> attribute of this CommunicatorServer
 * changes.
 */
@Override
public MBeanNotificationInfo[] getNotificationInfo() {

    // Initialize notifInfos on first call to getNotificationInfo()
    //
    if (notifInfos == null) {
        notifInfos = new MBeanNotificationInfo[1];
        String[] notifTypes = {
            AttributeChangeNotification.ATTRIBUTE_CHANGE};
        notifInfos[0] = new MBeanNotificationInfo( notifTypes,
                 AttributeChangeNotification.class.getName(),
                 "Sent to notify that the value of the State attribute "+
                 "of this CommunicatorServer instance has changed.");
    }

    return notifInfos.clone();
}
项目:jdk8u_jdk    文件:SimpleStandard.java   
/**
 * Operation: reset to their initial values the "State" and "NbChanges"
 * attributes of the "SimpleStandard" standard MBean.
 */
public void reset() {
    checkSubject();
    AttributeChangeNotification acn =
        new AttributeChangeNotification(this,
                                        0,
                                        0,
                                        "NbChanges reset",
                                        "NbChanges",
                                        "Integer",
                                        new Integer(nbChanges),
                                        new Integer(0));
    state = "initial state";
    nbChanges = 0;
    nbResets++;
    sendNotification(acn);
}
项目:jdk8u_jdk    文件:SimpleStandard.java   
/**
 * Operation: reset to their initial values the "State" and "NbChanges"
 * attributes of the "SimpleStandard" standard MBean.
 */
public void reset() {
    checkSubject("reset");
    AttributeChangeNotification acn =
        new AttributeChangeNotification(this,
                                        0,
                                        0,
                                        "NbChanges reset",
                                        "NbChanges",
                                        "Integer",
                                        new Integer(nbChanges),
                                        new Integer(0));
    state = "initial state";
    nbChanges = 0;
    nbResets++;
    sendNotification(acn);
}