Class RequestContext


  • 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.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static RequestContext NONE
      Signifies that no data needs to be passed to the pipeline.
    • Constructor Summary

      Constructors 
      Constructor Description
      RequestContext​(java.lang.Object key, java.lang.Object value)
      Constructs a new RequestContext object.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method 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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • NONE

        public static final RequestContext NONE
        Signifies that no data needs to be passed to the pipeline.
    • Constructor Detail

      • RequestContext

        public RequestContext​(java.lang.Object key,
                              java.lang.Object value)
        Constructs a new RequestContext object.
        Parameters:
        key - The key with which the specified value should be associated.
        value - The value to be associated with the specified key.
        Throws:
        java.lang.IllegalArgumentException - If key is null.
    • Method Detail

      • addData

        public 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.
        Parameters:
        key - The key with which the specified value should be associated.
        value - The value to be associated with the specified key.
        Returns:
        the new RequestContext object containing the specified pair added to the set of pairs.
        Throws:
        java.lang.IllegalArgumentException - If key is null.
      • getData

        public Option<java.lang.Object> getData​(java.lang.Object key)
        Scans the linked-list of RequestContext objects looking for one with the specified key. Note that the first key found, i.e. the most recently added, will be returned.
        Parameters:
        key - The key to search for.
        Returns:
        The value of the specified key if it exists.
        Throws:
        java.lang.IllegalArgumentException - If key is null.