Class DeltaSession
- java.lang.Object
- 
- org.apache.catalina.session.StandardSession
- 
- org.apache.catalina.ha.session.DeltaSession
 
 
- 
- All Implemented Interfaces:
- java.io.Externalizable,- java.io.Serializable,- HttpSession,- ClusterSession,- Session,- ReplicatedMapEntry
 
 public class DeltaSession extends StandardSession implements java.io.Externalizable, ClusterSession, ReplicatedMapEntry Similar to the StandardSession except that this session will keep track of deltas during a request.- See Also:
- Serialized Form
 
- 
- 
Field SummaryFields Modifier and Type Field Description protected java.util.concurrent.locks.LockdiffLockstatic Loglogprotected static StringManagersmThe string manager for this package.- 
Fields inherited from class org.apache.catalina.session.StandardSessionaccessCount, ACTIVITY_CHECK, attributes, authType, creationTime, EMPTY_ARRAY, expiring, facade, id, isNew, isValid, LAST_ACCESS_AT_START, lastAccessedTime, listeners, manager, maxInactiveInterval, notes, principal, sessionContext, STRICT_SERVLET_COMPLIANCE, support, thisAccessedTime
 - 
Fields inherited from interface org.apache.catalina.SessionSESSION_ACTIVATED_EVENT, SESSION_CREATED_EVENT, SESSION_DESTROYED_EVENT, SESSION_PASSIVATED_EVENT
 
- 
 - 
Constructor SummaryConstructors Constructor Description DeltaSession()DeltaSession(Manager manager)Construct a new Session associated with the specified Manager.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaccessEntry()Access 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(java.lang.String sessionId, boolean recordAllActions)protected voiddeserializeAndExecuteDeltaRequest(byte[] delta)protected voiddoReadObject(java.io.ObjectInputStream stream)Read a serialized version of this session object from the specified object input stream.protected voiddoWriteObject(java.io.ObjectOutputStream stream)Write a serialized version of this session object to the specified object output stream.voidendAccess()End 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)java.lang.ClassLoader[]getClassLoaders()DeltaRequestgetDeltaRequest()byte[]getDiff()Returns a diff and sets the dirty map to falselonggetLastTimeReplicated()longgetVersion()For accuracy checking, a serialized attribute can contain a version number This number increases as modifications are made to the data.booleanisAccessReplicate()If this returns true, to replicate that an object has been accessedbooleanisDiffable()If 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 statebooleanisPrimarySession()returns 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 serializationvoidreadExternal(java.io.ObjectInput in)voidreadObjectData(java.io.ObjectInput stream)voidreadObjectData(java.io.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(java.lang.String name, boolean notify)Remove the object bound with the specified name from this session.voidremoveAttribute(java.lang.String name, boolean notify, boolean addDeltaRequest)protected voidremoveAttributeInternal(java.lang.String name, boolean notify, boolean addDeltaRequest)voidremoveNote(java.lang.String name)Remove any object bound to the specified name in the internal notes for this session.voidremoveNote(java.lang.String name, boolean addDeltaRequest)voidremoveSessionListener(SessionListener listener)Remove a session event listener from this component.voidremoveSessionListener(SessionListener listener, boolean addDeltaRequest)voidresetDeltaRequest()voidresetDiff()Resets the current diff state and resets the dirty flagprotected voidsetAccessCount(int count)voidsetAttribute(java.lang.String name, java.lang.Object value)Bind an object to this session, using the specified name.voidsetAttribute(java.lang.String name, java.lang.Object value, boolean notify, boolean addDeltaRequest)voidsetAuthType(java.lang.String authType)Set the authentication type used to authenticate our cached Principal, if any.voidsetAuthType(java.lang.String authType, boolean addDeltaRequest)voidsetId(java.lang.String id)Set the session identifier for this session.voidsetId(java.lang.String id, boolean notify)Set 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)voidsetNote(java.lang.String name, java.lang.Object value)Bind an object to a specified name in the internal notes associated with this session, replacing any existing binding for this name.voidsetNote(java.lang.String name, java.lang.Object value, boolean addDeltaRequest)voidsetOwner(java.lang.Object owner)This 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(java.security.Principal principal)Set the authenticated Principal that is associated with this Session.voidsetPrincipal(java.security.Principal principal, boolean addDeltaRequest)voidsetVersion(long version)Forces a certain version to a replicated map entryjava.lang.StringtoString()Return a string representation of this object.voidunlock()Unlock after serializationvoidwriteExternal(java.io.ObjectOutput out)voidwriteObjectData(java.io.ObjectOutput stream)voidwriteObjectData(java.io.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, getSessionContext, getThisAccessedTime, getThisAccessedTimeInternal, getValue, getValueNames, invalidate, isAttributeDistributable, isNew, isValidInternal, keys, passivate, putValue, removeAttribute, removeAttributeInternal, removeValue, setAttribute, setCreationTime, setManager, setValid, tellChangedSessionId, tellNew
 - 
Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 - 
Methods inherited from interface javax.servlet.http.HttpSessiongetAttribute, getAttributeNames, getCreationTime, getId, getLastAccessedTime, getMaxInactiveInterval, getServletContext, getSessionContext, getValue, getValueNames, invalidate, isNew, putValue, removeAttribute, removeValue
 - 
Methods 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 Detail- 
logpublic static final Log log 
 - 
smprotected static final StringManager sm The string manager for this package.
 - 
diffLockprotected final java.util.concurrent.locks.Lock diffLock 
 
- 
 - 
Constructor Detail- 
DeltaSessionpublic DeltaSession() 
 - 
DeltaSessionpublic DeltaSession(Manager manager) Construct a new Session associated with the specified Manager.- Parameters:
- manager- The manager with which this Session is associated
 
 
- 
 - 
Method Detail- 
createRequestprotected DeltaRequest createRequest(java.lang.String sessionId, boolean recordAllActions) 
 - 
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
 
 - 
getDiffpublic byte[] getDiff() throws java.io.IOExceptionReturns a diff and sets the dirty map to false- Specified by:
- getDiffin interface- ReplicatedMapEntry
- Returns:
- a serialized view of the difference
- Throws:
- java.io.IOException- IO error serializing
 
 - 
getClassLoaderspublic java.lang.ClassLoader[] getClassLoaders() 
 - 
applyDiffpublic void applyDiff(byte[] diff, int offset, int length) throws java.io.IOException, java.lang.ClassNotFoundExceptionApplies a diff to an existing object.- Specified by:
- applyDiffin interface- ReplicatedMapEntry
- Parameters:
- diff- Serialized diff data
- offset- Array offset
- length- Array length
- Throws:
- java.io.IOException- IO error deserializing
- java.lang.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
 
 - 
setOwnerpublic void setOwner(java.lang.Object owner) Description 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
 
 - 
setIdpublic void setId(java.lang.String id, boolean notify)Description 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?
 
 - 
setIdpublic void setId(java.lang.String id) Set 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)
 - 
setPrincipalpublic void setPrincipal(java.security.Principal principal) Set 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
 
 - 
setPrincipalpublic void setPrincipal(java.security.Principal principal, boolean addDeltaRequest)
 - 
setAuthTypepublic void setAuthType(java.lang.String authType) Set 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
 
 - 
setAuthTypepublic void setAuthType(java.lang.String authType, boolean addDeltaRequest)
 - 
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
 
 - 
toStringpublic java.lang.String toString() Return a string representation of this object.- Overrides:
- toStringin class- StandardSession
 
 - 
addSessionListenerpublic void addSessionListener(SessionListener listener) Description 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
 
 - 
addSessionListenerpublic void addSessionListener(SessionListener listener, boolean addDeltaRequest) 
 - 
removeSessionListenerpublic void removeSessionListener(SessionListener listener) Description 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
 
 - 
removeSessionListenerpublic void removeSessionListener(SessionListener listener, boolean addDeltaRequest) 
 - 
readExternalpublic void readExternal(java.io.ObjectInput in) throws java.io.IOException, java.lang.ClassNotFoundException- Specified by:
- readExternalin interface- java.io.Externalizable
- Throws:
- java.io.IOException
- java.lang.ClassNotFoundException
 
 - 
readObjectDatapublic void readObjectData(java.io.ObjectInputStream stream) throws java.lang.ClassNotFoundException, java.io.IOExceptionRead 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:
- java.lang.ClassNotFoundException- if an unknown class is specified
- java.io.IOException- if an input/output error occurs
 
 - 
readObjectDatapublic void readObjectData(java.io.ObjectInput stream) throws java.lang.ClassNotFoundException, java.io.IOException- Throws:
- java.lang.ClassNotFoundException
- java.io.IOException
 
 - 
writeObjectDatapublic void writeObjectData(java.io.ObjectOutputStream stream) throws java.io.IOExceptionWrite 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:
- java.io.IOException- if an input/output error occurs
 
 - 
writeObjectDatapublic void writeObjectData(java.io.ObjectOutput stream) throws java.io.IOException- Throws:
- java.io.IOException
 
 - 
resetDeltaRequestpublic void resetDeltaRequest() 
 - 
getDeltaRequestpublic DeltaRequest getDeltaRequest() 
 - 
deserializeAndExecuteDeltaRequestprotected void deserializeAndExecuteDeltaRequest(byte[] delta) throws java.io.IOException, java.lang.ClassNotFoundException- Throws:
- java.io.IOException
- java.lang.ClassNotFoundException
 
 - 
removeAttributepublic void removeAttribute(java.lang.String name, boolean notify)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:
- 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:
- java.lang.IllegalStateException- if this method is called on an invalidated session
 
 - 
removeAttributepublic void removeAttribute(java.lang.String name, boolean notify, boolean addDeltaRequest)
 - 
setAttributepublic void setAttribute(java.lang.String name, java.lang.Object value)Bind 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:
- java.lang.IllegalArgumentException- if an attempt is made to add a non-serializable object in an environment marked distributable.
- java.lang.IllegalStateException- if this method is called on an invalidated session
 
 - 
setAttributepublic void setAttribute(java.lang.String name, java.lang.Object value, boolean notify, boolean addDeltaRequest)
 - 
removeNotepublic void removeNote(java.lang.String name) Description 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
 
 - 
removeNotepublic void removeNote(java.lang.String name, boolean addDeltaRequest)
 - 
setNotepublic void setNote(java.lang.String name, java.lang.Object value)Description 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
 
 - 
setNotepublic void setNote(java.lang.String name, java.lang.Object value, boolean addDeltaRequest)
 - 
doReadObjectprotected void doReadObject(java.io.ObjectInputStream stream) throws java.lang.ClassNotFoundException, java.io.IOExceptionRead 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:
- java.lang.ClassNotFoundException- if an unknown class is specified
- java.io.IOException- if an input/output error occurs
 
 - 
writeExternalpublic void writeExternal(java.io.ObjectOutput out) throws java.io.IOException- Specified by:
- writeExternalin interface- java.io.Externalizable
- Throws:
- java.io.IOException
 
 - 
doWriteObjectprotected void doWriteObject(java.io.ObjectOutputStream stream) throws java.io.IOExceptionWrite 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:
- java.io.IOException- if an input/output error occurs
 
 - 
removeAttributeInternalprotected void removeAttributeInternal(java.lang.String name, boolean notify, boolean addDeltaRequest)
 - 
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) 
 
- 
 
-