activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dej...@apache.org
Subject svn commit: r1364560 - /activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/MessageServlet.java
Date Mon, 23 Jul 2012 09:57:42 GMT
Author: dejanb
Date: Mon Jul 23 09:57:42 2012
New Revision: 1364560

URL: http://svn.apache.org/viewvc?rev=1364560&view=rev
Log:
https://issues.apache.org/jira/browse/AMQ-3940 - REST API support for configurable response
content type

Modified:
    activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/MessageServlet.java

Modified: activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/MessageServlet.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/MessageServlet.java?rev=1364560&r1=1364559&r2=1364560&view=diff
==============================================================================
--- activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/MessageServlet.java
(original)
+++ activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/MessageServlet.java
Mon Jul 23 09:57:42 2012
@@ -60,6 +60,7 @@ public class MessageServlet extends Mess
     private long defaultReadTimeout = -1;
     private long maximumReadTimeout = 20000;
     private long requestTimeout = 1000;
+    private String defaultContentType = "text/xml";
 
     private HashMap<String, WebClient> clients = new HashMap<String, WebClient>();
 
@@ -77,6 +78,10 @@ public class MessageServlet extends Mess
         if (name != null) {
             requestTimeout = asLong(name);
         }
+        name = servletConfig.getInitParameter("defaultContentType");
+        if (name != null) {
+            defaultContentType = name;
+        }
     }
 
     /**
@@ -236,7 +241,7 @@ public class MessageServlet extends Mess
         try {
 
             // write a responds
-            response.setContentType("text/xml");
+            response.setContentType(defaultContentType);
             PrintWriter writer = response.getWriter();
 
             // handle any message(s)
@@ -280,11 +285,6 @@ public class MessageServlet extends Mess
         }
     }
 
-    protected boolean isRicoAjax(HttpServletRequest request) {
-        String rico = request.getParameter("rico");
-        return rico != null && rico.equals("true");
-    }
-
     public WebClient getWebClient(HttpServletRequest request) {
         String clientId = request.getParameter("clientId");
         if (clientId != null) {
@@ -305,16 +305,14 @@ public class MessageServlet extends Mess
     }
 
     protected String getContentType(HttpServletRequest request) {
-        /*
-         * log("Params: " + request.getParameterMap()); Enumeration iter =
-         * request.getHeaderNames(); while (iter.hasMoreElements()) { String
-         * name = (String) iter.nextElement(); log("Header: " + name + " = " +
-         * request.getHeader(name)); }
-         */
         String value = request.getParameter("xml");
         if (value != null && "true".equalsIgnoreCase(value)) {
             return "text/xml";
         }
+        value = request.getParameter("json");
+        if (value != null && "true".equalsIgnoreCase(value)) {
+            return "application/json";
+        }
         return null;
     }
 



Mime
View raw message