public class RequestContext
extends java.lang.Object
RequestContext
offers a means of passing arbitrary data (key-value pairs) to pipeline policies.
Most applications do not need to pass arbitrary data to the pipeline and can pass RequestContext.NONE
or
null
.
Each context object is immutable. The addData(Object, Object)
method creates a new
RequestContext
object that refers to its parent, forming a linked list.
Modifier and Type | Field and Description |
---|---|
static RequestContext |
NONE
Signifies that no data needs to be passed to the pipeline.
|
Constructor and Description |
---|
RequestContext(java.lang.Object key,
java.lang.Object value)
Constructs a new
RequestContext object. |
Modifier and Type | Method and Description |
---|---|
RequestContext |
addData(java.lang.Object key,
java.lang.Object value)
Adds a new immutable
RequestContext object with the specified key-value pair to
the existing RequestContext chain. |
Option<java.lang.Object> |
getData(java.lang.Object key)
Scans the linked-list of
RequestContext objects looking for one with the specified key. |
public static final RequestContext NONE
public RequestContext(java.lang.Object key, java.lang.Object value)
RequestContext
object.key
- The key with which the specified value should be associated.value
- The value to be associated with the specified key.java.lang.IllegalArgumentException
- If key
is null
.public RequestContext addData(java.lang.Object key, java.lang.Object value)
RequestContext
object with the specified key-value pair to
the existing RequestContext
chain.key
- The key with which the specified value should be associated.value
- The value to be associated with the specified key.RequestContext
object containing the specified pair added to the set of pairs.java.lang.IllegalArgumentException
- If key
is null
.public Option<java.lang.Object> getData(java.lang.Object key)
RequestContext
objects looking for one with the specified key.
Note that the first key found, i.e. the most recently added, will be returned.key
- The key to search for.java.lang.IllegalArgumentException
- If key
is null
.