View Javadoc

1   /*
2    * $Id: RequestContext.java 502296 2007-02-01 17:33:39Z niallp $
3    *
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *  http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  package org.apache.struts2.spi;
22  
23  import org.apache.struts2.Messages;
24  
25  import javax.servlet.ServletContext;
26  import javax.servlet.http.Cookie;
27  import javax.servlet.http.HttpServletRequest;
28  import javax.servlet.http.HttpServletResponse;
29  import java.util.List;
30  import java.util.Locale;
31  import java.util.Map;
32  
33  /***
34   * Request context. A single request may span multiple actions with action chaining.
35   *
36   * @author crazybob@google.com (Bob Lee)
37   */
38  public interface RequestContext {
39  
40      /***
41       * Gets context of the currently executing action.
42       *
43       * @return current action context
44       */
45      ActionContext getActionContext();
46  
47      /***
48       * Convenience method. Equivalent to {@code getActionContext().getAction()}.
49       *
50       * @return currently executing action
51       */
52      Object getAction();
53  
54      /***
55       * Gets map of request parameters.
56       */
57      Map<String, String[]> getParameterMap();
58  
59      /***
60       * Gets map of request attributes.
61       */
62      Map<String, Object> getAttributeMap();
63  
64      /***
65       * Gets map of session attributes.
66       */
67      Map<String, Object> getSessionMap();
68  
69      /***
70       * Gets map of application (servlet context) attributes.
71       */
72      Map<String, Object> getApplicationMap();
73  
74      /***
75       * Finds cookies with the given name,
76       */
77      List<Cookie> findCookiesForName(String name);
78  
79      /***
80       * Gets locale.
81       */
82      Locale getLocale();
83  
84      /***
85       * Sets locale. Stores the locale in the session for future requests.
86       */
87      void setLocale(Locale locale);
88  
89      /***
90       * Gets messages.
91       */
92      Messages getMessages();
93  
94      /***
95       * Gets the servlet request.
96       */
97      HttpServletRequest getServletRequest();
98  
99      /***
100      * Gets the servlet response.
101      */
102     HttpServletResponse getServletResponse();
103 
104     /***
105      * Gets the servlet context.
106      */
107     ServletContext getServletContext();
108 
109     /***
110      * Gets the value stack.
111      */
112     ValueStack getValueStack();
113 
114     /***
115      * Invokes the next interceptor or the action method if no more interceptors remain.
116      *
117      * @return result name
118      * @throws IllegalStateException if already invoked or called from the action
119      */
120     String proceed() throws Exception;
121 }