Class DeltaSession
- All Implemented Interfaces:
HttpSession
,Externalizable
,Serializable
,ClusterSession
,Session
,ReplicatedMapEntry
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionprotected final Lock
static final Log
protected static final StringManager
The string manager for this package.Fields inherited from class org.apache.catalina.session.StandardSession
accessCount, activityCheck, attributes, authType, creationTime, EMPTY_ARRAY, expiring, facade, id, isNew, isValid, lastAccessAtStart, lastAccessedTime, listeners, manager, maxInactiveInterval, notes, principal, support, thisAccessedTime
Fields inherited from interface org.apache.catalina.Session
SESSION_ACTIVATED_EVENT, SESSION_CREATED_EVENT, SESSION_DESTROYED_EVENT, SESSION_PASSIVATED_EVENT
-
Constructor Summary
ConstructorDescriptionDeltaSession
(Manager manager) Construct a new Session associated with the specified Manager. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Access to an existing object.void
addSessionListener
(SessionListener listener) Add a session event listener to this component.void
addSessionListener
(SessionListener listener, boolean addDeltaRequest) void
applyDiff
(byte[] diff, int offset, int length) Applies a diff to an existing object.protected DeltaRequest
createRequest
(String sessionId, boolean recordAllActions) protected void
deserializeAndExecuteDeltaRequest
(byte[] delta) protected void
doReadObject
(ObjectInputStream stream) Read a serialized version of this session object from the specified object input stream.protected void
doWriteObject
(ObjectOutputStream stream) Write a serialized version of this session object to the specified object output stream.void
End access to the session.void
expire
(boolean notify) Perform the internal processing required to invalidate this session, without triggering an exception if the session has already expired.void
expire
(boolean notify, boolean notifyCluster) Deprecated.Unused.byte[]
getDiff()
Returns a diff and sets the dirty map to falselong
long
For accuracy checking, a serialized attribute can contain a version number This number increases as modifications are made to the data.boolean
If this returns true, to replicate that an object has been accessedboolean
If this returns true, the map will extract the diff using getDiff() Otherwise it will serialize the entire object.boolean
isDirty()
Has the object changed since last replication and is not in a locked stateboolean
returns true if this session is the primary session, if that is the case, the manager can expire it upon timeout.boolean
isValid()
void
lock()
Lock during serializationvoid
void
readObjectData
(ObjectInput stream) void
readObjectData
(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.void
recycle()
Release all object references, and initialize instance variables, in preparation for reuse of this object.void
removeAttribute
(String name, boolean notify) Remove the object bound with the specified name from this session.void
removeAttribute
(String name, boolean notify, boolean addDeltaRequest) protected void
removeAttributeInternal
(String name, boolean notify, boolean addDeltaRequest) void
removeNote
(String name) Remove any object bound to the specified name in the internal notes for this session.void
removeNote
(String name, boolean addDeltaRequest) void
removeSessionListener
(SessionListener listener) Remove a session event listener from this component.void
removeSessionListener
(SessionListener listener, boolean addDeltaRequest) void
void
Resets the current diff state and resets the dirty flagprotected void
setAccessCount
(int count) void
setAttribute
(String name, Object value) Binds an object to this session, using the name specified.void
setAttribute
(String name, Object value, boolean notify, boolean addDeltaRequest) void
setAuthType
(String authType) Set the authentication type used to authenticate our cached Principal, if any.void
setAuthType
(String authType, boolean addDeltaRequest) void
Set the session identifier for this session and notifies any associated listeners that a new session has been created.void
Set the session identifier for this session and optionally notifies any associated listeners that a new session has been created.void
setLastTimeReplicated
(long lastTimeReplicated) Set the last replicate time.void
setMaxInactiveInterval
(int interval) Specifies the time, in seconds, between client requests before the servlet container will invalidate this session.void
setMaxInactiveInterval
(int interval, boolean addDeltaRequest) void
setNew
(boolean isNew) Set theisNew
flag for this session.void
setNew
(boolean isNew, boolean addDeltaRequest) void
Bind an object to a specified name in the internal notes associated with this session, replacing any existing binding for this name.void
void
This method is called after the object has been created on a remote map.void
setPrimarySession
(boolean primarySession) Sets whether this is the primary session or not.void
setPrincipal
(Principal principal) Set the authenticated Principal that is associated with this Session.void
setPrincipal
(Principal principal, boolean addDeltaRequest) void
setVersion
(long version) Forces a certain version to a replicated map entrytoString()
void
unlock()
Unlock after serializationvoid
void
writeObjectData
(ObjectOutput stream) void
writeObjectData
(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.StandardSession
access, 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, tellNew
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface jakarta.servlet.http.HttpSession
getAttribute, getAttributeNames, getCreationTime, getId, getLastAccessedTime, getMaxInactiveInterval, getServletContext, invalidate, isNew, removeAttribute
Methods inherited from interface org.apache.catalina.Session
access, 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
-
sm
The string manager for this package. -
diffLock
-
-
Constructor Details
-
DeltaSession
public DeltaSession() -
DeltaSession
Construct a new Session associated with the specified Manager.- Parameters:
manager
- The manager with which this Session is associated
-
-
Method Details
-
createRequest
-
isDirty
public boolean isDirty()Description copied from interface:ReplicatedMapEntry
Has the object changed since last replication and is not in a locked state- Specified by:
isDirty
in interfaceReplicatedMapEntry
- Returns:
- boolean
-
isDiffable
public boolean isDiffable()Description copied from interface:ReplicatedMapEntry
If this returns true, the map will extract the diff using getDiff() Otherwise it will serialize the entire object.- Specified by:
isDiffable
in interfaceReplicatedMapEntry
- Returns:
- boolean
-
getDiff
Description copied from interface:ReplicatedMapEntry
Returns a diff and sets the dirty map to false- Specified by:
getDiff
in interfaceReplicatedMapEntry
- Returns:
- Serialized diff data
- Throws:
IOException
- IO error serializing
-
getClassLoaders
-
applyDiff
public void applyDiff(byte[] diff, int offset, int length) throws IOException, ClassNotFoundException Description copied from interface:ReplicatedMapEntry
Applies a diff to an existing object.- Specified by:
applyDiff
in interfaceReplicatedMapEntry
- Parameters:
diff
- Serialized diff dataoffset
- Array offsetlength
- Array length- Throws:
IOException
- IO error deserializingClassNotFoundException
- Serialization error
-
resetDiff
public 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:
resetDiff
in interfaceReplicatedMapEntry
-
lock
public void lock()Lock during serializationThis implementation is a NO-OP. Any required locking takes place in the methods that make modifications.
- Specified by:
lock
in interfaceReplicatedMapEntry
-
unlock
public void unlock()Unlock after serializationThis implementation is a NO-OP. Any required unlocking takes place in the methods that make modifications.
- Specified by:
unlock
in interfaceReplicatedMapEntry
-
setOwner
Description copied from interface:ReplicatedMapEntry
This 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:
setOwner
in interfaceReplicatedMapEntry
- Parameters:
owner
- Object
-
isAccessReplicate
public boolean isAccessReplicate()Description copied from interface:ReplicatedMapEntry
If this returns true, to replicate that an object has been accessed- Specified by:
isAccessReplicate
in interfaceReplicatedMapEntry
- Returns:
- boolean
-
accessEntry
public void accessEntry()Description copied from interface:ReplicatedMapEntry
Access to an existing object.- Specified by:
accessEntry
in interfaceReplicatedMapEntry
-
isPrimarySession
public boolean isPrimarySession()Description copied from interface:ClusterSession
returns true if this session is the primary session, if that is the case, the manager can expire it upon timeout.- Specified by:
isPrimarySession
in interfaceClusterSession
- Returns:
- True if this session is primary
-
setPrimarySession
public void setPrimarySession(boolean primarySession) Description copied from interface:ClusterSession
Sets whether this is the primary session or not.- Specified by:
setPrimarySession
in interfaceClusterSession
- Parameters:
primarySession
- Flag value
-
setId
Description copied from interface:Session
Set the session identifier for this session and optionally notifies any associated listeners that a new session has been created.- Specified by:
setId
in interfaceSession
- Overrides:
setId
in classStandardSession
- Parameters:
id
- The new session identifiernotify
- Should any associated listeners be notified that a new session has been created?
-
setId
Description copied from interface:Session
Set the session identifier for this session and notifies any associated listeners that a new session has been created.- Specified by:
setId
in interfaceSession
- Overrides:
setId
in classStandardSession
- Parameters:
id
- The new session identifier
-
setMaxInactiveInterval
public void setMaxInactiveInterval(int interval) Description copied from interface:jakarta.servlet.http.HttpSession
Specifies the time, in seconds, between client requests before the servlet container will invalidate this session. A zero or negative time indicates that the session should never timeout.- Specified by:
setMaxInactiveInterval
in interfaceHttpSession
- Specified by:
setMaxInactiveInterval
in interfaceSession
- Overrides:
setMaxInactiveInterval
in classStandardSession
- Parameters:
interval
- An integer specifying the number of seconds
-
setMaxInactiveInterval
public void setMaxInactiveInterval(int interval, boolean addDeltaRequest) -
setNew
public void setNew(boolean isNew) Description copied from interface:Session
Set theisNew
flag for this session.- Specified by:
setNew
in interfaceSession
- Overrides:
setNew
in classStandardSession
- Parameters:
isNew
- The new value for theisNew
flag
-
setNew
public void setNew(boolean isNew, boolean addDeltaRequest) -
setPrincipal
Description copied from interface:Session
Set the authenticated Principal that is associated with this Session. This provides anAuthenticator
with a means to cache a previously authenticated Principal, and avoid potentially expensiveRealm.authenticate()
calls on every request.- Specified by:
setPrincipal
in interfaceSession
- Overrides:
setPrincipal
in classStandardSession
- Parameters:
principal
- The new Principal, ornull
if none
-
setPrincipal
-
setAuthType
Description copied from interface:Session
Set the authentication type used to authenticate our cached Principal, if any.- Specified by:
setAuthType
in interfaceSession
- Overrides:
setAuthType
in classStandardSession
- Parameters:
authType
- The new cached authentication type
-
setAuthType
-
isValid
public boolean isValid()- Specified by:
isValid
in interfaceSession
- Overrides:
isValid
in classStandardSession
- Returns:
true
if the session is still valid
-
endAccess
public void endAccess()Description copied from interface:Session
End access to the session.- Specified by:
endAccess
in interfaceSession
- Overrides:
endAccess
in classStandardSession
-
expire
public void expire(boolean notify) Description copied from class:StandardSession
Perform the internal processing required to invalidate this session, without triggering an exception if the session has already expired.- Overrides:
expire
in classStandardSession
- Parameters:
notify
- Should we notify listeners about the demise of this session?
-
expire
public void expire(boolean notify, boolean notifyCluster) -
recycle
public void recycle()Description copied from interface:Session
Release all object references, and initialize instance variables, in preparation for reuse of this object.- Specified by:
recycle
in interfaceSession
- Overrides:
recycle
in classStandardSession
-
toString
- Overrides:
toString
in classStandardSession
-
addSessionListener
Description copied from interface:Session
Add a session event listener to this component.- Specified by:
addSessionListener
in interfaceSession
- Overrides:
addSessionListener
in classStandardSession
- Parameters:
listener
- the SessionListener instance that should be notified for session events
-
addSessionListener
-
removeSessionListener
Description copied from interface:Session
Remove a session event listener from this component.- Specified by:
removeSessionListener
in interfaceSession
- Overrides:
removeSessionListener
in classStandardSession
- Parameters:
listener
- remove the session listener, which will no longer be notified
-
removeSessionListener
-
readExternal
- Specified by:
readExternal
in interfaceExternalizable
- Throws:
IOException
ClassNotFoundException
-
readObjectData
Description copied from class:StandardSession
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.- Overrides:
readObjectData
in classStandardSession
- Parameters:
stream
- The object input stream to read from- Throws:
ClassNotFoundException
- if an unknown class is specifiedIOException
- if an input/output error occurs
-
readObjectData
- Throws:
ClassNotFoundException
IOException
-
writeObjectData
Description copied from class:StandardSession
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.- Overrides:
writeObjectData
in classStandardSession
- Parameters:
stream
- The object output stream to write to- Throws:
IOException
- if an input/output error occurs
-
writeObjectData
- Throws:
IOException
-
resetDeltaRequest
public void resetDeltaRequest() -
getDeltaRequest
Deprecated.Unused. This method will be removed in Tomcat 12.Get the request.- Returns:
- the request
-
deserializeAndExecuteDeltaRequest
protected void deserializeAndExecuteDeltaRequest(byte[] delta) throws IOException, ClassNotFoundException - Throws:
IOException
ClassNotFoundException
-
removeAttribute
Description copied from class:StandardSession
Remove 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:
removeAttribute
in classStandardSession
- Parameters:
name
- Name of the object to remove from this session.notify
- Should we notify interested listeners that this attribute is being removed?
-
removeAttribute
-
setAttribute
Description copied from interface:jakarta.servlet.http.HttpSession
Binds an object to this session, using the name specified. If an object of the same name is already bound to the session, the object is replaced.After this method executes, and if the new object implements
HttpSessionBindingListener
, the container callsHttpSessionBindingListener.valueBound
. The container then notifies anyHttpSessionAttributeListener
s in the web application.If an object was already bound to this session of this name that implements
HttpSessionBindingListener
, itsHttpSessionBindingListener.valueUnbound
method is called.If the value passed in is null, this has the same effect as calling
removeAttribute()
.- Specified by:
setAttribute
in interfaceHttpSession
- Overrides:
setAttribute
in classStandardSession
- Parameters:
name
- the name to which the object is bound; cannot be nullvalue
- the object to be bound
-
setAttribute
-
removeNote
Description copied from interface:Session
Remove any object bound to the specified name in the internal notes for this session.- Specified by:
removeNote
in interfaceSession
- Overrides:
removeNote
in classStandardSession
- Parameters:
name
- Name of the note to be removed
-
removeNote
-
setNote
Description copied from interface:Session
Bind an object to a specified name in the internal notes associated with this session, replacing any existing binding for this name.- Specified by:
setNote
in interfaceSession
- Overrides:
setNote
in classStandardSession
- Parameters:
name
- Name to which the object should be boundvalue
- Object to be bound to the specified name
-
setNote
-
doReadObject
Description copied from class:StandardSession
Read 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:
doReadObject
in classStandardSession
- Parameters:
stream
- The input stream to read from- Throws:
ClassNotFoundException
- if an unknown class is specifiedIOException
- if an input/output error occurs
-
writeExternal
- Specified by:
writeExternal
in interfaceExternalizable
- Throws:
IOException
-
doWriteObject
Description copied from class:StandardSession
Write 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
distributable
property of the associated Manager is set totrue
.- Overrides:
doWriteObject
in classStandardSession
- Parameters:
stream
- The output stream to write to- Throws:
IOException
- if an input/output error occurs
-
removeAttributeInternal
-
getLastTimeReplicated
public long getLastTimeReplicated()- Specified by:
getLastTimeReplicated
in interfaceReplicatedMapEntry
- Returns:
- the last replicate time.
-
getVersion
public long getVersion()Description copied from interface:ReplicatedMapEntry
For 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:
getVersion
in interfaceReplicatedMapEntry
- Returns:
- long - the version number or -1 if the data is not versioned
-
setLastTimeReplicated
public void setLastTimeReplicated(long lastTimeReplicated) Description copied from interface:ReplicatedMapEntry
Set the last replicate time.- Specified by:
setLastTimeReplicated
in interfaceReplicatedMapEntry
- Parameters:
lastTimeReplicated
- New timestamp
-
setVersion
public void setVersion(long version) Description copied from interface:ReplicatedMapEntry
Forces a certain version to a replicated map entry- Specified by:
setVersion
in interfaceReplicatedMapEntry
- Parameters:
version
- long
-
setAccessCount
protected void setAccessCount(int count)
-