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:
  • 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:
    • TYPE_PRINCIPAL

      public static final int TYPE_PRINCIPAL
      Action type for session principal.
      See Also:
    • TYPE_ISNEW

      public static final int TYPE_ISNEW
      Action type for session new flag.
      See Also:
    • TYPE_MAXINTERVAL

      public static final int TYPE_MAXINTERVAL
      Action type for session max inactive interval.
      See Also:
    • TYPE_AUTHTYPE

      public static final int TYPE_AUTHTYPE
      Action type for session authentication type.
      See Also:
    • TYPE_LISTENER

      public static final int TYPE_LISTENER
      Action type for session listener.
      See Also:
    • TYPE_NOTE

      public static final int TYPE_NOTE
      Action type for session note.
      See Also:
    • ACTION_SET

      public static final int ACTION_SET
      Action to set a value.
      See Also:
    • ACTION_REMOVE

      public static final int ACTION_REMOVE
      Action to remove a value.
      See Also:
    • NAME_PRINCIPAL

      public static final String NAME_PRINCIPAL
      Name used for principal actions.
      See Also:
    • NAME_MAXINTERVAL

      public static final String NAME_MAXINTERVAL
      Name used for max inactive interval actions.
      See Also:
    • NAME_ISNEW

      public static final String NAME_ISNEW
      Name used for new flag actions.
      See Also:
    • NAME_AUTHTYPE

      public static final String NAME_AUTHTYPE
      Name used for auth type actions.
      See Also:
    • NAME_LISTENER

      public static final String NAME_LISTENER
      Name used for listener actions.
      See Also:
  • 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:
    • 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: