Class TransactionalStateSupport


  • public class TransactionalStateSupport
    extends Object
    Provides state persistence functionality for user attributes between HTTP invocations to the server on a per transaction basis. This class is similar to SessionStateSupport but the attributes are only available though the course of a single transaction rather than for a full session. The scope of a transaction is a single set of interactions between the server and an adapter to accomplish a single task (i.e. looking up a login context, even when spanning multiple HTTP request/response interactions, is a single transactional context).
    Transactional state is maintained using the same underlying mechanisms at SessionStateSupport but with an additional qualifier on the key to distinguish one transaction from another. This enables better support for concurrent and nested transactions. The transactional qualifier is a short opaque value encoded into the resume path that is passed to the adapter in front channel invocations.
    There are some server configurations where transactional state differentiation is not possible. In those cases, use of this API will default to behaving like SessionStateSupport.
    Attributes must be added or updated using the setAttribute(String, Object, HttpServletRequest, HttpServletResponse) or removeAttribute(String, HttpServletRequest, HttpServletResponse) methods before the associated HttpServletResponse response is committed.
    It's recommended that clients of this API 'clean up after themselves' and remove attributes when finished with them.
    Since:
    6.5
    • Method Detail

      • setAttribute

        public void setAttribute​(String name,
                                 Object value,
                                 javax.servlet.http.HttpServletRequest req,
                                 javax.servlet.http.HttpServletResponse resp)
        Sets a named attribute for the user's transactional context.
        Parameters:
        name - the name of the attribute
        value - value the attribute value
        req - HTTP request
        resp - HTTP response
        Since:
        6.5
      • removeAttribute

        public Object removeAttribute​(String name,
                                      javax.servlet.http.HttpServletRequest req,
                                      javax.servlet.http.HttpServletResponse resp)
        Removes the named attribute from the user's transactional context.
        Parameters:
        name - the name of the attribute
        req - HTTP request
        resp - HTTP response
        Returns:
        the value of the attribute that was removed, if it exists, null otherwise.
        Since:
        6.5
      • getTransactionalContextId

        public String getTransactionalContextId()
        Gets the transactional qualifier id that was embedded/encoded into the resume path.
        Returns:
        transactional qualifier id or null if no such qualifier was not present.
      • hasTransactionalContextId

        public boolean hasTransactionalContextId()
        Indicates if a transactional qualifier id embedded/encoded into the resume path.
        Returns:
        true if the resume path contains such an id, and false otherwise.