use of javax.management.AttributeChangeNotification in project wildfly by wildfly.
the class ServiceMBeanSupport method sendStateChangeNotification.
/**
* Helper for sending out state change notifications
*/
private void sendStateChangeNotification(int oldState, int newState, String msg, Throwable t) {
long now = System.currentTimeMillis();
AttributeChangeNotification stateChangeNotification = new AttributeChangeNotification(this, getNextNotificationSequenceNumber(), now, msg, "State", "java.lang.Integer", new Integer(oldState), new Integer(newState));
stateChangeNotification.setUserData(t);
sendNotification(stateChangeNotification);
}
use of javax.management.AttributeChangeNotification in project wildfly by wildfly.
the class TestResultService method handleNotification.
@Override
public void handleNotification(Notification notification, Object handback) {
if (notification instanceof AttributeChangeNotification) {
AttributeChangeNotification attributeChangeNotification = (AttributeChangeNotification) notification;
int oldValue = (Integer) attributeChangeNotification.getOldValue();
int newValue = (Integer) attributeChangeNotification.getNewValue();
logger.trace("Attribute change notification: " + oldValue + "->" + newValue);
if (oldValue == STOPPED && newValue == STARTING) {
startingNotificationReceived = true;
} else if (oldValue == STARTING && newValue == STARTED) {
startedNotificationReceived = true;
} else if (oldValue == STARTED && newValue == STOPPING) {
stoppingNotificationReceived = true;
} else if (oldValue == STOPPING && newValue == STOPPED) {
stoppedNotificationReceived = true;
}
}
}
use of javax.management.AttributeChangeNotification in project jdk8u_jdk by JetBrains.
the class RequiredModelMBean method sendAttributeChangeNotification.
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");
}
}
use of javax.management.AttributeChangeNotification in project camel by apache.
the class SimpleBean method tick.
public void tick() throws Exception {
tick++;
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-dd-MM'T'HH:mm:ss");
Date date = sdf.parse("2010-07-01T10:30:15");
long timeStamp = date.getTime();
AttributeChangeNotification acn = new AttributeChangeNotification(this, sequence++, timeStamp, "attribute changed", "stringValue", "string", tick - 1, tick);
sendNotification(acn);
}
use of javax.management.AttributeChangeNotification in project tomcat by apache.
the class BaseModelMBean method sendAttributeChangeNotification.
/**
* 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
// Old and new are both null == no change
return;
AttributeChangeNotification notification = new AttributeChangeNotification(this, 1, System.currentTimeMillis(), "Attribute value has changed", oldValue.getName(), type, oldValue.getValue(), newValue.getValue());
sendAttributeChangeNotification(notification);
}
Aggregations