[jboss-cvs] JBoss Messaging SVN: r5484 - in trunk/src/main/org/jboss/messaging/core: management and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Dec 9 05:50:59 EST 2008
Author: jmesnil
Date: 2008-12-09 05:50:59 -0500 (Tue, 09 Dec 2008)
New Revision: 5484
Modified:
trunk/src/main/org/jboss/messaging/core/client/management/impl/ManagementHelper.java
trunk/src/main/org/jboss/messaging/core/management/ManagementService.java
trunk/src/main/org/jboss/messaging/core/management/impl/ManagementServiceImpl.java
Log:
grouped related helper methods in ManagementHelper class
Modified: trunk/src/main/org/jboss/messaging/core/client/management/impl/ManagementHelper.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/client/management/impl/ManagementHelper.java 2008-12-09 10:13:07 UTC (rev 5483)
+++ trunk/src/main/org/jboss/messaging/core/client/management/impl/ManagementHelper.java 2008-12-09 10:50:59 UTC (rev 5484)
@@ -26,6 +26,10 @@
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
import javax.management.ObjectName;
import javax.management.openmbean.CompositeData;
@@ -90,11 +94,47 @@
for (int i = 0; i < parameters.length; i++)
{
Object parameter = parameters[i];
+ // use a zero-filled 2-padded index:
+ // if there is more than 10 parameters, order is preserved (e.g. 02 will be before 10)
SimpleString key = new SimpleString(String.format("%s%02d", HDR_JMX_OPERATION_PREFIX, i));
storeTypedProperty(message, key, parameter);
}
}
+ public static List<Object> retrieveOperationParameters(final Message message)
+ {
+ List<Object> params = new ArrayList<Object>();
+ Set<SimpleString> propertyNames = message.getPropertyNames();
+ // put the property names in a list to sort them and have the parameters
+ // in the correct order
+ List<SimpleString> propsNames = new ArrayList<SimpleString>(propertyNames);
+ Collections.sort(propsNames);
+ for (SimpleString propertyName : propsNames)
+ {
+ if (propertyName.startsWith(ManagementHelper.HDR_JMX_OPERATION_PREFIX))
+ {
+ String s = propertyName.toString();
+ // split by the dot
+ String[] ss = s.split("\\.");
+ try
+ {
+ int index = Integer.parseInt(ss[ss.length - 1]);
+ Object value = message.getProperty(propertyName);
+ if (value instanceof SimpleString)
+ {
+ value = value.toString();
+ }
+ params.add(index, value);
+ }
+ catch (NumberFormatException e)
+ {
+ // ignore the property (it is the operation name)
+ }
+ }
+ }
+ return params;
+ }
+
public static boolean isOperationResult(final Message message)
{
return message.containsProperty(HDR_JMX_OPERATION_SUCCEEDED);
Modified: trunk/src/main/org/jboss/messaging/core/management/ManagementService.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/management/ManagementService.java 2008-12-09 10:13:07 UTC (rev 5483)
+++ trunk/src/main/org/jboss/messaging/core/management/ManagementService.java 2008-12-09 10:50:59 UTC (rev 5484)
@@ -28,6 +28,7 @@
import org.jboss.messaging.core.client.management.impl.ManagementHelper;
import org.jboss.messaging.core.config.Configuration;
+import org.jboss.messaging.core.message.Message;
import org.jboss.messaging.core.messagecounter.MessageCounterManager;
import org.jboss.messaging.core.persistence.StorageManager;
import org.jboss.messaging.core.postoffice.PostOffice;
@@ -35,7 +36,6 @@
import org.jboss.messaging.core.security.Role;
import org.jboss.messaging.core.server.MessagingServer;
import org.jboss.messaging.core.server.Queue;
-import org.jboss.messaging.core.server.ServerMessage;
import org.jboss.messaging.core.settings.HierarchicalRepository;
import org.jboss.messaging.core.settings.impl.QueueSettings;
import org.jboss.messaging.core.transaction.ResourceManager;
@@ -81,7 +81,7 @@
public Object getResource(ObjectName objectName);
- void handleMessage(ServerMessage message);
+ void handleMessage(Message message);
void sendNotification(NotificationType type, String message) throws Exception;
Modified: trunk/src/main/org/jboss/messaging/core/management/impl/ManagementServiceImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/management/impl/ManagementServiceImpl.java 2008-12-09 10:13:07 UTC (rev 5483)
+++ trunk/src/main/org/jboss/messaging/core/management/impl/ManagementServiceImpl.java 2008-12-09 10:50:59 UTC (rev 5484)
@@ -30,7 +30,6 @@
import java.lang.reflect.Method;
import java.nio.ByteBuffer;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -49,6 +48,7 @@
import org.jboss.messaging.core.management.jmx.impl.ReplicationAwareAddressControlWrapper;
import org.jboss.messaging.core.management.jmx.impl.ReplicationAwareMessagingServerControlWrapper;
import org.jboss.messaging.core.management.jmx.impl.ReplicationAwareQueueControlWrapper;
+import org.jboss.messaging.core.message.Message;
import org.jboss.messaging.core.messagecounter.MessageCounter;
import org.jboss.messaging.core.messagecounter.MessageCounterManager;
import org.jboss.messaging.core.messagecounter.impl.MessageCounterManagerImpl;
@@ -243,7 +243,7 @@
sendNotification(NotificationType.QUEUE_DESTROYED, name.toString());
}
- public void handleMessage(final ServerMessage message)
+ public void handleMessage(final Message message)
{
SimpleString objectName = (SimpleString)message.getProperty(ManagementHelper.HDR_JMX_OBJECTNAME);
if (log.isDebugEnabled())
@@ -260,7 +260,7 @@
if (propNames.contains(ManagementHelper.HDR_JMX_OPERATION_NAME))
{
SimpleString operation = (SimpleString)message.getProperty(ManagementHelper.HDR_JMX_OPERATION_NAME);
- List<Object> operationParameters = retrieveOperationParameters(message);
+ List<Object> operationParameters = ManagementHelper.retrieveOperationParameters(message);
if (operation != null)
{
@@ -455,39 +455,5 @@
return result;
}
- private List<Object> retrieveOperationParameters(final ServerMessage message)
- {
- List<Object> params = new ArrayList<Object>();
- Set<SimpleString> propertyNames = message.getPropertyNames();
- // put the property names in a list to sort them and have the parameters
- // in the correct order
- List<SimpleString> propsNames = new ArrayList<SimpleString>(propertyNames);
- Collections.sort(propsNames);
- for (SimpleString propertyName : propsNames)
- {
- if (propertyName.startsWith(ManagementHelper.HDR_JMX_OPERATION_PREFIX))
- {
- String s = propertyName.toString();
- // split by the dot
- String[] ss = s.split("\\.");
- try
- {
- int index = Integer.parseInt(ss[ss.length - 1]);
- Object value = message.getProperty(propertyName);
- if (value instanceof SimpleString)
- {
- value = value.toString();
- }
- params.add(index, value);
- }
- catch (NumberFormatException e)
- {
- // ignore the property (it is the operation name)
- }
- }
- }
- return params;
- }
-
// Inner classes -------------------------------------------------
}
More information about the jboss-cvs-commits
mailing list