Package org.hornetq.utils.json

Examples of org.hornetq.utils.json.JSONArray


   private String listSubscribersInfosAsJSON(final DurabilityType durability) throws Exception
   {
      try
      {
         List<QueueControl> queues = getQueues(durability);
         JSONArray array = new JSONArray();

         for (QueueControl queue : queues)
         {
            String clientID = null;
            String subName = null;

            if (queue.isDurable() && !queue.getName().startsWith(ResourceNames.JMS_TOPIC))
            {
               Pair<String, String> pair = HornetQDestination.decomposeQueueNameForDurableSubscription(queue.getName()
                                                                                                            .toString());
               clientID = pair.getA();
               subName = pair.getB();
            }
            else if (queue.getName().startsWith(ResourceNames.JMS_TOPIC))
            {
               // in the case of heirarchical topics the queue name will not follow the <part>.<part> pattern of normal
               // durable subscribers so skip decomposing the name for the client ID and subscription name and just
               // hard-code it
               clientID = "HornetQ";
               subName = "HornetQ";
            }

            String filter = queue.getFilter() != null ? queue.getFilter() : null;

            JSONObject info = new JSONObject();

            info.put("queueName", queue.getName());
            info.put("clientID", clientID);
            info.put("selector", filter);
            info.put("name", subName);
            info.put("durable", queue.isDurable());
            info.put("messageCount", queue.getMessageCount());
            info.put("deliveringCount", queue.getDeliveringCount());
            info.put("consumers", new JSONArray(queue.listConsumersAsJSON()) );
            array.put(info);
         }

         return array.toString();
      }
      catch (Exception e)
      {
         e.printStackTrace();
         return e.toString();
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();
         TransactionDetail detail = new JMSTransactionDetail(xid, resourceManager.getTransaction(xid), 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

            // 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

   private String listSubscribersInfosAsJSON(final DurabilityType durability) throws Exception
   {
      try
      {
         List<QueueControl> queues = getQueues(durability);
         JSONArray array = new JSONArray();

         for (QueueControl queue : queues)
         {
            String clientID = null;
            String subName = null;

            if (queue.isDurable())
            {
               Pair<String, String> pair = HornetQDestination.decomposeQueueNameForDurableSubscription(queue.getName()
                                                                                                            .toString());
               clientID = pair.getA();
               subName = pair.getB();
            }

            String filter = queue.getFilter() != null ? queue.getFilter() : null;

            JSONObject info = new JSONObject();

            info.put("queueName", queue.getName());
            info.put("clientID", clientID);
            info.put("selector", filter);
            info.put("name", subName);
            info.put("durable", queue.isDurable());
            info.put("messageCount", queue.getMessageCount());
            info.put("deliveringCount", queue.getDeliveringCount());
            info.put("consumers", new JSONArray(queue.listConsumersAsJSON()) );
            array.put(info);
         }

         return array.toString();
      }
      catch (Exception e)
      {
         e.printStackTrace();
         return e.toString();
View Full Code Here

      String paramString;

      if (parameters != null)
      {
         JSONArray jsonArray = ManagementHelper.toJSONArray(parameters);

         paramString = jsonArray.toString();
      }
      else
      {
         paramString = null;
      }
View Full Code Here

      message.getBodyBuffer().writeNullableString(paramString);
   }

   private static JSONArray toJSONArray(final Object[] array) throws Exception
   {
      JSONArray jsonArray = new JSONArray();

      for (Object parameter : array)
      {
         if (parameter instanceof Map)
         {
            Map<String, Object> map = (Map<String, Object>)parameter;

            JSONObject jsonObject = new JSONObject();

            for (Map.Entry<String, Object> entry : map.entrySet())
            {
               String key = entry.getKey();

               Object val = entry.getValue();

               if (val != null)
               {
                  if (val.getClass().isArray())
                  {
                     val = ManagementHelper.toJSONArray((Object[])val);
                  }
                  else
                  {
                     ManagementHelper.checkType(val);
                  }
               }

               jsonObject.put(key, val);
            }

            jsonArray.put(jsonObject);
         }
         else
         {
            if (parameter != null)
            {
               Class clz = parameter.getClass();

               if (clz.isArray())
               {
                  Object[] innerArray = (Object[])parameter;

                  jsonArray.put(ManagementHelper.toJSONArray(innerArray));
               }
               else
               {
                  ManagementHelper.checkType(parameter);

                  jsonArray.put(parameter);
               }
            }
            else
            {
               jsonArray.put((Object)null);
            }
         }
      }

      return jsonArray;
View Full Code Here

   {
      String jsonString = message.getBodyBuffer().readNullableString();

      if (jsonString != null)
      {
         JSONArray jsonArray = new JSONArray(jsonString);

         return ManagementHelper.fromJSONArray(jsonArray);
      }
      else
      {
View Full Code Here

      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;
      }
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.