View Javadoc
1   package com.atlassian.plugin.refimpl.saldeps;
2   
3   import javax.servlet.ServletContext;
4   import javax.servlet.http.HttpServletRequest;
5   import javax.servlet.http.HttpServletResponse;
6   
7   public class ServletContextThreadLocal {
8       private static final ThreadLocal<HttpServletRequest> request = new ThreadLocal<HttpServletRequest>();
9       private static final ThreadLocal<HttpServletResponse> response = new ThreadLocal<HttpServletResponse>();
10  
11      public static ServletContext getContext() {
12          return getRequest().getSession().getServletContext();
13      }
14  
15      public static HttpServletRequest getRequest() {
16          return request.get();
17      }
18  
19      /**
20       * @param httpRequest the request
21       * @deprecated since 2.16. This method is not longer a part of public API and
22       * should not be used from outside of <code>com.atlassian.core.filters</code> package.
23       * The visibility of this method will be changed to package private in the future;
24       * no replacement provided.
25       */
26      public static void setRequest(HttpServletRequest httpRequest) {
27          request.set(httpRequest);
28      }
29  
30      /**
31       * @param httpResponse the response
32       * @deprecated since 2.18. This method is not longer a part of public API and
33       * should not be used from outside of <code>com.atlassian.core.filters</code> package.
34       * The visibility of this method will be changed to package private in the future;
35       * no replacement provided.
36       */
37      public static void setResponse(HttpServletResponse httpResponse) {
38          response.set(httpResponse);
39      }
40  
41      public static HttpServletResponse getResponse() {
42          return response.get();
43      }
44  }