1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 package org.apache.struts2.rest;
23
24 import org.apache.struts2.rest.handler.ContentTypeHandler;
25
26 import javax.servlet.http.HttpServletRequest;
27 import javax.servlet.http.HttpServletResponse;
28
29 import com.opensymphony.xwork2.config.entities.ActionConfig;
30
31 import java.io.IOException;
32
33 /***
34 * Manages content type handlers
35 */
36 public interface ContentTypeHandlerManager {
37 String STRUTS_REST_HANDLER_OVERRIDE_PREFIX = "struts.rest.handlerOverride.";
38
39 /***
40 * Gets the handler for the request by looking at the request content type and extension
41 * @param req The request
42 * @return The appropriate handler
43 */
44 ContentTypeHandler getHandlerForRequest(HttpServletRequest req);
45
46 /***
47 * Gets the handler for the response by looking at the extension of the request
48 * @param req The request
49 * @return The appropriate handler
50 */
51 ContentTypeHandler getHandlerForResponse(HttpServletRequest req, HttpServletResponse res);
52
53 /***
54 * Handles the result using handlers to generate content type-specific content
55 *
56 * @param actionConfig The action config for the current request
57 * @param methodResult The object returned from the action method
58 * @param target The object to return, usually the action object
59 * @return The new result code to process
60 * @throws IOException If unable to write to the response
61 */
62 String handleResult(ActionConfig actionConfig, Object methodResult, Object target)
63 throws IOException;
64 }