Package org.hornetq.utils.json

Examples of org.hornetq.utils.json.JSONObject


         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


      try
      {
         List<ServerSession> sessions = server.getHornetQServer().getSessions(connectionID);
         for (ServerSession sess : sessions)
         {
            JSONObject obj = new JSONObject();
            obj.put("sessionID", sess.getName());
            obj.put("creationTime", sess.getCreationTime());
            array.put(obj);
         }
      }
      finally
      {
View Full Code Here

      return array.toString();
   }

   private JSONObject toJSONObject(ServerConsumer consumer) throws Exception
   {
      JSONObject obj = new JSONObject();
      obj.put("consumerID", consumer.getID());
      obj.put("connectionID", consumer.getConnectionID());
      obj.put("sessionID", consumer.getSessionID());
      obj.put("queueName", consumer.getQueue().getName().toString());
      obj.put("browseOnly", consumer.isBrowseOnly());
      obj.put("creationTime", consumer.getCreationTime());
      // JMS consumer with message filter use the queue's filter
      Filter queueFilter = consumer.getQueue().getFilter();
      if (queueFilter != null)
      {
         obj.put("filter", queueFilter.getFilterString().toString());
      }
      String[] destinationInfo = determineJMSDestination(consumer.getQueue().getAddress().toString());
      if (destinationInfo == null)
      {
         return null;
      }
      obj.put("destinationName", destinationInfo[0]);
      obj.put("destinationType", destinationInfo[1]);
      if (destinationInfo[1].equals("topic"))
      {
         try
         {
            HornetQDestination.decomposeQueueNameForDurableSubscription(consumer.getQueue().getName().toString());
            obj.put("durable", true);
         }
         catch (IllegalArgumentException e)
         {
            obj.put("durable", false);
         }
      }
      else
      {
         obj.put("durable", false);
      }

      return obj;
   }
View Full Code Here

   {
      Map<SimpleString, Pair<UUID, AtomicLong>> targetCopy = cloneTargetAddresses();

      for (Map.Entry<SimpleString, Pair<UUID, AtomicLong>> entry : targetCopy.entrySet())
      {
         JSONObject producerInfo = new JSONObject();
         producerInfo.put("connectionID", this.getConnectionID().toString());
         producerInfo.put("sessionID", this.getName());
         producerInfo.put("destination", entry.getKey().toString());
         producerInfo.put("lastUUIDSent", entry.getValue().getA());
         producerInfo.put("msgSent", entry.getValue().getB().longValue());
         array.put(producerInfo);
      }
   }
View Full Code Here

   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

               subName = pair.b;
            }

            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();
      }
View Full Code Here

      {
         Xid xid = entry.getKey();
         TransactionDetail detail = new JMSTransactionDetail(xid,
                                                             resourceManager.getTransaction(xid),
                                                             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

    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

        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();
        }
View Full Code Here

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

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