use of javax.management.Notification in project felix by apache.
the class DynamicMBeanImpl method sendNotification.
/**
* Sends a notification to a subscriber.
*
* @param msg the msg to send
* @param attributeName the name of the attribute
* @param attributeType the type of the attribute
* @param oldValue the old value of the attribute
* @param newValue the new value of the attribute
*/
public void sendNotification(String msg, String attributeName, String attributeType, Object oldValue, Object newValue) {
long timeStamp = System.currentTimeMillis();
if ((newValue == null && oldValue == null) || (newValue != null && newValue.equals(oldValue))) {
return;
}
m_sequenceNumber++;
Notification notification = new AttributeChangeNotification(this, m_sequenceNumber, timeStamp, msg, attributeName, attributeType, oldValue, newValue);
sendNotification(notification);
m_instanceManager.getFactory().getLogger().log(Logger.INFO, "Notification sent");
}
use of javax.management.Notification in project felix by apache.
the class RemoteNotificationClientHandler method sendNotification.
private void sendNotification(TargetedNotification notification) {
NotificationTuple tuple = null;
synchronized (tuples) {
tuple = (NotificationTuple) tuples.get(notification.getListenerID());
}
// It may be possible that a notification arrived after the client already removed the listener
if (tuple == null)
return;
Notification notif = notification.getNotification();
if (tuple.getInvokeFilter()) {
// Invoke the filter on client side
NotificationFilter filter = tuple.getNotificationFilter();
RmiConnectorActivator.log(LogService.LOG_DEBUG, "Filtering notification " + notif + ", filter = " + filter, null);
if (filter != null) {
try {
boolean deliver = filter.isNotificationEnabled(notif);
if (!deliver)
return;
} catch (RuntimeException x) {
RmiConnectorActivator.log(LogService.LOG_WARNING, "RuntimeException caught from isNotificationEnabled, filter = " + filter, x);
// And go on quietly
}
}
}
RmiConnectorActivator.log(LogService.LOG_DEBUG, "Sending Notification " + notif + ", listener info is " + tuple, null);
NotificationListener listener = tuple.getNotificationListener();
try {
listener.handleNotification(notif, tuple.getHandback());
} catch (RuntimeException x) {
RmiConnectorActivator.log(LogService.LOG_WARNING, "RuntimeException caught from handleNotification, listener = " + listener, x);
// And return quietly
}
}
use of javax.management.Notification in project felix by apache.
the class UserManager method notifyUserAdminEvent.
// ///////PRIVATE METHODS//////////////////////////
private void notifyUserAdminEvent(UserAdminEvent event) {
String typedesc = null;
switch(event.getType()) {
case UserAdminEvent.ROLE_CREATED:
typedesc = "created";
break;
case UserAdminEvent.ROLE_CHANGED:
typedesc = "changed";
break;
case UserAdminEvent.ROLE_REMOVED:
typedesc = "removed";
break;
}
try {
ObjectName source = new ObjectName(ObjectNames.UA_SERVICE);
String message = "User Admin event: Role " + event.getRole().getName() + typedesc;
Notification notification = new Notification(AgentConstants.USER_ADMIN_NOTIFICATION_TYPE, source, sequenceNumber++, message);
CompositeData userData = OSGi2JMXCodec.encodeUserAdminEvent(event);
notification.setUserData(userData);
sendNotification(notification);
} catch (Exception e) {
ac.error("Unexpected exception", e);
}
}
use of javax.management.Notification in project jdk8u_jdk by JetBrains.
the class ResultLogManager method clearMemoryLog.
// Clear the memory log, sends a notification indicating that
// the memory log was cleared.
//
private void clearMemoryLog() throws IOException {
synchronized (this) {
memoryLog.clear();
memCapacityReached = false;
}
sendNotification(new Notification(MEMORY_LOG_CLEARED, objectName, getNextSeqNumber(), "memory log cleared"));
}
use of javax.management.Notification in project jdk8u_jdk by JetBrains.
the class ServerNotifForwarder method snoopOnUnregister.
// The standard RMI connector client will register a listener on the MBeanServerDelegate
// in order to be told when MBeans are unregistered. We snoop on fetched notifications
// so that we can know too, and remove the corresponding entry from the listenerMap.
// See 6957378.
private void snoopOnUnregister(NotificationResult nr) {
List<IdAndFilter> copy = null;
synchronized (listenerMap) {
Set<IdAndFilter> delegateSet = listenerMap.get(MBeanServerDelegate.DELEGATE_NAME);
if (delegateSet == null || delegateSet.isEmpty()) {
return;
}
copy = new ArrayList<>(delegateSet);
}
for (TargetedNotification tn : nr.getTargetedNotifications()) {
Integer id = tn.getListenerID();
for (IdAndFilter idaf : copy) {
if (idaf.id == id) {
// This is a notification from the MBeanServerDelegate.
Notification n = tn.getNotification();
if (n instanceof MBeanServerNotification && n.getType().equals(MBeanServerNotification.UNREGISTRATION_NOTIFICATION)) {
MBeanServerNotification mbsn = (MBeanServerNotification) n;
ObjectName gone = mbsn.getMBeanName();
synchronized (listenerMap) {
listenerMap.remove(gone);
}
}
}
}
}
}
Aggregations