message.getBodyBuffer().writeBytes(decode(characters.trim()));
/** * Used by HornetQ management service. */ public static Object[] retrieveOperationParameters(final Message message) throws Exception { SimpleString sstring = message.getBodyBuffer().readNullableSimpleString(); String jsonString = (sstring == null) ? null : sstring.toString(); if (jsonString != null) { JSONArray jsonArray = new JSONArray(jsonString); return ManagementHelper.fromJSONArray(jsonArray); } else { return null; } }
/** * Used by HornetQ management service. */ public static void storeResult(final Message message, final Object result) throws Exception { String resultString; if (result != null) { // Result is stored in body, also encoded as JSON array of length 1 JSONArray jsonArray = ManagementHelper.toJSONArray(new Object[]{result}); resultString = jsonArray.toString(); } else { resultString = null; } message.getBodyBuffer().writeNullableSimpleString(SimpleString.toSimpleString(resultString)); }
/** * Used by HornetQ management service. */ public static Object[] retrieveOperationParameters(final Message message) throws Exception { SimpleString sstring = message.getBodyBuffer().readNullableSimpleString(); String jsonString = (sstring == null) ? null : sstring.toString(); if (jsonString != null) { JSONArray jsonArray = new JSONArray(jsonString); return ManagementHelper.fromJSONArray(jsonArray); } else { return null; } }
/** * Returns the result of an operation invocation or an attribute value. * <br> * If an error occurred on the server, {@link #hasOperationSucceeded(Message)} will return {@code false}. * and the result will be a String corresponding to the server exception. */ public static Object[] getResults(final Message message) throws Exception { SimpleString sstring = message.getBodyBuffer().readNullableSimpleString(); String jsonString = (sstring == null) ? null : sstring.toString(); ; if (jsonString != null) { JSONArray jsonArray = new JSONArray(jsonString); Object[] res = ManagementHelper.fromJSONArray(jsonArray); return res; } else { return null; } }
/** * Used by HornetQ management service. */ public static void storeResult(final Message message, final Object result) throws Exception { String resultString; if (result != null) { // Result is stored in body, also encoded as JSON array of length 1 JSONArray jsonArray = ManagementHelper.toJSONArray(new Object[] { result }); resultString = jsonArray.toString(); } else { resultString = null; } message.getBodyBuffer().writeNullableSimpleString(SimpleString.toSimpleString(resultString)); }
/** * Returns the result of an operation invocation or an attribute value. * <br> * If an error occurred on the server, {@link #hasOperationSucceeded(Message)} will return {@code false}. * and the result will be a String corresponding to the server exception. */ public static Object[] getResults(final Message message) throws Exception { SimpleString sstring = message.getBodyBuffer().readNullableSimpleString(); String jsonString = (sstring == null) ? null : sstring.toString(); if (jsonString != null) { JSONArray jsonArray = new JSONArray(jsonString); Object[] res = ManagementHelper.fromJSONArray(jsonArray); return res; } else { return null; } }
message.getBodyBuffer().writeNullableSimpleString(SimpleString.toSimpleString(paramString));
/** * Stores a operation invocation in a message to invoke the corresponding operation the value from the server resource. * * @param message message * @param resourceName the name of the server resource * @param operationName the name of the operation to invoke on the server resource * @param parameters the parameters to use to invoke the server resource * @see ResourceNames */ public static void putOperationInvocation(final Message message, final String resourceName, final String operationName, final Object... parameters) throws Exception { // store the name of the operation in the headers message.putStringProperty(ManagementHelper.HDR_RESOURCE_NAME, new SimpleString(resourceName)); message.putStringProperty(ManagementHelper.HDR_OPERATION_NAME, new SimpleString(operationName)); // and the params go in the body, since might be too large for header String paramString; if (parameters != null) { JSONArray jsonArray = ManagementHelper.toJSONArray(parameters); paramString = jsonArray.toString(); } else { paramString = null; } message.getBodyBuffer().writeNullableSimpleString(SimpleString.toSimpleString(paramString)); }