DeltaRequest (Apache Tomcat 11.0.24 API Documentation)
Description: declaration: package: org.apache.catalina.ha.session, class: DeltaRequest

# Class DeltaRequest

java.lang.Object
org.apache.catalina.ha.session.DeltaRequest

All Implemented Interfaces:
  `Externalizable, Serializable`

public class DeltaRequest extends Object implements Externalizable
This class is used to track the series of actions that happens when a request is executed. These actions will then translate into invocations of methods on the actual session.

This class is NOT thread safe. One DeltaRequest per session.

See Also:
  - Serialized Form

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final int`
  `ACTION_REMOVE`
  Action to remove a value.
  `static final int`
  `ACTION_SET`
  Action to set a value.
  `static final Log`
  `log`
  The logger for this class.
  `static final String`
  `NAME_AUTHTYPE`
  Name used for auth type actions.
  `static final String`
  `NAME_ISNEW`
  Name used for new flag actions.
  `static final String`
  `NAME_LISTENER`
  Name used for listener actions.
  `static final String`
  `NAME_MAXINTERVAL`
  Name used for max inactive interval actions.
  `static final String`
  `NAME_PRINCIPAL`
  Name used for principal actions.
  `protected static final StringManager`
  `sm`
  The string manager for this package.
  `static final int`
  `TYPE_ATTRIBUTE`
  Action type for session attributes.
  `static final int`
  `TYPE_AUTHTYPE`
  Action type for session authentication type.
  `static final int`
  `TYPE_ISNEW`
  Action type for session new flag.
  `static final int`
  `TYPE_LISTENER`
  Action type for session listener.
  `static final int`
  `TYPE_MAXINTERVAL`
  Action type for session max inactive interval.
  `static final int`
  `TYPE_NOTE`
  Action type for session note.
  `static final int`
  `TYPE_PRINCIPAL`
  Action type for session principal.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `DeltaRequest()`
  Default constructor required by `Externalizable`.
  `DeltaRequest(String sessionId, boolean recordAllActions)`
  Construct a new DeltaRequest.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected void`
  `addAction(int type, int action, String name, Object value)`
  Add an action to the list of actions to be executed.
  `void`
  `addSessionListener(SessionListener listener)`
  Record an add session listener action.
  `void`
  `clear()`
  Clear all actions and the action pool.
  `void`
  `execute(DeltaSession session, boolean notifyListeners)`
  Execute all recorded actions on the given session.
  `String`
  `getSessionId()`
  Get the session identifier.
  `int`
  `getSize()`
  Get the number of actions recorded.
  `void`
  `readExternal(ObjectInput in)`
  `void`
  `removeAttribute(String name)`
  Record a remove attribute action.
  `void`
  `removeNote(String name)`
  Record a remove note action.
  `void`
  `removeSessionListener(SessionListener listener)`
  Record a remove session listener action.
  `void`
  `reset()`
  Reset this request, returning all action objects to the pool.
  `protected byte[]`
  `serialize()`
  serialize DeltaRequest
  `void`
  `setAttribute(String name, Object value)`
  Record a set attribute action.
  `void`
  `setAuthType(String authType)`
  Record a set auth type action.
  `void`
  `setMaxInactiveInterval(int interval)`
  Record a set max inactive interval action.
  `void`
  `setNew(boolean n)`
  Record a set new action.
  `void`
  `setNote(String name, Object value)`
  Record a set note action.
  `void`
  `setPrincipal(Principal p)`
  Only support principals from type `GenericPrincipal`
  `void`
  `setSessionId(String sessionId)`
  Set the session identifier.
  `void`
  `writeExternal(ObjectOutput out)`

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### log

    public static final Log log
    The logger for this class.

  - ### sm

    protected static final StringManager sm
    The string manager for this package.

  - ### TYPE_ATTRIBUTE

    public static final int TYPE_ATTRIBUTE
    Action type for session attributes.
    See Also:
      - Constant Field Values

  - ### TYPE_PRINCIPAL

    public static final int TYPE_PRINCIPAL
    Action type for session principal.
    See Also:
      - Constant Field Values

  - ### TYPE_ISNEW

    public static final int TYPE_ISNEW
    Action type for session new flag.
    See Also:
      - Constant Field Values

  - ### TYPE_MAXINTERVAL

    public static final int TYPE_MAXINTERVAL
    Action type for session max inactive interval.
    See Also:
      - Constant Field Values

  - ### TYPE_AUTHTYPE

    public static final int TYPE_AUTHTYPE
    Action type for session authentication type.
    See Also:
      - Constant Field Values

  - ### TYPE_LISTENER

    public static final int TYPE_LISTENER
    Action type for session listener.
    See Also:
      - Constant Field Values

  - ### TYPE_NOTE

    public static final int TYPE_NOTE
    Action type for session note.
    See Also:
      - Constant Field Values

  - ### ACTION_SET

    public static final int ACTION_SET
    Action to set a value.
    See Also:
      - Constant Field Values

  - ### ACTION_REMOVE

    public static final int ACTION_REMOVE
    Action to remove a value.
    See Also:
      - Constant Field Values

  - ### NAME_PRINCIPAL

    public static final String NAME_PRINCIPAL
    Name used for principal actions.
    See Also:
      - Constant Field Values

  - ### NAME_MAXINTERVAL

    public static final String NAME_MAXINTERVAL
    Name used for max inactive interval actions.
    See Also:
      - Constant Field Values

  - ### NAME_ISNEW

    public static final String NAME_ISNEW
    Name used for new flag actions.
    See Also:
      - Constant Field Values

  - ### NAME_AUTHTYPE

    public static final String NAME_AUTHTYPE
    Name used for auth type actions.
    See Also:
      - Constant Field Values

  - ### NAME_LISTENER

    public static final String NAME_LISTENER
    Name used for listener actions.
    See Also:
      - Constant Field Values

- ## Constructor Details

  - ### DeltaRequest

    public DeltaRequest()
    Default constructor required by `Externalizable`.

  - ### DeltaRequest

    public DeltaRequest(String sessionId, boolean recordAllActions)
    Construct a new DeltaRequest.
    Parameters:
      `sessionId` - Session identifier
      `recordAllActions` - Record all actions, including duplicates

- ## Method Details

  - ### setAttribute

    public void setAttribute(String name, Object value)
    Record a set attribute action.
    Parameters:
      `name` - Attribute name
      `value` - Attribute value

  - ### removeAttribute

    public void removeAttribute(String name)
    Record a remove attribute action.
    Parameters:
      `name` - Attribute name

  - ### setNote

    public void setNote(String name, Object value)
    Record a set note action.
    Parameters:
      `name` - Note name
      `value` - Note value

  - ### removeNote

    public void removeNote(String name)
    Record a remove note action.
    Parameters:
      `name` - Note name

  - ### setMaxInactiveInterval

    public void setMaxInactiveInterval(int interval)
    Record a set max inactive interval action.
    Parameters:
      `interval` - Max inactive interval in seconds

  - ### setPrincipal

    public void setPrincipal(Principal p)
    Only support principals from type `GenericPrincipal`
    Parameters:
      `p` - Session principal
    See Also:
      - `GenericPrincipal`

  - ### setNew

    public void setNew(boolean n)
    Record a set new action.
    Parameters:
      `n` - New flag value

  - ### setAuthType

    public void setAuthType(String authType)
    Record a set auth type action.
    Parameters:
      `authType` - Authentication type

  - ### addSessionListener

    public void addSessionListener(SessionListener listener)
    Record an add session listener action.
    Parameters:
      `listener` - Session listener to add

  - ### removeSessionListener

    public void removeSessionListener(SessionListener listener)
    Record a remove session listener action.
    Parameters:
      `listener` - Session listener to remove

  - ### addAction

    protected void addAction(int type, int action, String name, Object value)
    Add an action to the list of actions to be executed.
    Parameters:
      `type` - Action type
      `action` - Action (set or remove)
      `name` - Attribute or property name
      `value` - Attribute or property value

  - ### execute

    public void execute(DeltaSession session, boolean notifyListeners)
    Execute all recorded actions on the given session.
    Parameters:
      `session` - Target session
      `notifyListeners` - Whether to notify session listeners

  - ### reset

    public void reset()
    Reset this request, returning all action objects to the pool.

  - ### getSessionId

    public String getSessionId()
    Get the session identifier.
    Returns:
      Session identifier

  - ### setSessionId

    public void setSessionId(String sessionId)
    Set the session identifier.
    Parameters:
      `sessionId` - Session identifier

  - ### getSize

    public int getSize()
    Get the number of actions recorded.
    Returns:
      Number of actions

  - ### clear

    public void clear()
    Clear all actions and the action pool.

  - ### readExternal

    public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
    Specified by:
      `readExternal` in interface `Externalizable`
    Throws:
      `IOException`
      `ClassNotFoundException`

  - ### writeExternal

    public void writeExternal(ObjectOutput out) throws IOException
    Specified by:
      `writeExternal` in interface `Externalizable`
    Throws:
      `IOException`

  - ### serialize

    protected byte[] serialize() throws IOException
    serialize DeltaRequest
    Returns:
      serialized delta request
    Throws:
      `IOException` - IO error serializing
    See Also:
      - `writeExternal(java.io.ObjectOutput)`