Package org.hornetq.utils.json

Examples of org.hornetq.utils.json.JSONObject


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


         if (tx == null)
         {
            continue;
         }
         TransactionDetail detail = new JMSTransactionDetail(xid, tx, entry.getValue());
         JSONObject txJson = detail.toJSON();

         html.append("<table border=\"1\">");
         html.append("<tr><th>creation_time</th>");
         html.append("<td>" + txJson.get(TransactionDetail.KEY_CREATION_TIME) + "</td>");
         html.append("<th>xid_as_base_64</th>");
         html.append("<td colspan=\"3\">" + txJson.get(TransactionDetail.KEY_XID_AS_BASE64) + "</td></tr>");
         html.append("<tr><th>xid_format_id</th>");
         html.append("<td>" + txJson.get(TransactionDetail.KEY_XID_FORMAT_ID) + "</td>");
         html.append("<th>xid_global_txid</th>");
         html.append("<td>" + txJson.get(TransactionDetail.KEY_XID_GLOBAL_TXID) + "</td>");
         html.append("<th>xid_branch_qual</th>");
         html.append("<td>" + txJson.get(TransactionDetail.KEY_XID_BRANCH_QUAL) + "</td></tr>");

         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())
            {
               String key = propkeys.next();
               propstr.append(key);
               propstr.append("=");
               propstr.append(props.get(key));
               propstr.append(", ");
            }

            html.append("<th>operation_type</th>");
            html.append("<td>" + msgJson.get(TransactionDetail.KEY_MSG_OP_TYPE) + "</th>");
View Full Code Here

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

   public static String toJSON(final DayCounterInfo[] infos) throws JSONException
   {
      JSONObject json = new JSONObject();
      JSONArray counters = new JSONArray();
      for (DayCounterInfo info : infos)
      {
         JSONObject counter = new JSONObject();
         counter.put("date", info.getDate());
         counter.put("counters", Arrays.asList(info.getCounters()));
         counters.put(counter);
      }
      json.put("dayCounters", counters);
      return json.toString();
   }
View Full Code Here

    * Returns an array of RoleInfo corresponding to the JSON serialization returned
    * by {@link QueueControl#listMessageCounterHistory()}.
    */
   public static DayCounterInfo[] fromJSON(final String jsonString) throws JSONException
   {
      JSONObject json = new JSONObject(jsonString);
      JSONArray dayCounters = json.getJSONArray("dayCounters");
      DayCounterInfo[] infos = new DayCounterInfo[dayCounters.length()];
      for (int i = 0; i < dayCounters.length(); i++)
      {

         JSONObject counter = (JSONObject)dayCounters.get(i);
         JSONArray hour = (JSONArray)counter.getJSONArray("counters").get(0);
         int[] hourCounters = new int[24];
         for (int j = 0; j < 24; j++)
         {
            hourCounters[j] = hour.getInt(j);
         }
         DayCounterInfo info = new DayCounterInfo(counter.getString("date"), hourCounters);
         infos[i] = info;
      }
      return infos;
   }
View Full Code Here

   {
      JSONArray array = new JSONArray(jsonString);
      RoleInfo[] roles = new RoleInfo[array.length()];
      for (int i = 0; i < array.length(); i++)
      {
         JSONObject r = array.getJSONObject(i);
         RoleInfo role = new RoleInfo(r.getString("name"),
                                      r.getBoolean("send"),
                                      r.getBoolean("consume"),
                                      r.getBoolean("createDurableQueue"),
                                      r.getBoolean("deleteDurableQueue"),
                                      r.getBoolean("createNonDurableQueue"),
                                      r.getBoolean("deleteNonDurableQueue"),
                                      r.getBoolean("manage"));
         roles[i] = role;
      }
      return roles;
   }
View Full Code Here

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

   public static final AddressSettingsInfo from(final String jsonString) throws Exception
   {
      JSONObject object = new JSONObject(jsonString);
      return new AddressSettingsInfo(object.getString("addressFullMessagePolicy"),
                                     object.getLong("maxSizeBytes"),
                                     object.getInt("pageSizeBytes"),
                                     object.getInt("pageCacheMaxSize"),
                                     object.getInt("maxDeliveryAttempts"),
                                     object.getLong("redeliveryDelay"),
                                     object.getDouble("redeliveryMultiplier"),
                                     object.getLong("maxRedeliveryDelay"),
                                     object.getString("DLA"),
                                     object.getString("expiryAddress"),
                                     object.getBoolean("lastValueQueue"),
                                     object.getLong("redistributionDelay"),
                                     object.getBoolean("sendToDLAOnNoRoute"));
   }
View Full Code Here

      {
         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
View Full Code Here

            array[i] = inner;
         }
         else if (val instanceof JSONObject)
         {
            JSONObject jsonObject = (JSONObject)val;

            Map<String, Object> map = new HashMap<String, Object>();

            Iterator<String> iter = jsonObject.keys();

            while (iter.hasNext())
            {
               String key = iter.next();

               Object innerVal = jsonObject.get(key);

               if (innerVal instanceof JSONArray)
               {
                  innerVal = ManagementHelper.fromJSONArray(((JSONArray)innerVal));
               }
               else if (innerVal instanceof JSONObject)
               {
                  Map<String, Object> innerMap = new HashMap<String, Object>();
                  JSONObject o = (JSONObject)innerVal;
                  Iterator it = o.keys();
                  while (it.hasNext())
                  {
                     String k = (String)it.next();
                     innerMap.put(k, o.get(k));
                  }
                  innerVal = innerMap;
               }
               else if (innerVal instanceof Integer)
               {
View Full Code Here

         for (RemotingConnection connection : connections)
         {
            ServerSession session = jmsSessions.get(connection.getID());
            if (session != null)
            {
               JSONObject obj = new JSONObject();
               obj.put("connectionID", connection.getID().toString());
               obj.put("clientAddress", connection.getRemoteAddress());
               obj.put("creationTime", connection.getCreationTime());
               obj.put("clientID", session.getMetaData("jms-client-id"));
               obj.put("principal", session.getUsername());
               array.put(obj);
            }
         }
         return array.toString();
      }
View Full Code Here

               for (ServerSession session : sessions)
               {
                  Set<ServerConsumer> consumers = session.getServerConsumers();
                  for (ServerConsumer consumer : consumers)
                  {
                     JSONObject obj = toJSONObject(consumer);
                     if (obj != null)
                     {
                        array.put(obj);
                     }
                  }
View Full Code Here

TOP

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

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.