Package org.apache.struts2.rest
Class DefaultContentTypeHandlerManager
java.lang.Object
org.apache.struts2.rest.DefaultContentTypeHandlerManager
- All Implemented Interfaces:
- ContentTypeHandlerManager
Manages 
ContentTypeHandler instances and uses them to
 process results- 
Field SummaryFields inherited from interface org.apache.struts2.rest.ContentTypeHandlerManagerSTRUTS_REST_HANDLER_OVERRIDE_PREFIX
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionfindExtension(String url) Finds the extension in the urlGets the extension in the urlgetHandlerForRequest(jakarta.servlet.http.HttpServletRequest request) Gets the handler for the request by looking at the request content type and extensiongetHandlerForResponse(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse res) Gets the handler for the response by looking at the extension of the requesthandleResult(ActionInvocation invocation, Object methodResult, Object target) Handles the result using handlers to generate content type-specific contentprotected StringreadResultCode(Object methodResult) protected IntegerreadStatusCode(Object methodResult) voidsetContainer(Container container) voidsetDefaultExtension(String name) 
- 
Constructor Details- 
DefaultContentTypeHandlerManagerpublic DefaultContentTypeHandlerManager()
 
- 
- 
Method Details- 
setDefaultExtension
- 
setContainer
- 
getHandlerForRequestGets the handler for the request by looking at the request content type and extension- Specified by:
- getHandlerForRequestin interface- ContentTypeHandlerManager
- Parameters:
- request- The request
- Returns:
- The appropriate handler
 
- 
getHandlerForResponsepublic ContentTypeHandler getHandlerForResponse(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse res) Gets the handler for the response by looking at the extension of the request- Specified by:
- getHandlerForResponsein interface- ContentTypeHandlerManager
- Parameters:
- request- The request
- res- The servlet response
- Returns:
- The appropriate handler WW-4588: modified to get a handler for the response side and auto generate the response type from the Accept: header
 
- 
handleResultpublic String handleResult(ActionInvocation invocation, Object methodResult, Object target) throws IOException Handles the result using handlers to generate content type-specific content- Specified by:
- handleResultin interface- ContentTypeHandlerManager
- Parameters:
- invocation- The action invocation 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:
- IOException- If unable to write to the response
 
- 
readStatusCode
- 
readResultCode
- 
getExtensionIfPresentGets the extension in the url- Parameters:
- url- The url
- Returns:
- The extension, or null
 
- 
findExtensionFinds the extension in the url- Specified by:
- findExtensionin interface- ContentTypeHandlerManager
- Parameters:
- url- The url
- Returns:
- The extension, or the default extension if there is none
 
 
-