Class DeltaSession
- All Implemented Interfaces:
- HttpSession,- Externalizable,- Serializable,- ClusterSession,- Session,- ReplicatedMapEntry
- See Also:
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected final Lockstatic final Logprotected static final StringManagerThe string manager for this package.Fields inherited from class org.apache.catalina.session.StandardSessionaccessCount, activityCheck, attributes, authType, creationTime, EMPTY_ARRAY, expiring, facade, id, isNew, isValid, lastAccessAtStart, lastAccessedTime, listeners, manager, maxInactiveInterval, notes, principal, support, thisAccessedTimeFields inherited from interface org.apache.catalina.SessionSESSION_ACTIVATED_EVENT, SESSION_CREATED_EVENT, SESSION_DESTROYED_EVENT, SESSION_PASSIVATED_EVENT
- 
Constructor SummaryConstructorsConstructorDescriptionDeltaSession(Manager manager) Construct a new Session associated with the specified Manager.
- 
Method SummaryModifier and TypeMethodDescriptionvoidAccess to an existing object.voidaddSessionListener(SessionListener listener) Add a session event listener to this component.voidaddSessionListener(SessionListener listener, boolean addDeltaRequest) voidapplyDiff(byte[] diff, int offset, int length) Applies a diff to an existing object.protected DeltaRequestcreateRequest(String sessionId, boolean recordAllActions) protected voiddeserializeAndExecuteDeltaRequest(byte[] delta) protected voiddoReadObject(ObjectInputStream stream) Read a serialized version of this session object from the specified object input stream.protected voiddoWriteObject(ObjectOutputStream stream) Write a serialized version of this session object to the specified object output stream.voidEnd the access and register to ReplicationValve (crossContext support)voidexpire(boolean notify) Perform the internal processing required to invalidate this session, without triggering an exception if the session has already expired.voidexpire(boolean notify, boolean notifyCluster) Deprecated.Unused.byte[]getDiff()Returns a diff and sets the dirty map to falselonglongFor accuracy checking, a serialized attribute can contain a version number This number increases as modifications are made to the data.booleanIf this returns true, to replicate that an object has been accessedbooleanIf this returns true, the map will extract the diff using getDiff() Otherwise it will serialize the entire object.booleanisDirty()Has the object changed since last replication and is not in a locked statebooleanreturns true if this session is the primary session, if that is the case, the manager can expire it upon timeout.booleanisValid()Return theisValidflag for this session.voidlock()Lock during serializationvoidvoidreadObjectData(ObjectInput stream) voidreadObjectData(ObjectInputStream stream) Read a serialized version of the contents of this session object from the specified object input stream, without requiring that the StandardSession itself have been serialized.voidrecycle()Release all object references, and initialize instance variables, in preparation for reuse of this object.voidremoveAttribute(String name, boolean notify) Remove the object bound with the specified name from this session.voidremoveAttribute(String name, boolean notify, boolean addDeltaRequest) protected voidremoveAttributeInternal(String name, boolean notify, boolean addDeltaRequest) voidremoveNote(String name) Remove any object bound to the specified name in the internal notes for this session.voidremoveNote(String name, boolean addDeltaRequest) voidremoveSessionListener(SessionListener listener) Remove a session event listener from this component.voidremoveSessionListener(SessionListener listener, boolean addDeltaRequest) voidvoidResets the current diff state and resets the dirty flagprotected voidsetAccessCount(int count) voidsetAttribute(String name, Object value) Bind an object to this session, using the specified name.voidsetAttribute(String name, Object value, boolean notify, boolean addDeltaRequest) voidsetAuthType(String authType) Set the authentication type used to authenticate our cached Principal, if any.voidsetAuthType(String authType, boolean addDeltaRequest) voidSet the session identifier for this session.voidSet the session identifier for this session and optionally notifies any associated listeners that a new session has been created.voidsetLastTimeReplicated(long lastTimeReplicated) Set the last replicate time.voidsetMaxInactiveInterval(int interval) Set the maximum time interval, in seconds, between client requests before the servlet container will invalidate the session.voidsetMaxInactiveInterval(int interval, boolean addDeltaRequest) voidsetNew(boolean isNew) Set theisNewflag for this session.voidsetNew(boolean isNew, boolean addDeltaRequest) voidBind an object to a specified name in the internal notes associated with this session, replacing any existing binding for this name.voidvoidThis method is called after the object has been created on a remote map.voidsetPrimarySession(boolean primarySession) Sets whether this is the primary session or not.voidsetPrincipal(Principal principal) Set the authenticated Principal that is associated with this Session.voidsetPrincipal(Principal principal, boolean addDeltaRequest) voidsetVersion(long version) Forces a certain version to a replicated map entrytoString()Return a string representation of this object.voidunlock()Unlock after serializationvoidvoidwriteObjectData(ObjectOutput stream) voidwriteObjectData(ObjectOutputStream stream) Write a serialized version of the contents of this session object to the specified object output stream, without requiring that the StandardSession itself have been serialized.Methods inherited from class org.apache.catalina.session.StandardSessionaccess, activate, exclude, expire, fireSessionEvent, getAttribute, getAttributeNames, getAuthType, getCreationTime, getCreationTimeInternal, getId, getIdInternal, getIdleTime, getIdleTimeInternal, getLastAccessedTime, getLastAccessedTimeInternal, getManager, getMaxInactiveInterval, getNote, getNoteNames, getPrincipal, getServletContext, getSession, getThisAccessedTime, getThisAccessedTimeInternal, invalidate, isAttributeDistributable, isNew, isValidInternal, keys, passivate, removeAttribute, removeAttributeInternal, setAttribute, setCreationTime, setManager, setValid, tellChangedSessionId, tellNewMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface jakarta.servlet.http.HttpSessiongetAttribute, getAttributeNames, getCreationTime, getId, getLastAccessedTime, getMaxInactiveInterval, getServletContext, invalidate, isNew, removeAttributeMethods inherited from interface org.apache.catalina.Sessionaccess, expire, getAuthType, getCreationTime, getCreationTimeInternal, getId, getIdInternal, getIdleTime, getIdleTimeInternal, getLastAccessedTime, getLastAccessedTimeInternal, getManager, getMaxInactiveInterval, getNote, getNoteNames, getPrincipal, getSession, getThisAccessedTime, getThisAccessedTimeInternal, isAttributeDistributable, setCreationTime, setManager, setValid, tellChangedSessionId
- 
Field Details- 
log
- 
smThe string manager for this package.
- 
diffLock
 
- 
- 
Constructor Details- 
DeltaSessionpublic DeltaSession()
- 
DeltaSessionConstruct a new Session associated with the specified Manager.- Parameters:
- manager- The manager with which this Session is associated
 
 
- 
- 
Method Details- 
createRequest
- 
isDirtypublic boolean isDirty()Has the object changed since last replication and is not in a locked state- Specified by:
- isDirtyin interface- ReplicatedMapEntry
- Returns:
- boolean
 
- 
isDiffablepublic boolean isDiffable()If this returns true, the map will extract the diff using getDiff() Otherwise it will serialize the entire object.- Specified by:
- isDiffablein interface- ReplicatedMapEntry
- Returns:
- boolean
 
- 
getDiffReturns a diff and sets the dirty map to false- Specified by:
- getDiffin interface- ReplicatedMapEntry
- Returns:
- a serialized view of the difference
- Throws:
- IOException- IO error serializing
 
- 
getClassLoaders
- 
applyDiffpublic void applyDiff(byte[] diff, int offset, int length) throws IOException, ClassNotFoundException Applies a diff to an existing object.- Specified by:
- applyDiffin interface- ReplicatedMapEntry
- Parameters:
- diff- Serialized diff data
- offset- Array offset
- length- Array length
- Throws:
- IOException- IO error deserializing
- ClassNotFoundException- Serialization error
 
- 
resetDiffpublic void resetDiff()Resets the current diff state and resets the dirty flagThis implementation is a NO-OP. The diff is reset in getDiff().- Specified by:
- resetDiffin interface- ReplicatedMapEntry
 
- 
lockpublic void lock()Lock during serializationThis implementation is a NO-OP. Any required locking takes place in the methods that make modifications. - Specified by:
- lockin interface- ReplicatedMapEntry
 
- 
unlockpublic void unlock()Unlock after serializationThis implementation is a NO-OP. Any required unlocking takes place in the methods that make modifications. - Specified by:
- unlockin interface- ReplicatedMapEntry
 
- 
setOwnerDescription copied from interface:ReplicatedMapEntryThis method is called after the object has been created on a remote map. On this method, the object can initialize itself for any data that wasn't- Specified by:
- setOwnerin interface- ReplicatedMapEntry
- Parameters:
- owner- Object
 
- 
isAccessReplicatepublic boolean isAccessReplicate()If this returns true, to replicate that an object has been accessed- Specified by:
- isAccessReplicatein interface- ReplicatedMapEntry
- Returns:
- boolean
 
- 
accessEntrypublic void accessEntry()Access to an existing object.- Specified by:
- accessEntryin interface- ReplicatedMapEntry
 
- 
isPrimarySessionpublic boolean isPrimarySession()returns true if this session is the primary session, if that is the case, the manager can expire it upon timeout.- Specified by:
- isPrimarySessionin interface- ClusterSession
- Returns:
- True if this session is primary
 
- 
setPrimarySessionpublic void setPrimarySession(boolean primarySession) Sets whether this is the primary session or not.- Specified by:
- setPrimarySessionin interface- ClusterSession
- Parameters:
- primarySession- Flag value
 
- 
setIdDescription copied from interface:SessionSet the session identifier for this session and optionally notifies any associated listeners that a new session has been created.- Specified by:
- setIdin interface- Session
- Overrides:
- setIdin class- StandardSession
- Parameters:
- id- The new session identifier
- notify- Should any associated listeners be notified that a new session has been created?
 
- 
setIdSet the session identifier for this session.- Specified by:
- setIdin interface- Session
- Overrides:
- setIdin class- StandardSession
- Parameters:
- id- The new session identifier
 
- 
setMaxInactiveIntervalpublic void setMaxInactiveInterval(int interval) Description copied from class:StandardSessionSet the maximum time interval, in seconds, between client requests before the servlet container will invalidate the session. A zero or negative time indicates that the session should never time out.- Specified by:
- setMaxInactiveIntervalin interface- HttpSession
- Specified by:
- setMaxInactiveIntervalin interface- Session
- Overrides:
- setMaxInactiveIntervalin class- StandardSession
- Parameters:
- interval- The new maximum interval
 
- 
setMaxInactiveIntervalpublic void setMaxInactiveInterval(int interval, boolean addDeltaRequest) 
- 
setNewpublic void setNew(boolean isNew) Set theisNewflag for this session.- Specified by:
- setNewin interface- Session
- Overrides:
- setNewin class- StandardSession
- Parameters:
- isNew- The new value for the- isNewflag
 
- 
setNewpublic void setNew(boolean isNew, boolean addDeltaRequest) 
- 
setPrincipalSet the authenticated Principal that is associated with this Session. This provides anAuthenticatorwith a means to cache a previously authenticated Principal, and avoid potentially expensiveRealm.authenticate()calls on every request.- Specified by:
- setPrincipalin interface- Session
- Overrides:
- setPrincipalin class- StandardSession
- Parameters:
- principal- The new Principal, or- nullif none
 
- 
setPrincipal
- 
setAuthTypeSet the authentication type used to authenticate our cached Principal, if any.- Specified by:
- setAuthTypein interface- Session
- Overrides:
- setAuthTypein class- StandardSession
- Parameters:
- authType- The new cached authentication type
 
- 
setAuthType
- 
isValidpublic boolean isValid()Return theisValidflag for this session.- Specified by:
- isValidin interface- Session
- Overrides:
- isValidin class- StandardSession
- Returns:
- trueif the session is still valid
 
- 
endAccesspublic void endAccess()End the access and register to ReplicationValve (crossContext support)- Specified by:
- endAccessin interface- Session
- Overrides:
- endAccessin class- StandardSession
 
- 
expirepublic void expire(boolean notify) Perform the internal processing required to invalidate this session, without triggering an exception if the session has already expired.- Overrides:
- expirein class- StandardSession
- Parameters:
- notify- Should we notify listeners about the demise of this session?
 
- 
expirepublic void expire(boolean notify, boolean notifyCluster) 
- 
recyclepublic void recycle()Release all object references, and initialize instance variables, in preparation for reuse of this object.- Specified by:
- recyclein interface- Session
- Overrides:
- recyclein class- StandardSession
 
- 
toStringReturn a string representation of this object.- Overrides:
- toStringin class- StandardSession
 
- 
addSessionListenerDescription copied from class:StandardSessionAdd a session event listener to this component.- Specified by:
- addSessionListenerin interface- Session
- Overrides:
- addSessionListenerin class- StandardSession
- Parameters:
- listener- the SessionListener instance that should be notified for session events
 
- 
addSessionListener
- 
removeSessionListenerDescription copied from class:StandardSessionRemove a session event listener from this component.- Specified by:
- removeSessionListenerin interface- Session
- Overrides:
- removeSessionListenerin class- StandardSession
- Parameters:
- listener- remove the session listener, which will no longer be notified
 
- 
removeSessionListener
- 
readExternal- Specified by:
- readExternalin interface- Externalizable
- Throws:
- IOException
- ClassNotFoundException
 
- 
readObjectDataRead a serialized version of the contents of this session object from the specified object input stream, without requiring that the StandardSession itself have been serialized.- Overrides:
- readObjectDatain class- StandardSession
- Parameters:
- stream- The object input stream to read from
- Throws:
- ClassNotFoundException- if an unknown class is specified
- IOException- if an input/output error occurs
 
- 
readObjectData- Throws:
- ClassNotFoundException
- IOException
 
- 
writeObjectDataWrite a serialized version of the contents of this session object to the specified object output stream, without requiring that the StandardSession itself have been serialized.- Overrides:
- writeObjectDatain class- StandardSession
- Parameters:
- stream- The object output stream to write to
- Throws:
- IOException- if an input/output error occurs
 
- 
writeObjectData- Throws:
- IOException
 
- 
resetDeltaRequestpublic void resetDeltaRequest()
- 
getDeltaRequestDeprecated.Unused. This method will be removed in Tomcat 12.Get the request.- Returns:
- the request
 
- 
deserializeAndExecuteDeltaRequestprotected void deserializeAndExecuteDeltaRequest(byte[] delta) throws IOException, ClassNotFoundException - Throws:
- IOException
- ClassNotFoundException
 
- 
removeAttributeRemove the object bound with the specified name from this session. If the session does not have an object bound with this name, this method does nothing.After this method executes, and if the object implements HttpSessionBindingListener, the container callsvalueUnbound()on the object.- Overrides:
- removeAttributein class- StandardSession
- Parameters:
- name- Name of the object to remove from this session.
- notify- Should we notify interested listeners that this attribute is being removed?
- Throws:
- IllegalStateException- if this method is called on an invalidated session
 
- 
removeAttribute
- 
setAttributeBind an object to this session, using the specified name. If an object of the same name is already bound to this session, the object is replaced.After this method executes, and if the object implements HttpSessionBindingListener, the container callsvalueBound()on the object.- Specified by:
- setAttributein interface- HttpSession
- Overrides:
- setAttributein class- StandardSession
- Parameters:
- name- Name to which the object is bound, cannot be null
- value- Object to be bound, cannot be null
- Throws:
- IllegalArgumentException- if an attempt is made to add a non-serializable object in an environment marked distributable.
- IllegalStateException- if this method is called on an invalidated session
 
- 
setAttribute
- 
removeNoteDescription copied from class:StandardSessionRemove any object bound to the specified name in the internal notes for this session.- Specified by:
- removeNotein interface- Session
- Overrides:
- removeNotein class- StandardSession
- Parameters:
- name- Name of the note to be removed
 
- 
removeNote
- 
setNoteDescription copied from class:StandardSessionBind an object to a specified name in the internal notes associated with this session, replacing any existing binding for this name.- Specified by:
- setNotein interface- Session
- Overrides:
- setNotein class- StandardSession
- Parameters:
- name- Name to which the object should be bound
- value- Object to be bound to the specified name
 
- 
setNote
- 
doReadObjectRead a serialized version of this session object from the specified object input stream.IMPLEMENTATION NOTE : The reference to the owning Manager is not restored by this method, and must be set explicitly. - Overrides:
- doReadObjectin class- StandardSession
- Parameters:
- stream- The input stream to read from
- Throws:
- ClassNotFoundException- if an unknown class is specified
- IOException- if an input/output error occurs
 
- 
writeExternal- Specified by:
- writeExternalin interface- Externalizable
- Throws:
- IOException
 
- 
doWriteObjectWrite a serialized version of this session object to the specified object output stream.IMPLEMENTATION NOTE : The owning Manager will not be stored in the serialized representation of this Session. After calling readObject(), you must set the associated Manager explicitly.IMPLEMENTATION NOTE : Any attribute that is not Serializable will be unbound from the session, with appropriate actions if it implements HttpSessionBindingListener. If you do not want any such attributes, be sure the distributableproperty of the associated Manager is set totrue.- Overrides:
- doWriteObjectin class- StandardSession
- Parameters:
- stream- The output stream to write to
- Throws:
- IOException- if an input/output error occurs
 
- 
removeAttributeInternal
- 
getLastTimeReplicatedpublic long getLastTimeReplicated()- Specified by:
- getLastTimeReplicatedin interface- ReplicatedMapEntry
- Returns:
- the last replicate time.
 
- 
getVersionpublic long getVersion()Description copied from interface:ReplicatedMapEntryFor accuracy checking, a serialized attribute can contain a version number This number increases as modifications are made to the data. The replicated map can use this to ensure accuracy on a periodic basis- Specified by:
- getVersionin interface- ReplicatedMapEntry
- Returns:
- long - the version number or -1 if the data is not versioned
 
- 
setLastTimeReplicatedpublic void setLastTimeReplicated(long lastTimeReplicated) Description copied from interface:ReplicatedMapEntrySet the last replicate time.- Specified by:
- setLastTimeReplicatedin interface- ReplicatedMapEntry
- Parameters:
- lastTimeReplicated- New timestamp
 
- 
setVersionpublic void setVersion(long version) Description copied from interface:ReplicatedMapEntryForces a certain version to a replicated map entry- Specified by:
- setVersionin interface- ReplicatedMapEntry
- Parameters:
- version- long
 
- 
setAccessCountprotected void setAccessCount(int count) 
 
-