ARTEMIS-565 fixing JMS Control stuff
This commit is contained in:
parent
03bb756079
commit
8873744d27
|
@ -122,6 +122,9 @@ public final class JsonUtil {
|
||||||
if (innerVal instanceof JsonArray) {
|
if (innerVal instanceof JsonArray) {
|
||||||
innerVal = fromJsonArray(((JsonArray) innerVal));
|
innerVal = fromJsonArray(((JsonArray) innerVal));
|
||||||
}
|
}
|
||||||
|
else if (innerVal instanceof JsonString) {
|
||||||
|
innerVal = ((JsonString)innerVal).getString();
|
||||||
|
}
|
||||||
else if (innerVal instanceof JsonObject) {
|
else if (innerVal instanceof JsonObject) {
|
||||||
Map<String, Object> innerMap = new HashMap<>();
|
Map<String, Object> innerMap = new HashMap<>();
|
||||||
JsonObject o = (JsonObject) innerVal;
|
JsonObject o = (JsonObject) innerVal;
|
||||||
|
@ -139,7 +142,8 @@ public final class JsonUtil {
|
||||||
Object[] data = (Object[]) innerVal;
|
Object[] data = (Object[]) innerVal;
|
||||||
CompositeData[] cds = new CompositeData[data.length];
|
CompositeData[] cds = new CompositeData[data.length];
|
||||||
for (int i1 = 0; i1 < data.length; i1++) {
|
for (int i1 = 0; i1 < data.length; i1++) {
|
||||||
ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(Base64.decode((data[i1].toString()))));
|
String dataConverted = convertJsonValue(data[i1], String.class).toString();
|
||||||
|
ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(Base64.decode(dataConverted)));
|
||||||
cds[i1] = (CompositeDataSupport) ois.readObject();
|
cds[i1] = (CompositeDataSupport) ois.readObject();
|
||||||
}
|
}
|
||||||
innerVal = cds;
|
innerVal = cds;
|
||||||
|
@ -191,7 +195,7 @@ public final class JsonUtil {
|
||||||
jsonObjectBuilder.add(key, (Short) param);
|
jsonObjectBuilder.add(key, (Short) param);
|
||||||
}
|
}
|
||||||
else if (param instanceof Byte) {
|
else if (param instanceof Byte) {
|
||||||
//??
|
jsonObjectBuilder.add(key, ((Byte) param).shortValue());
|
||||||
}
|
}
|
||||||
else if (param instanceof SimpleString) {
|
else if (param instanceof SimpleString) {
|
||||||
jsonObjectBuilder.add(key, param.toString());
|
jsonObjectBuilder.add(key, param.toString());
|
||||||
|
@ -225,7 +229,7 @@ public final class JsonUtil {
|
||||||
jsonArrayBuilder.add((Short) param);
|
jsonArrayBuilder.add((Short) param);
|
||||||
}
|
}
|
||||||
else if (param instanceof Byte) {
|
else if (param instanceof Byte) {
|
||||||
//??
|
jsonArrayBuilder.add(((Byte) param).shortValue());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
throw ActiveMQClientMessageBundle.BUNDLE.invalidManagementParam(param.getClass().getName());
|
throw ActiveMQClientMessageBundle.BUNDLE.invalidManagementParam(param.getClass().getName());
|
||||||
|
|
|
@ -138,7 +138,17 @@ public class JMSManagementHelper {
|
||||||
* and the result will be a String corresponding to the server exception.
|
* and the result will be a String corresponding to the server exception.
|
||||||
*/
|
*/
|
||||||
public static Object getResult(final Message message) throws Exception {
|
public static Object getResult(final Message message) throws Exception {
|
||||||
return ManagementHelper.getResult(JMSManagementHelper.getCoreMessage(message));
|
return getResult(message, 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 getResult(final Message message, Class desiredType) throws Exception {
|
||||||
|
return ManagementHelper.getResult(JMSManagementHelper.getCoreMessage(message), desiredType);
|
||||||
}
|
}
|
||||||
|
|
||||||
private JMSManagementHelper() {
|
private JMSManagementHelper() {
|
||||||
|
|
|
@ -57,23 +57,30 @@ public class JMSMessagingProxy {
|
||||||
// Protected -----------------------------------------------------
|
// Protected -----------------------------------------------------
|
||||||
|
|
||||||
public Object retrieveAttributeValue(final String attributeName) {
|
public Object retrieveAttributeValue(final String attributeName) {
|
||||||
|
return retrieveAttributeValue(attributeName, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object retrieveAttributeValue(final String attributeName, final Class desiredType) {
|
||||||
try {
|
try {
|
||||||
Message m = session.createMessage();
|
Message m = session.createMessage();
|
||||||
JMSManagementHelper.putAttribute(m, resourceName, attributeName);
|
JMSManagementHelper.putAttribute(m, resourceName, attributeName);
|
||||||
Message reply = requestor.request(m);
|
Message reply = requestor.request(m);
|
||||||
return JMSManagementHelper.getResult(reply);
|
return JMSManagementHelper.getResult(reply, desiredType);
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
throw new IllegalStateException(e);
|
throw new IllegalStateException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object invokeOperation(final String operationName, final Object... args) throws Exception {
|
public Object invokeOperation(final String operationName, final Object... args) throws Exception {
|
||||||
|
return invokeOperation(null, operationName, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object invokeOperation(final Class desiredType, final String operationName, final Object... args) throws Exception {
|
||||||
Message m = session.createMessage();
|
Message m = session.createMessage();
|
||||||
JMSManagementHelper.putOperationInvocation(m, resourceName, operationName, args);
|
JMSManagementHelper.putOperationInvocation(m, resourceName, operationName, args);
|
||||||
Message reply = requestor.request(m);
|
Message reply = requestor.request(m);
|
||||||
if (JMSManagementHelper.hasOperationSucceeded(reply)) {
|
if (JMSManagementHelper.hasOperationSucceeded(reply)) {
|
||||||
return JMSManagementHelper.getResult(reply);
|
return JMSManagementHelper.getResult(reply, desiredType);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
throw new Exception((String) JMSManagementHelper.getResult(reply));
|
throw new Exception((String) JMSManagementHelper.getResult(reply));
|
||||||
|
|
|
@ -96,7 +96,7 @@ public class JMSQueueControlUsingJMSTest extends JMSQueueControlTest {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int changeMessagesPriority(final String filter, final int newPriority) throws Exception {
|
public int changeMessagesPriority(final String filter, final int newPriority) throws Exception {
|
||||||
return (Integer) proxy.invokeOperation("changeMessagesPriority", filter, newPriority);
|
return (Integer) proxy.invokeOperation(Integer.class, "changeMessagesPriority", filter, newPriority);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -111,12 +111,12 @@ public class JMSQueueControlUsingJMSTest extends JMSQueueControlTest {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int expireMessages(final String filter) throws Exception {
|
public int expireMessages(final String filter) throws Exception {
|
||||||
return (Integer) proxy.invokeOperation("expireMessages", filter);
|
return (Integer) proxy.invokeOperation(Integer.class, "expireMessages", filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getConsumerCount() {
|
public int getConsumerCount() {
|
||||||
return (Integer) proxy.retrieveAttributeValue("consumerCount");
|
return (Integer) proxy.retrieveAttributeValue("consumerCount", Integer.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -136,7 +136,7 @@ public class JMSQueueControlUsingJMSTest extends JMSQueueControlTest {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getDeliveringCount() {
|
public int getDeliveringCount() {
|
||||||
return (Integer) proxy.retrieveAttributeValue("deliveringCount");
|
return (Integer) proxy.retrieveAttributeValue("deliveringCount", Integer.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -166,7 +166,7 @@ public class JMSQueueControlUsingJMSTest extends JMSQueueControlTest {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getMessagesAdded() {
|
public long getMessagesAdded() {
|
||||||
return (Integer) proxy.retrieveAttributeValue("messagesAdded");
|
return (Integer) proxy.retrieveAttributeValue("messagesAdded", Integer.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -210,7 +210,7 @@ public class JMSQueueControlUsingJMSTest extends JMSQueueControlTest {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int retryMessages() throws Exception {
|
public int retryMessages() throws Exception {
|
||||||
return (Integer) proxy.invokeOperation("retryMessages");
|
return (Integer) proxy.invokeOperation("retryMessages", Integer.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -267,12 +267,12 @@ public class JMSQueueControlUsingJMSTest extends JMSQueueControlTest {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int moveMessages(String filter, String otherQueueName, boolean rejectDuplicates) throws Exception {
|
public int moveMessages(String filter, String otherQueueName, boolean rejectDuplicates) throws Exception {
|
||||||
return (Integer) proxy.invokeOperation("moveMessages", filter, otherQueueName, rejectDuplicates);
|
return (Integer) proxy.invokeOperation(Integer.class, "moveMessages", filter, otherQueueName, rejectDuplicates);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int moveMessages(final String filter, final String otherQueueName) throws Exception {
|
public int moveMessages(final String filter, final String otherQueueName) throws Exception {
|
||||||
return (Integer) proxy.invokeOperation("moveMessages", filter, otherQueueName);
|
return (Integer) proxy.invokeOperation(Integer.class, "moveMessages", filter, otherQueueName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -282,7 +282,7 @@ public class JMSQueueControlUsingJMSTest extends JMSQueueControlTest {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int removeMessages(final String filter) throws Exception {
|
public int removeMessages(final String filter) throws Exception {
|
||||||
return (Integer) proxy.invokeOperation("removeMessages", filter);
|
return (Integer) proxy.invokeOperation(Integer.class, "removeMessages", filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -297,7 +297,7 @@ public class JMSQueueControlUsingJMSTest extends JMSQueueControlTest {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int sendMessagesToDeadLetterAddress(final String filterStr) throws Exception {
|
public int sendMessagesToDeadLetterAddress(final String filterStr) throws Exception {
|
||||||
return (Integer) proxy.invokeOperation("sendMessagesToDeadLetterAddress", filterStr);
|
return (Integer) proxy.invokeOperation(Integer.class, "sendMessagesToDeadLetterAddress", filterStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue