Class HttpRequestLocal<T>

java.lang.Object
com.atlassian.jira.web.HttpRequestLocal<T>

@Immutable public class HttpRequestLocal<T> extends Object
Per-request variable (similar to ThreadLocal, but request-scoped).
Since:
v4.4
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new HttpRequestLocal, specifying the name to use.
  • Method Summary

    Modifier and Type
    Method
    Description
    get()
    Returns the value of this HttpRequestLocal, or null if it is not set.
    protected T
    Returns the current request's "initial value" for this request-local variable.
    void
    Removes the value of this HttpRequestLocal.
    void
    set(T value)
    Sets the value of this HttpRequestLocal.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • HttpRequestLocal

      public HttpRequestLocal(String name)
      Creates a new HttpRequestLocal, specifying the name to use. This name is used as the attribute name under which this request local is stored in the servlet request.
      Parameters:
      name - a String containing the attribute name to use in the servlet request
  • Method Details

    • get

      public T get()
      Returns the value of this HttpRequestLocal, or null if it is not set. If there is no current HTTP request, this method returns null regardless of what initialValue() would have returned.
      Returns:
      the value of this HttpRequestLocal, or null
    • set

      public void set(T value)
      Sets the value of this HttpRequestLocal.
      Parameters:
      value - the value to set
    • remove

      public void remove()
      Removes the value of this HttpRequestLocal.
    • initialValue

      protected T initialValue()
      Returns the current request's "initial value" for this request-local variable. This method will be invoked the first time that this request local variable's get() method is called in a request.

      This implementation simply returns null. Override this method for different initial values.

      Returns:
      the initial value for this request local