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

# Class SessionMessageImpl

java.lang.Object
org.apache.catalina.ha.ClusterMessageBase
org.apache.catalina.ha.session.SessionMessageImpl

All Implemented Interfaces:
  `Serializable, ClusterMessage, SessionMessage`

public class SessionMessageImpl extends ClusterMessageBase implements SessionMessage
Session cluster message.

See Also:
  - Serialized Form

- ## Field Summary

  ### Fields inherited from class ClusterMessageBase

  `address`

  ### Fields inherited from interface SessionMessage

  `EVT_ALL_SESSION_DATA, EVT_ALL_SESSION_NOCONTEXTMANAGER, EVT_ALL_SESSION_TRANSFERCOMPLETE, EVT_CHANGE_SESSION_ID, EVT_GET_ALL_SESSIONS, EVT_SESSION_ACCESSED, EVT_SESSION_CREATED, EVT_SESSION_DELTA, EVT_SESSION_EXPIRED`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `SessionMessageImpl(String contextName, int eventtype, byte[] session, String sessionID, String uniqueID)`
  Creates a session message.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `String`
  `getContextName()`
  `int`
  `getEventType()`
  returns the event type
  `String`
  `getEventTypeString()`
  Clear text event type name (for logging purpose only).
  `byte[]`
  `getSession()`
  `String`
  `getSessionID()`
  `long`
  `getTimestamp()`
  `String`
  `getUniqueId()`
  `void`
  `setTimestamp(long time)`
  Set message send time but only the first setting works (one shot)
  `String`
  `toString()`

  ### Methods inherited from class ClusterMessageBase

  `getAddress, setAddress`

  ### Methods inherited from class Object

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

  ### Methods inherited from interface ClusterMessage

  `getAddress, setAddress`

- ## Constructor Details

  - ### SessionMessageImpl

    public SessionMessageImpl(String contextName, int eventtype, byte[] session, String sessionID, String uniqueID)
    Creates a session message. Depending on what event type you want this message to represent, you populate the different parameters in the constructor
    The following rules apply dependent on what event type argument you use:
    EVT_SESSION_CREATED
    The parameters: session, sessionID must be set.
    EVT_SESSION_EXPIRED
    The parameters: sessionID must be set.
    EVT_SESSION_ACCESSED
    The parameters: sessionID must be set.
    EVT_GET_ALL_SESSIONS
    get all sessions from one of the nodes.
    EVT_SESSION_DELTA
    Send attribute delta (add,update,remove attribute or principal, ...).
    EVT_ALL_SESSION_DATA
    Send complete serializes session list
    EVT_ALL_SESSION_TRANSFERCOMPLETE
    send that all session state information are transferred after GET_ALL_SESSION received from this sender.
    EVT_CHANGE_SESSION_ID
    send original sessionID and new sessionID.
    EVT_ALL_SESSION_NOCONTEXTMANAGER
    send that context manager does not exist after GET_ALL_SESSION received from this sender.
    Parameters:
      `contextName` - - the name of the context (application
      `eventtype` - - one of the 8 event type defined in this class
      `session` - - the serialized byte array of the session itself
      `sessionID` - - the id that identifies this session
      `uniqueID` - - the id that identifies this message

- ## Method Details

  - ### getEventType

    public int getEventType()
    Description copied from interface: `SessionMessage`
    returns the event type
    Specified by:
      `getEventType` in interface `SessionMessage`
    Returns:
      one of the event types EVT_XXXX

  - ### getSession

    public byte[] getSession()
    Specified by:
      `getSession` in interface `SessionMessage`
    Returns:
      the serialized data for the session

  - ### getSessionID

    public String getSessionID()
    Specified by:
      `getSessionID` in interface `SessionMessage`
    Returns:
      the session ID for the session

  - ### setTimestamp

    public void setTimestamp(long time)
    Set message send time but only the first setting works (one shot)
    Specified by:
      `setTimestamp` in interface `ClusterMessage`
    Overrides:
      `setTimestamp` in class `ClusterMessageBase`
    Parameters:
      `time` - the timestamp

  - ### getTimestamp

    public long getTimestamp()
    Specified by:
      `getTimestamp` in interface `ClusterMessage`
    Overrides:
      `getTimestamp` in class `ClusterMessageBase`
    Returns:
      the message timestamp

  - ### getEventTypeString

    public String getEventTypeString()
    Description copied from interface: `SessionMessage`
    Clear text event type name (for logging purpose only).
    Specified by:
      `getEventTypeString` in interface `SessionMessage`
    Returns:
      the event type in a string representation, useful for debugging

  - ### getContextName

    public String getContextName()
    Specified by:
      `getContextName` in interface `SessionMessage`
    Returns:
      the context name associated with this message

  - ### getUniqueId

    public String getUniqueId()
    Specified by:
      `getUniqueId` in interface `ClusterMessage`
    Returns:
      the unique id of the message

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `Object`