Example usage for javax.management AttributeChangeNotification AttributeChangeNotification

List of usage examples for javax.management AttributeChangeNotification AttributeChangeNotification

Introduction

In this page you can find the example usage for javax.management AttributeChangeNotification AttributeChangeNotification.

Prototype

public AttributeChangeNotification(Object source, long sequenceNumber, long timeStamp, String msg,
        String attributeName, String attributeType, Object oldValue, Object newValue) 

Source Link

Document

Constructs an attribute change notification object.

Usage

From source file:com.cisco.oss.foundation.monitoring.ServerInfo.java

/**
 * Sends a notification to registered clients about the change in value of
 * an attribute./*from   w  w  w  .j  a v a2  s .  c om*/
 *
 * @param msg           A String containing the message of the notification.
 * @param attributeName A String giving the name of the attribute.
 * @param attributeType A String containing the type of the attribute.
 * @param oldValue      An object representing value of the attribute before the
 *                      change.
 * @param newValue      An object representing value of the attribute after the
 *                      change.
 */
@Override
public void sendAttributeChangeNotification(String msg, String attributeName, String attributeType,
        Object oldValue, Object newValue) {
    LOGGER.debug("Sending Notification " + (attrNotificationSeq + 1) + ":" + msg + ":" + attributeName + ":"
            + attributeType + ":" + oldValue.toString() + ":" + newValue.toString());

    Notification n = new AttributeChangeNotification(this, attrNotificationSeq++, System.currentTimeMillis(),
            msg, attributeName, attributeType, oldValue, newValue);
    sendNotification(n);
    LOGGER.debug("Notification Sent " + attrNotificationSeq);
}

From source file:com.example.Hello.java

public synchronized void setCacheSize(int size) {
    int oldSize = this.cacheSize;
    this.cacheSize = size;

    /* In a real application, changing the attribute would
       typically have effects beyond just modifying the cacheSize
       field.  For example, resizing the cache might mean
       discarding entries or allocating new ones. The logic for
       these effects would be here. */
    System.out.println("Cache size now " + this.cacheSize);

    /* Construct a notification that describes the change. The
       "source" of a notification is the ObjectName of the MBean
       that emitted it. But an MBean can put a reference to
       itself ("this") in the source, and the MBean server will
       replace this with the ObjectName before sending the
       notification on to its clients./*from   w  w  w .  j a v  a 2  s  .  com*/
            
       For good measure, we maintain a sequence number for each
       notification emitted by this MBean.
            
       The oldValue and newValue parameters to the constructor are
       of type Object, so we are relying on Tiger's autoboxing
       here.  */
    Notification n = new AttributeChangeNotification(this, sequenceNumber++, System.currentTimeMillis(),
            "CacheSize changed", "CacheSize", "int", oldSize, this.cacheSize);

    /* Now send the notification using the sendNotification method
       inherited from the parent class NotificationBroadcasterSupport. */
    sendNotification(n);
}

From source file:co.paralleluniverse.common.monitoring.PeriodicMonitor.java

public void refresh() {
    collectAndResetCounters1();/*from   w  w  w.  j  a v a  2s  .c  o m*/
    //Notification n = new AttributeChangeNotification(this, notificationSequenceNumber++, System.currentTimeMillis(), "CacheInfo changed", "PerfInfo", newValue.getClass().getName(), null, newValue);
    Notification n = new AttributeChangeNotification(this, notificationSequenceNumber++,
            System.currentTimeMillis(), "Info changed", "", null, null, null);
    sendNotification(n);
}

From source file:org.helios.jzab.agent.net.active.ActiveHost.java

/**
 * Updates the state of this active host, sending a JMX attribute change notification if this is really a valid state change
 * @param state The new state//from  w w  w.jav  a2s.c  om
 */
protected void setState(ActiveHostState state) {
    if (state == null)
        throw new IllegalArgumentException("The passed ActiveHostState was null", new Throwable());
    ActiveHostState priorState = this.state.getAndSet(state);
    if (priorState != state) {
        this.stateTimestamp = SystemClock.currentTimeMillis();
        sendNotification(new AttributeChangeNotification(objectName, notificationSequence.incrementAndGet(),
                this.stateTimestamp, String.format("State change from [%s] to [%s]", priorState, state),
                "State", ActiveHostState.class.getName(), priorState.name(), state.name()));
    }
}

From source file:org.marketcetera.strategy.StrategyModule.java

@Override
public void statusChanged(Status inOldStatus, Status inNewStatus) {
    notificationDelegate//from   w  ww .j a  v a  2  s  .  co m
            .sendNotification(new AttributeChangeNotification(this, jmxNotificationCounter.getAndIncrement(),
                    System.currentTimeMillis(), STATUS_CHANGED.getText(), "Status", //$NON-NLS-1$
                    "String", //$NON-NLS-1$
                    inOldStatus, inNewStatus));
}

From source file:com.heliosapm.script.AbstractDeployedScript.java

/**
 * Sends a status change notification/*from ww  w . jav a2 s  .c  o  m*/
 * @param prior The prior status
 * @param current The current status
 * @param timestamp The timestamp
 */
protected void sendStatusChangeNotification(final DeploymentStatus prior, final DeploymentStatus current,
        final long timestamp) {
    final String msg = String.format("[%s] Status change for [%s]: from[%s] to [%s]", new Date(timestamp),
            objectName, prior, current);
    // last event msg
    sendNotification(new AttributeChangeNotification(objectName, sequence.incrementAndGet(), timestamp, msg,
            "Status", DeploymentStatus.class.getName(), prior.name(), current.name()));
}