Author: ron.sigal(a)jboss.com
Date: 2009-08-26 15:41:52 -0400 (Wed, 26 Aug 2009)
New Revision: 5391
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/transport/servlet/ServletServerInvoker.java
Log:
JBREM-1145: Made use of new content type test optional.
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/transport/servlet/ServletServerInvoker.java
===================================================================
---
remoting2/branches/2.x/src/main/org/jboss/remoting/transport/servlet/ServletServerInvoker.java 2009-08-26
19:39:51 UTC (rev 5390)
+++
remoting2/branches/2.x/src/main/org/jboss/remoting/transport/servlet/ServletServerInvoker.java 2009-08-26
19:41:52 UTC (rev 5391)
@@ -71,6 +71,8 @@
private static final Logger log = Logger.getLogger(ServletServerInvoker.class);
private boolean unwrapSingletonArrays;
+
+ private boolean useRemotingContentType;
public ServletServerInvoker(InvokerLocator locator)
{
@@ -106,6 +108,17 @@
val + " to a boolean value.");
}
}
+
+ val = configuration.get(HTTPMetadataConstants.USE_REMOTING_CONTENT_TYPE);
+ if (val != null && val instanceof String)
+ {
+ useRemotingContentType = Boolean.valueOf((String) val).booleanValue();
+ }
+ else
+ {
+ log.warn(HTTPMetadataConstants.USE_REMOTING_CONTENT_TYPE + " value should
be a String: " + val);
+ }
+ log.debug(this + " useRemotingContentType: " + useRemotingContentType);
}
public void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
@@ -317,6 +330,13 @@
if (path != null)
metadata.put(HTTPMetadataConstants.PATH, path);
+ metadata.put(HTTPMetadataConstants.USE_REMOTING_CONTENT_TYPE,
Boolean.toString(useRemotingContentType));
+ String remotingContentType = (String)
metadata.get(HTTPMetadataConstants.REMOTING_CONTENT_TYPE);
+ if (remotingContentType == null)
+ {
+ remotingContentType = (String)
metadata.get(HTTPMetadataConstants.REMOTING_CONTENT_TYPE_LC);
+ }
+
String requestContentType = request.getContentType();
@@ -358,7 +378,8 @@
}
else
{
- if(WebUtil.isBinary(requestContentType))
+ if((useRemotingContentType &&
HTTPMetadataConstants.REMOTING_CONTENT_TYPE_NON_STRING.equalsIgnoreCase(remotingContentType))
+ || (!useRemotingContentType &&
WebUtil.isBinary(requestContentType)))
{
invocationRequest = getInvocationRequest(metadata, obj);
}
@@ -394,6 +415,7 @@
if (checkForNoExceptionReturn(metadata))
{
log.trace("Returning error message instead of Exception");
+ response.addHeader(HTTPMetadataConstants.REMOTING_CONTENT_TYPE,
HTTPMetadataConstants.REMOTING_CONTENT_TYPE_STRING);
response.sendError(500, "Error occurred processing invocation
request. ");
return retval;
}
@@ -472,7 +494,15 @@
retval = outputStream.toByteArray();
response.setContentLength(retval.length);
}
-
+
+ if (responseObject instanceof String)
+ {
+ response.addHeader(HTTPMetadataConstants.REMOTING_CONTENT_TYPE,
HTTPMetadataConstants.REMOTING_CONTENT_TYPE_STRING);
+ }
+ else
+ {
+ response.addHeader(HTTPMetadataConstants.REMOTING_CONTENT_TYPE,
HTTPMetadataConstants.REMOTING_CONTENT_TYPE_NON_STRING);
+ }
}
catch(ClassNotFoundException e)
{