use of javax.management.Notification in project jdk8u_jdk by JetBrains.
the class LoggingExceptionTest method main.
public static void main(String[] args) {
Handler handler = new ConsoleHandler();
Logger logger = Logger.getLogger("javax.management.modelmbean");
logger.addHandler(handler);
logger.setLevel(Level.FINEST);
try {
for (int i = 0; i < tests.length; i++) {
System.out.println(">>> DescriptorSupportLoggingTest: Test Case " + i);
DescriptorSupport ds;
String msg = "Instantiate " + tests[i];
System.out.println(msg);
switch(i) {
case 0:
ds = new DescriptorSupport();
break;
case 1:
ds = new DescriptorSupport(10);
break;
case 2:
ds = new DescriptorSupport(new DescriptorSupport().toXMLString());
break;
case 3:
ds = new DescriptorSupport("name1=value1", "name2=value2");
break;
case 4:
ds = new DescriptorSupport(new String[] { "name" }, new Object[] { "value" });
break;
case 5:
ds = new DescriptorSupport(new DescriptorSupport());
break;
case 6:
RequiredModelMBean mbean = new RequiredModelMBean();
NotificationListener nl = new NotificationListener() {
public void handleNotification(Notification notification, Object handback) {
}
};
mbean.addAttributeChangeNotificationListener(nl, null, null);
break;
default:
throw new AssertionError();
}
System.out.println(msg + " OK");
}
} catch (Exception e) {
System.out.println("Got unexpected exception = " + e);
String msg = "Test FAILED!";
System.out.println(msg);
throw new IllegalArgumentException(msg);
}
System.out.println("Test PASSED!");
}
use of javax.management.Notification in project jdk8u_jdk by JetBrains.
the class Basic method sendNotification.
/**
* Send one Notification of the provided notifType type.
*/
public void sendNotification(String notifType) {
Notification notification = null;
if (notifType.equals(NOTIF_TYPE_0)) {
notification = new Notification(NOTIF_TYPE_0, mbeanName, seqNumber, NOTIFICATION_MESSAGE);
} else if (notifType.equals(NOTIF_TYPE_1)) {
notification = new SqeNotification(NOTIF_TYPE_1, mbeanName, seqNumber, NOTIFICATION_MESSAGE);
}
seqNumber++;
broadcaster.sendNotification(notification);
}
use of javax.management.Notification in project geode by apache.
the class SystemMemberJmxImpl method handleRegionCreate.
/**
* Implementation handles creation of region by extracting the details from the given event object
* and sending the {@link SystemMemberJmx#NOTIF_REGION_CREATED} notification to the connected JMX
* Clients. Region Path is set as User Data in Notification.
*
* @param event event object corresponding to the creation of a region
*/
public void handleRegionCreate(SystemMemberRegionEvent event) {
Notification notification = new Notification(NOTIF_REGION_CREATED, this.modelMBean, Helper.getNextNotificationSequenceNumber(), Helper.getRegionEventDetails(event));
notification.setUserData(event.getRegionPath());
Helper.sendNotification(this, notification);
}
use of javax.management.Notification in project geode by apache.
the class SystemMemberJmxImpl method handleClientMembership.
/**
* Implementation handles client membership changes.
*
* @param clientId id of the client for whom membership change happened
* @param eventType membership change type; one of {@link ClientMembershipMessage#JOINED},
* {@link ClientMembershipMessage#LEFT}, {@link ClientMembershipMessage#CRASHED}
*/
public void handleClientMembership(String clientId, int eventType) {
String notifType = null;
List<ManagedResource> cleanedUp = null;
if (eventType == ClientMembershipMessage.LEFT) {
notifType = NOTIF_CLIENT_LEFT;
cleanedUp = cleanupBridgeClientResources(clientId);
} else if (eventType == ClientMembershipMessage.CRASHED) {
notifType = NOTIF_CLIENT_CRASHED;
cleanedUp = cleanupBridgeClientResources(clientId);
} else if (eventType == ClientMembershipMessage.JOINED) {
notifType = NOTIF_CLIENT_JOINED;
}
if (cleanedUp != null) {
for (ManagedResource resource : cleanedUp) {
MBeanUtil.unregisterMBean(resource);
}
}
Helper.sendNotification(this, new Notification(notifType, this.modelMBean, Helper.getNextNotificationSequenceNumber(), clientId));
}
use of javax.management.Notification in project geode by apache.
the class SystemMemberJmxImpl method handleRegionLoss.
/**
* Implementation should handle loss of region by extracting the details from the given event
* object and sending the {@link SystemMemberJmx#NOTIF_REGION_LOST} notification to the connected
* JMX Clients. Region Path is set as User Data in Notification. Additionally, it also clears the
* ManagedResources created for the region that is lost.
*
* @param event event object corresponding to the loss of a region
*/
public void handleRegionLoss(SystemMemberRegionEvent event) {
SystemMemberCacheJmxImpl cacheResource = this.managedSystemMemberCache;
if (cacheResource != null) {
ManagedResource cleanedUp = cacheResource.cleanupRegionResources(event.getRegionPath());
if (cleanedUp != null) {
MBeanUtil.unregisterMBean(cleanedUp);
}
}
Notification notification = new Notification(NOTIF_REGION_LOST, this.modelMBean, Helper.getNextNotificationSequenceNumber(), Helper.getRegionEventDetails(event));
notification.setUserData(event.getRegionPath());
Helper.sendNotification(this, notification);
}
Aggregations