Package org.hornetq.utils.json

Examples of org.hornetq.utils.json.JSONArray


   // Static --------------------------------------------------------

    private static String toJSON(final Map<String, Object>[] messages)
    {
        JSONArray array = toJSONMsgArray(messages);
        return array.toString();
    }
View Full Code Here


        return array.toString();
    }

    private static JSONArray toJSONMsgArray(final Map<String, Object>[] messages)
    {
        JSONArray array = new JSONArray();
        for (Map<String, Object> message : messages)
        {
            array.put(new JSONObject(message));
        }
        return array;
    }
View Full Code Here

    private static String toJSON(final  Map<String, Map<String, Object>[]> messages)
    {
        try
        {
            JSONArray arrayReturn = new JSONArray();
            for (Map.Entry<String, Map<String, Object>[]> entry: messages.entrySet())
            {
                JSONObject objectItem = new JSONObject();
                objectItem.put("consumerName", entry.getKey());
                objectItem.put("elements", toJSONMsgArray(entry.getValue()));
                arrayReturn.put(objectItem);
            }

            return arrayReturn.toString();
        }
        catch (JSONException e)
        {
            return "Invalid conversion " + e.toString();
        }
View Full Code Here

      clearIO();
      try
      {
         Collection<Consumer> consumers = queue.getConsumers();

         JSONArray jsonArray = new JSONArray();

         for (Consumer consumer : consumers)
         {

            if (consumer instanceof ServerConsumer)
            {
               ServerConsumer serverConsumer = (ServerConsumer)consumer;

               JSONObject obj = new JSONObject();
               obj.put("consumerID", serverConsumer.getID());
               obj.put("connectionID", serverConsumer.getConnectionID().toString());
               obj.put("sessionID", serverConsumer.getSessionID());
               obj.put("browseOnly", serverConsumer.isBrowseOnly());
               obj.put("creationTime", serverConsumer.getCreationTime());

               jsonArray.put(obj);
            }

         }

         return jsonArray.toString();
      }
      finally
      {
         blockOnIO();
      }
View Full Code Here

            // sort by creation time, oldest first
            return (int)(entry1.getValue() - entry2.getValue());
         }
      });

      JSONArray txDetailListJson = new JSONArray();
      for (Map.Entry<Xid, Long> entry : xidsSortedByCreationTime)
      {
         Xid xid = entry.getKey();
         Transaction tx = resourceManager.getTransaction(xid);
         if (tx == null)
         {
            continue;
         }
         TransactionDetail detail = new JMSTransactionDetail(xid, tx, entry.getValue());
         txDetailListJson.put(detail.toJSON());
      }
      return txDetailListJson.toString();
   }
View Full Code Here

         html.append("<tr><th colspan=\"6\">Message List</th></tr>");
         html.append("<tr><td colspan=\"6\">");
         html.append("<table border=\"1\" cellspacing=\"0\" cellpadding=\"0\">");

         JSONArray msgs = txJson.getJSONArray(TransactionDetail.KEY_TX_RELATED_MESSAGES);
         for (int i = 0; i < msgs.length(); i++)
         {
            JSONObject msgJson = msgs.getJSONObject(i);
            JSONObject props = msgJson.getJSONObject(TransactionDetail.KEY_MSG_PROPERTIES);
            StringBuilder propstr = new StringBuilder();
            @SuppressWarnings("unchecked")
            Iterator<String> propkeys = props.keys();
            while (propkeys.hasNext())
View Full Code Here

      ClientConsumer consumer = session.createConsumer(queue);
      Assert.assertEquals(1, queueControl.getConsumerCount());

      System.out.println("Consumers: " + queueControl.listConsumersAsJSON());

      JSONArray obj = new JSONArray(queueControl.listConsumersAsJSON());

      assertEquals(1, obj.length());

      consumer.close();
      Assert.assertEquals(0, queueControl.getConsumerCount());

      obj = new JSONArray(queueControl.listConsumersAsJSON());

      assertEquals(0, obj.length());

      session.deleteQueue(queue);
   }
View Full Code Here

      // unscheduled message
      producer.send(session.createMessage(false));

      String jsonString = queueControl.listScheduledMessagesAsJSON();
      Assert.assertNotNull(jsonString);
      JSONArray array = new JSONArray(jsonString);
      Assert.assertEquals(1, array.length());
      Assert.assertEquals(intValue, array.getJSONObject(0).get("key"));

      Thread.sleep(delay + 500);

      jsonString = queueControl.listScheduledMessagesAsJSON();
      Assert.assertNotNull(jsonString);
      array = new JSONArray(jsonString);
      Assert.assertEquals(0, array.length());

      ManagementTestBase.consumeMessages(2, session, queue);

      session.deleteQueue(queue);
   }
View Full Code Here

      message.putIntProperty(new SimpleString("key"), intValue);
      producer.send(message);

      String jsonString = queueControl.listMessagesAsJSON(null);
      Assert.assertNotNull(jsonString);
      JSONArray array = new JSONArray(jsonString);
      Assert.assertEquals(1, array.length());
      Assert.assertEquals(intValue, array.getJSONObject(0).get("key"));

      ManagementTestBase.consumeMessages(1, session, queue);

      jsonString = queueControl.listMessagesAsJSON(null);
      Assert.assertNotNull(jsonString);
      array = new JSONArray(jsonString);
      Assert.assertEquals(0, array.length());

      session.deleteQueue(queue);
   }
View Full Code Here

      unmatchingMessage.putLongProperty(key, unmatchingValue);
      producer.send(unmatchingMessage);

      String jsonString = queueControl.listMessagesAsJSON(filter);
      Assert.assertNotNull(jsonString);
      JSONArray array = new JSONArray(jsonString);
      Assert.assertEquals(1, array.length());
      Assert.assertEquals(matchingValue, array.getJSONObject(0).get("key"));

      ManagementTestBase.consumeMessages(2, session, queue);

      jsonString = queueControl.listMessagesAsJSON(filter);
      Assert.assertNotNull(jsonString);
      array = new JSONArray(jsonString);
      Assert.assertEquals(0, array.length());

      session.deleteQueue(queue);
   }
View Full Code Here

TOP

Related Classes of org.hornetq.utils.json.JSONArray

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.