Commits

Manjula Piyumal committed c1f1e40

Adding clustering command support for commands with String Array properties

Comments (0)

Files changed (3)

modules/core/src/main/java/org/adroitlogic/ultraesb/clustering/ClusteringConstants.java

     public static final String COMMAND_ARGUMENT_SEPARATOR = "?";
     public static final String COMMAND_PARAMETER_SEPARATOR = "&";
     public static final String COMMAND_PARAMETER_VALUE_SEPARATOR = "=";
+    public static final String COMMAND_VALUE_LIST_START = "[";
+    public static final String COMMAND_VALUE_LIST_END = "]";
+    public static final String COMMAND_VALUE_LIST_ITEM_SEPARATOR = ",";
     public static final String COMMAND_PACKAGE_NAME = "org.adroitlogic.ultraesb.clustering.commands";
     public static final long DEFAULT_CM_STARTUP_TIMEOUT = 30;
 

modules/core/src/main/java/org/adroitlogic/ultraesb/clustering/ControlCommandMarshaller.java

                                 + " marshaled successfully");
                             logger.debug("Marshaled command till now is : {}",
                                 serialization.toString());
-                        } else {
+                        } else if (pd.getPropertyType().isArray()) {
+                        serialization.append(serializedFieldCount == 0 ?
+                                ClusteringConstants.COMMAND_ARGUMENT_SEPARATOR :
+                                ClusteringConstants.COMMAND_PARAMETER_SEPARATOR).append(
+                                pd.getName()).append(
+                                ClusteringConstants.COMMAND_PARAMETER_VALUE_SEPARATOR);
+                        String[] values = (String[]) value;
+                        if (values.length > 0) {
+                            serialization.append(ClusteringConstants.COMMAND_VALUE_LIST_START);
+                        }
+                        for (String list_value : values) {
+                            serialization.append(list_value).append((list_value.equals(values[values.length - 1])) ? (ClusteringConstants.COMMAND_VALUE_LIST_END) : ClusteringConstants.COMMAND_VALUE_LIST_ITEM_SEPARATOR);
+                        }
+                        serializedFieldCount++;
+                        logger.debug("Command property named " + pd.getName() + " of type "
+                                + pd.getPropertyType() + " with value " + value.toString()
+                                + " marshaled successfully");
+                        logger.debug("Marshaled command till now is : {}",
+                                serialization.toString());
+                    } else {
                             // todo : complex type serialization
                             throw new OperationNotSupportedException("The complex type " +
                                 "marshaling is not yet supported");

modules/core/src/main/java/org/adroitlogic/ultraesb/clustering/ControlCommandUnmarshaller.java

                                 setter.invoke(command, Float.parseFloat(paramValue));
                             } else if (descriptor.getPropertyType().getCanonicalName().equals("boolean")) {
                                 setter.invoke(command, Boolean.parseBoolean(paramValue));
+                            } else if (descriptor.getPropertyType().isArray()) {
+                                setter.invoke(command, (new Object[]{((paramValue.substring(1, paramValue.length() - 1).split(ClusteringConstants.COMMAND_VALUE_LIST_ITEM_SEPARATOR)))}));
                             } else {
                                 logger.warn("Complex object received to be unmarshaled, which is not supported yet");
                                 // todo complex object unmarshaling