[jboss-cvs] JBoss Messaging SVN: r4688 - in branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging: jms/server/management/impl and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Jul 17 10:42:01 EDT 2008
Author: jmesnil
Date: 2008-07-17 10:42:00 -0400 (Thu, 17 Jul 2008)
New Revision: 4688
Modified:
branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/core/management/impl/MessagingServerControl.java
branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/jms/server/management/impl/JMSServerControl.java
Log:
JBMESSAGING-1303: Revisit management interfaces
* emit JMX Notifications for queue/topic created/destroyed events
Modified: branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/core/management/impl/MessagingServerControl.java
===================================================================
--- branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/core/management/impl/MessagingServerControl.java 2008-07-17 13:54:23 UTC (rev 4687)
+++ branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/core/management/impl/MessagingServerControl.java 2008-07-17 14:42:00 UTC (rev 4688)
@@ -41,8 +41,6 @@
import org.jboss.messaging.core.management.MessagingServerControlMBean;
import org.jboss.messaging.core.management.MessagingServerManagement;
import org.jboss.messaging.core.management.NotificationType;
-import org.jboss.messaging.core.management.Operation;
-import org.jboss.messaging.core.management.Parameter;
import org.jboss.messaging.core.management.RoleInfo;
import org.jboss.messaging.core.security.CheckType;
import org.jboss.messaging.core.security.Role;
@@ -98,6 +96,7 @@
* overrides getMBeanInfo to add operations info using annotations
*
* @see Operation
+ *
* @see Parameter
*/
@Override
@@ -117,7 +116,7 @@
{
return server.getVersion();
}
-
+
public int getServerID()
{
return configuration.getServerID();
@@ -344,7 +343,8 @@
public MBeanNotificationInfo[] getNotificationInfo()
{
- return broadcaster.getNotificationInfo();
+ return MBeanInfoHelper
+ .getMBeanNotificationsInfo(MessagingServerControlMBean.class);
}
// Package protected ---------------------------------------------
Modified: branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/jms/server/management/impl/JMSServerControl.java
===================================================================
--- branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/jms/server/management/impl/JMSServerControl.java 2008-07-17 13:54:23 UTC (rev 4687)
+++ branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/jms/server/management/impl/JMSServerControl.java 2008-07-17 14:42:00 UTC (rev 4688)
@@ -23,9 +23,17 @@
package org.jboss.messaging.jms.server.management.impl;
import java.util.List;
+import java.util.concurrent.atomic.AtomicLong;
+import javax.management.ListenerNotFoundException;
import javax.management.MBeanInfo;
+import javax.management.MBeanNotificationInfo;
import javax.management.NotCompliantMBeanException;
+import javax.management.Notification;
+import javax.management.NotificationBroadcasterSupport;
+import javax.management.NotificationEmitter;
+import javax.management.NotificationFilter;
+import javax.management.NotificationListener;
import javax.management.StandardMBean;
import org.jboss.messaging.core.management.impl.MBeanInfoHelper;
@@ -39,7 +47,7 @@
*
*/
public class JMSServerControl extends StandardMBean implements
- JMSServerControlMBean
+ JMSServerControlMBean, NotificationEmitter
{
// Constants -----------------------------------------------------
@@ -47,6 +55,8 @@
// Attributes ----------------------------------------------------
private final JMSServerManager server;
+ private NotificationBroadcasterSupport broadcaster;
+ private AtomicLong notifSeq = new AtomicLong(0);
// Static --------------------------------------------------------
@@ -57,6 +67,7 @@
{
super(JMSServerControlMBean.class);
this.server = server;
+ broadcaster = new NotificationBroadcasterSupport();
}
// Public --------------------------------------------------------
@@ -85,36 +96,89 @@
public boolean createQueue(String name, String jndiBinding) throws Exception
{
- return server.createQueue(name, jndiBinding);
+ boolean created = server.createQueue(name, jndiBinding);
+ if (created)
+ {
+ sendNotification(NotificationType.QUEUE_CREATED, name);
+ }
+ return created;
}
public boolean destroyQueue(String name) throws Exception
{
- return server.destroyQueue(name);
+ boolean destroyed = server.destroyQueue(name);
+ if (destroyed)
+ {
+ sendNotification(NotificationType.QUEUE_DESTROYED, name);
+ }
+ return destroyed;
}
public boolean createTopic(String topicName, String jndiBinding)
throws Exception
{
- return server.createTopic(topicName, jndiBinding);
+ boolean created = server.createTopic(topicName, jndiBinding);
+ if (created)
+ {
+ sendNotification(NotificationType.TOPIC_CREATED, topicName);
+ }
+ return created;
}
+ public boolean destroyTopic(String name) throws Exception
+ {
+ boolean destroyed = server.destroyTopic(name);
+ if (destroyed)
+ {
+ sendNotification(NotificationType.TOPIC_DESTROYED, name);
+ }
+ return destroyed;
+ }
+
public void destroyConnectionFactory(String name) throws Exception
{
// TODO Auto-generated method stub
}
+ public boolean isStarted()
+ {
+ return server.isStarted();
+ }
- public boolean destroyTopic(String name) throws Exception
+ // NotificationEmitter implementation ----------------------------
+
+ public void removeNotificationListener(NotificationListener listener,
+ NotificationFilter filter, Object handback)
+ throws ListenerNotFoundException
{
- return server.destroyTopic(name);
+ broadcaster.removeNotificationListener(listener, filter, handback);
}
- public boolean isStarted()
+ public void removeNotificationListener(NotificationListener listener)
+ throws ListenerNotFoundException
{
- return server.isStarted();
+ broadcaster.removeNotificationListener(listener);
}
+ public void addNotificationListener(NotificationListener listener,
+ NotificationFilter filter, Object handback)
+ throws IllegalArgumentException
+ {
+ broadcaster.addNotificationListener(listener, filter, handback);
+ }
+
+ public MBeanNotificationInfo[] getNotificationInfo()
+ {
+ NotificationType[] values = NotificationType.values();
+ String[] names = new String[values.length];
+ for (int i = 0; i < values.length; i++)
+ {
+ names[i] = values[i].toString();
+ }
+ return new MBeanNotificationInfo[] { new MBeanNotificationInfo(names,
+ this.getClass().getName(), "Notifications emitted by a JMS Server") };
+ }
+
// StandardMBean overrides
// ---------------------------------------------------
@@ -131,8 +195,8 @@
MBeanInfo info = super.getMBeanInfo();
return new MBeanInfo(info.getClassName(), info.getDescription(), info
.getAttributes(), info.getConstructors(), MBeanInfoHelper
- .getMBeanOperationsInfo(JMSServerControlMBean.class), info
- .getNotifications());
+ .getMBeanOperationsInfo(JMSServerControlMBean.class),
+ getNotificationInfo());
}
// Package protected ---------------------------------------------
@@ -141,5 +205,17 @@
// Private -------------------------------------------------------
+ void sendNotification(NotificationType type, String message)
+ {
+ Notification notif = new Notification(type.toString(), this, notifSeq
+ .incrementAndGet(), message);
+ broadcaster.sendNotification(notif);
+ }
+
// Inner classes -------------------------------------------------
+
+ private enum NotificationType
+ {
+ QUEUE_CREATED, QUEUE_DESTROYED, TOPIC_CREATED, TOPIC_DESTROYED;
+ }
}
More information about the jboss-cvs-commits
mailing list