[Jboss-cvs] JBossAS SVN: r56232 - trunk/cluster/src/main/org/jboss/ha/jmx
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Aug 24 17:03:53 EDT 2006
Author: bstansberry at jboss.com
Date: 2006-08-24 17:03:53 -0400 (Thu, 24 Aug 2006)
New Revision: 56232
Modified:
trunk/cluster/src/main/org/jboss/ha/jmx/HAServiceMBeanSupport.java
Log:
[JBAS-3194] Add ability to suppress lifecycle notifications
Modified: trunk/cluster/src/main/org/jboss/ha/jmx/HAServiceMBeanSupport.java
===================================================================
--- trunk/cluster/src/main/org/jboss/ha/jmx/HAServiceMBeanSupport.java 2006-08-24 21:03:13 UTC (rev 56231)
+++ trunk/cluster/src/main/org/jboss/ha/jmx/HAServiceMBeanSupport.java 2006-08-24 21:03:53 UTC (rev 56232)
@@ -25,6 +25,7 @@
import java.util.List;
import java.util.Set;
+import javax.management.AttributeChangeNotification;
import javax.management.InstanceNotFoundException;
import javax.management.Notification;
import javax.management.ObjectInstance;
@@ -77,6 +78,9 @@
*/
private String REPLICANT_TOKEN = "";
+ private boolean sendLocalLifecycleNotifications = true;
+ private boolean sendRemoteLifecycleNotifications = true;
+
// Public --------------------------------------------------------
public HAServiceMBeanSupport()
@@ -308,9 +312,69 @@
true);
}
+ /**
+ * Gets whether JMX Notifications should be sent to local (same JVM) listeners
+ * if the notification is for an attribute change to attribute "State".
+ * <p>
+ * Default is <code>true</code>.
+ * </p>
+ * @see #sendNotification(Notification)
+ */
+ public boolean getSendLocalLifecycleNotifications()
+ {
+ return sendLocalLifecycleNotifications;
+ }
/**
+ * Sets whether JMX Notifications should be sent to local (same JVM) listeners
+ * if the notification is for an attribute change to attribute "State".
+ * <p>
+ * Default is <code>true</code>.
+ * </p>
+ * @see #sendNotification(Notification)
+ */
+ public void setSendLocalLifecycleNotifications(boolean sendLocalLifecycleNotifications)
+ {
+ this.sendLocalLifecycleNotifications = sendLocalLifecycleNotifications;
+ }
+
+ /**
+ * Gets whether JMX Notifications should be sent to remote listeners
+ * if the notification is for an attribute change to attribute "State".
+ * <p>
+ * Default is <code>true</code>.
+ * </p>
+ * <p>
+ * See http://jira.jboss.com/jira/browse/JBAS-3194 for an example of a
+ * use case where this property should be set to false.
+ * </p>
*
+ * @see #sendNotification(Notification)
+ */
+ public boolean getSendRemoteLifecycleNotifications()
+ {
+ return sendRemoteLifecycleNotifications;
+ }
+
+ /**
+ * Sets whether JMX Notifications should be sent to remote listeners
+ * if the notification is for an attribute change to attribute "State".
+ * <p>
+ * Default is <code>true</code>.
+ * </p>
+ * <p>
+ * See http://jira.jboss.com/jira/browse/JBAS-3194 for an example of a
+ * use case where this property should be set to false.
+ * </p>
+ *
+ * @see #sendNotification(Notification)
+ */
+ public void setSendRemoteLifecycleNotifications(boolean sendRemoteLifecycleNotifications)
+ {
+ this.sendRemoteLifecycleNotifications = sendRemoteLifecycleNotifications;
+ }
+
+ /**
* Broadcast the notification to the remote listener nodes (if any) and then
* invoke super.sendNotification() to notify local listeners.
*
@@ -318,29 +382,49 @@
* It is recommended that the source of the notification is an ObjectName of an MBean that
* is is available on all nodes where the broadcaster MBean is registered.
*
- *
+ * @see #getSendLocalLifecycleNotifications()
+ * @see #getSendRemoteLifecycleNotifications()
* @see javax.management.NotificationBroadcasterSupport#sendNotification(Notification)
- *
*/
public void sendNotification(Notification notification)
{
- try
+ boolean stateChange = isStateChangeNotification(notification);
+
+ if (!stateChange || sendRemoteLifecycleNotifications)
{
- // Overriding the source MBean with its ObjectName
- // to ensure that it can be safely transferred over the wire
- notification.setSource(this.getServiceName());
- sendNotificationRemote(notification);
+ try
+ {
+ // Overriding the source MBean with its ObjectName
+ // to ensure that it can be safely transferred over the wire
+ notification.setSource(this.getServiceName());
+ sendNotificationRemote(notification);
+ }
+
+ catch (Throwable th)
+ {
+ boolean debug = log.isDebugEnabled();
+ if (debug)
+ log.debug("sendNotificationRemote( " + notification + " ) failed ", th);
+ // even if broadcast failed, local notification should still be sent
+
+ }
}
-
- catch (Throwable th)
+
+ if (!stateChange || sendLocalLifecycleNotifications)
{
- if (log.isDebugEnabled())
- log.debug("sendNotificationRemote( " + notification + " ) failed ", th);
- // even if broadcast failed, local notification should still be sent
-
+ sendNotificationToLocalListeners(notification);
}
- sendNotificationToLocalListeners(notification);
}
+
+ private boolean isStateChangeNotification(Notification notification)
+ {
+ boolean stateChange = false;
+ if (notification instanceof AttributeChangeNotification)
+ {
+ stateChange = "State".equals(((AttributeChangeNotification) notification).getAttributeName());
+ }
+ return stateChange;
+ }
protected void sendNotificationToLocalListeners(Notification notification)
{
More information about the jboss-cvs-commits
mailing list