Class HttpServletRequestResponseContext
- java.lang.Object
-
- net.shibboleth.utilities.java.support.net.HttpServletRequestResponseContext
-
public final class HttpServletRequestResponseContext extends Object
Class which holds and makes available the current HTTP servlet request and response via ThreadLocal storage.See also
RequestResponseContextFilter, which is a Java ServletFilter-based way to populate and clean up this context in a servlet container.
-
-
Field Summary
Fields Modifier and Type Field Description private static ThreadLocal<javax.servlet.http.HttpServletRequest>currentRequestThreadLocal storage for request.private static ThreadLocal<javax.servlet.http.HttpServletResponse>currentResponseThreadLocal storage for response.
-
Constructor Summary
Constructors Modifier Constructor Description privateHttpServletRequestResponseContext()Constructor.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidclearCurrent()Clear the current thread-local context instances.static javax.servlet.http.HttpServletRequestgetRequest()Get the currentHttpServletRequestbeing serviced by the current thread.static javax.servlet.http.HttpServletResponsegetResponse()Get the currentHttpServletResponsebeing serviced by the current thread.static voidloadCurrent(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)Load the thread-local storage with the current request and response.
-
-
-
Field Detail
-
currentRequest
private static ThreadLocal<javax.servlet.http.HttpServletRequest> currentRequest
ThreadLocal storage for request.
-
currentResponse
private static ThreadLocal<javax.servlet.http.HttpServletResponse> currentResponse
ThreadLocal storage for response.
-
-
Method Detail
-
loadCurrent
public static void loadCurrent(@Nonnull javax.servlet.http.HttpServletRequest request, @Nonnull javax.servlet.http.HttpServletResponse response)Load the thread-local storage with the current request and response.- Parameters:
request- the currentHttpServletRequestresponse- the currentHttpServletResponse
-
clearCurrent
public static void clearCurrent()
Clear the current thread-local context instances.
-
getRequest
@Nullable public static javax.servlet.http.HttpServletRequest getRequest()
Get the currentHttpServletRequestbeing serviced by the current thread.- Returns:
- the current request
-
getResponse
@Nullable public static javax.servlet.http.HttpServletResponse getResponse()
Get the currentHttpServletResponsebeing serviced by the current thread.- Returns:
- the current response
-
-