Package org.hornetq.utils.json

Examples of org.hornetq.utils.json.JSONArray


      SimpleString sstring = message.getBodyBuffer().readNullableSimpleString();
      String jsonString = (sstring == null) ? null : sstring.toString();
                                           ;
      if (jsonString != null)
      {
         JSONArray jsonArray = new JSONArray(jsonString);

         Object[] res = ManagementHelper.fromJSONArray(jsonArray);

         return res;
      }
View Full Code Here


      {
         return Collections.emptyMap();
      }

      // create a JSON array with 1 object:
      JSONArray array = new JSONArray("[{" + str + "}]");
      Map<String, Object> params = (Map<String, Object>)ManagementHelper.fromJSONArray(array)[0];
      return params;
   }
View Full Code Here

      // if there is a single item, we wrap it in to make it a JSON object
      if (!s.trim().startsWith("{"))
      {
         s = "{" + s + "}";
      }
      JSONArray array = new JSONArray("[" + s + "]");
      return ManagementHelper.fromJSONArray(array);
   }
View Full Code Here

      clearIO();

      try
      {
         JSONArray array = new JSONArray();

         Set<RemotingConnection> connections = server.getHornetQServer().getRemotingService().getConnections();

         Set<ServerSession> sessions = server.getHornetQServer().getSessions();

         Map<Object, ServerSession> jmsSessions = new HashMap<Object, ServerSession>();

         for (ServerSession session : sessions)
         {
            if (session.getMetaData("jms-session") != null)
            {
               jmsSessions.put(session.getConnectionID(), session);
            }
         }

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

      clearIO();

      try
      {
         JSONArray array = new JSONArray();

         Set<RemotingConnection> connections = server.getHornetQServer().getRemotingService().getConnections();
         for (RemotingConnection connection : connections)
         {
            if (connectionID.equals(connection.getID().toString()))
            {
               List<ServerSession> sessions = server.getHornetQServer().getSessions(connectionID);
               for (ServerSession session : sessions)
               {
                  Set<ServerConsumer> consumers = session.getServerConsumers();
                  for (ServerConsumer consumer : consumers)
                  {
                     JSONObject obj = toJSONObject(consumer);
                     if (obj != null)
                     {
                        array.put(obj);
                     }
                  }
               }
            }
         }
         return array.toString();
      }
      finally
      {
         blockOnIO();
      }
View Full Code Here

      clearIO();

      try
      {
         JSONArray array = new JSONArray();

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

   {
      checkStarted();

      clearIO();

      JSONArray array = new JSONArray();
      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
      {
         blockOnIO();
      }
      return array.toString();
   }
View Full Code Here

      return FilterConstants.HORNETQ_USERID + " = '" + jmsMessageID + "'";
   }

   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

   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.a;
               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();
      }
      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

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.