org.apache.struts2.rest
Class DefaultContentTypeHandlerManager

java.lang.Object
  extended by org.apache.struts2.rest.DefaultContentTypeHandlerManager
All Implemented Interfaces:
ContentTypeHandlerManager

public class DefaultContentTypeHandlerManager
extends java.lang.Object
implements ContentTypeHandlerManager

Manages ContentTypeHandler instances and uses them to process results


Field Summary
 
Fields inherited from interface org.apache.struts2.rest.ContentTypeHandlerManager
STRUTS_REST_HANDLER_OVERRIDE_PREFIX
 
Constructor Summary
DefaultContentTypeHandlerManager()
           
 
Method Summary
 java.lang.String findExtension(java.lang.String url)
          Finds the extension in the url
 ContentTypeHandler getHandlerForRequest(javax.servlet.http.HttpServletRequest req)
          Gets the handler for the request by looking at the request content type and extension
 ContentTypeHandler getHandlerForResponse(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
          Gets the handler for the response by looking at the extension of the request
 java.lang.String handleResult(ActionConfig actionConfig, java.lang.Object methodResult, java.lang.Object target)
          Handles the result using handlers to generate content type-specific content
 void setContainer(Container container)
           
 void setDefaultExtension(java.lang.String name)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultContentTypeHandlerManager

public DefaultContentTypeHandlerManager()
Method Detail

setDefaultExtension

public void setDefaultExtension(java.lang.String name)

setContainer

public void setContainer(Container container)

getHandlerForRequest

public ContentTypeHandler getHandlerForRequest(javax.servlet.http.HttpServletRequest req)
Gets the handler for the request by looking at the request content type and extension

Specified by:
getHandlerForRequest in interface ContentTypeHandlerManager
Parameters:
req - The request
Returns:
The appropriate handler

getHandlerForResponse

public ContentTypeHandler getHandlerForResponse(javax.servlet.http.HttpServletRequest req,
                                                javax.servlet.http.HttpServletResponse res)
Gets the handler for the response by looking at the extension of the request

Specified by:
getHandlerForResponse in interface ContentTypeHandlerManager
Parameters:
req - The request
Returns:
The appropriate handler

handleResult

public java.lang.String handleResult(ActionConfig actionConfig,
                                     java.lang.Object methodResult,
                                     java.lang.Object target)
                              throws java.io.IOException
Handles the result using handlers to generate content type-specific content

Specified by:
handleResult in interface ContentTypeHandlerManager
Parameters:
actionConfig - The action config for the current request
methodResult - The object returned from the action method
target - The object to return, usually the action object
Returns:
The new result code to process
Throws:
java.io.IOException - If unable to write to the response

findExtension

public java.lang.String findExtension(java.lang.String url)
Finds the extension in the url

Specified by:
findExtension in interface ContentTypeHandlerManager
Parameters:
url - The url
Returns:
The extension


Copyright © 2000-2011 Apache Software Foundation. All Rights Reserved.