com.atlassian.jira.web
Class HttpRequestLocal<T>

java.lang.Object
  extended by 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
HttpRequestLocal(String name)
          Creates a new HttpRequestLocal, specifying the name to use.
 
Method Summary
 T get()
          Returns the value of this HttpRequestLocal, or null if it is not set.
protected  T initialValue()
          Returns the current request's "initial value" for this request-local variable.
 void remove()
          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 Detail

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 Detail

get

public T get()
Returns the value of this HttpRequestLocal, or null if it is not set.

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


Copyright © 2002-2012 Atlassian. All Rights Reserved.