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 Summary
Fields inherited from interface org.apache.struts2.rest.ContentTypeHandlerManager
STRUTS_REST_HANDLER_OVERRIDE_PREFIX
-
Constructor Summary
Constructors -
Method Summary
Modifier 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 String
readResultCode
(Object methodResult) protected Integer
readStatusCode
(Object methodResult) void
setContainer
(Container container) void
setDefaultExtension
(String name)
-
Constructor Details
-
DefaultContentTypeHandlerManager
public DefaultContentTypeHandlerManager()
-
-
Method Details
-
setDefaultExtension
-
setContainer
-
getHandlerForRequest
Gets the handler for the request by looking at the request content type and extension- Specified by:
getHandlerForRequest
in interfaceContentTypeHandlerManager
- Parameters:
request
- The request- Returns:
- The appropriate handler
-
getHandlerForResponse
public 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:
getHandlerForResponse
in interfaceContentTypeHandlerManager
- Parameters:
request
- The requestres
- 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
-
handleResult
public String handleResult(ActionInvocation invocation, Object methodResult, Object target) throws IOException Handles the result using handlers to generate content type-specific content- Specified by:
handleResult
in interfaceContentTypeHandlerManager
- Parameters:
invocation
- The action invocation for the current requestmethodResult
- The object returned from the action methodtarget
- 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
-
getExtensionIfPresent
Gets the extension in the url- Parameters:
url
- The url- Returns:
- The extension, or null
-
findExtension
Finds the extension in the url- Specified by:
findExtension
in interfaceContentTypeHandlerManager
- Parameters:
url
- The url- Returns:
- The extension, or the default extension if there is none
-