org.apache.catalina.ha.session

Class DeltaSession

public class DeltaSession extends StandardSession implements Externalizable, ClusterSession, ReplicatedMapEntry

Similar to the StandardSession except that this session will keep track of deltas during a request.

Version: $Revision: 896383 $ $Date: 2010-01-06 11:51:53 +0100 (Wed, 06 Jan 2010) $

Author: Filip Hanik

Field Summary
protected LockdiffLock
static Loglog
protected static StringManagersm
The string manager for this package.
Constructor Summary
DeltaSession()
Construct a new Session associated with the specified Manager.
DeltaSession(Manager manager)
Method Summary
voidapplyDiff(byte[] diff, int offset, int length)
Applies a diff to an existing object.
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)
protected ObjectgetAttributeInternal(String name)
Return the value of an attribute without a check for validity.
ClassLoader[]getClassLoaders()
DeltaRequestgetDeltaRequest()
byte[]getDiff()
Returns a diff and sets the dirty map to false
longgetLastAccessedTimeInternal()
Return the last client access time without invalidation check
protected longgetLastTimeReplicated()
longgetVersion()
booleanisDiffable()
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 state
booleanisPrimarySession()
returns true if this session is the primary session, if that is the case, the manager can expire it upon timeout.
booleanisValid()
Return the isValid flag for this session.
voidlock()
Lock during serialization
voidreadExternal(ObjectInput in)
voidreadObjectData(ObjectInput stream)
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)
voidresetDeltaRequest()
voidresetDiff()
Resets the current diff state and resets the dirty flag
protected 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)
voidsetId(String id)
Set the session identifier for this session.
voidsetIdInternal(String id)
Set the session identifier for this session without notify listeners.
protected voidsetLastTimeReplicated(long lastTimeReplicated)
voidsetMaxInactiveInterval(int interval)
voidsetMaxInactiveInterval(int interval, boolean addDeltaRequest)
voidsetNew(boolean isNew)
Set the isNew flag for this session.
voidsetNew(boolean isNew, boolean addDeltaRequest)
voidsetOwner(Object owner)
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)
StringtoString()
Return a string representation of this object.
voidunlock()
Unlock after serialization
voidwriteExternal(ObjectOutput out)
protected voidwriteObject(ObjectOutputStream stream)
Write a serialized version of this session object to the specified object output stream.
voidwriteObjectData(ObjectOutput stream)

Field Detail

diffLock

protected final Lock diffLock

log

public static Log log

sm

protected static StringManager sm
The string manager for this package.

Constructor Detail

DeltaSession

public DeltaSession()
Construct a new Session associated with the specified Manager.

Parameters: manager The manager with which this Session is associated

DeltaSession

public DeltaSession(Manager manager)

Method Detail

applyDiff

public void applyDiff(byte[] diff, int offset, int length)
Applies a diff to an existing object.

Parameters: diff byte[] offset int length int

Throws: IOException

endAccess

public void endAccess()
End the access and register to ReplicationValve (crossContext support)

expire

public void expire(boolean notify)
Perform the internal processing required to invalidate this session, without triggering an exception if the session has already expired.

Parameters: notify Should we notify listeners about the demise of this session?

expire

public void expire(boolean notify, boolean notifyCluster)

getAttributeInternal

protected Object getAttributeInternal(String name)
Return the value of an attribute without a check for validity.

getClassLoaders

public ClassLoader[] getClassLoaders()

getDeltaRequest

public DeltaRequest getDeltaRequest()

getDiff

public byte[] getDiff()
Returns a diff and sets the dirty map to false

Returns: byte[]

Throws: IOException

getLastAccessedTimeInternal

public long getLastAccessedTimeInternal()
Return the last client access time without invalidation check

See Also: .

getLastTimeReplicated

protected long getLastTimeReplicated()

getVersion

public long getVersion()

isDiffable

public boolean isDiffable()
If this returns true, the map will extract the diff using getDiff() Otherwise it will serialize the entire object.

Returns: boolean

isDirty

public boolean isDirty()
Has the object changed since last replication and is not in a locked state

Returns: boolean

isPrimarySession

public boolean isPrimarySession()
returns true if this session is the primary session, if that is the case, the manager can expire it upon timeout.

isValid

public boolean isValid()
Return the isValid flag for this session.

lock

public void lock()
Lock during serialization

readExternal

public void readExternal(ObjectInput in)

readObjectData

public void readObjectData(ObjectInput stream)

recycle

public void recycle()
Release all object references, and initialize instance variables, in preparation for reuse of this object.

removeAttribute

public void removeAttribute(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 calls valueUnbound() on the object.

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

public void removeAttribute(String name, boolean notify, boolean addDeltaRequest)

removeAttributeInternal

protected void removeAttributeInternal(String name, boolean notify, boolean addDeltaRequest)

resetDeltaRequest

public void resetDeltaRequest()

resetDiff

public void resetDiff()
Resets the current diff state and resets the dirty flag

setAccessCount

protected void setAccessCount(int count)

setAttribute

public void setAttribute(String name, 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 calls valueBound() on the object.

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

public void setAttribute(String name, Object value, boolean notify, boolean addDeltaRequest)

setId

public void setId(String id)
Set the session identifier for this session.

Parameters: id The new session identifier

setIdInternal

public void setIdInternal(String id)
Set the session identifier for this session without notify listeners.

Parameters: id The new session identifier

setLastTimeReplicated

protected void setLastTimeReplicated(long lastTimeReplicated)

setMaxInactiveInterval

public void setMaxInactiveInterval(int interval)

setMaxInactiveInterval

public void setMaxInactiveInterval(int interval, boolean addDeltaRequest)

setNew

public void setNew(boolean isNew)
Set the isNew flag for this session.

Parameters: isNew The new value for the isNew flag

setNew

public void setNew(boolean isNew, boolean addDeltaRequest)

setOwner

public void setOwner(Object owner)

setPrimarySession

public void setPrimarySession(boolean primarySession)
Sets whether this is the primary session or not.

Parameters: primarySession Flag value

setPrincipal

public void setPrincipal(Principal principal)
Set the authenticated Principal that is associated with this Session. This provides an Authenticator with a means to cache a previously authenticated Principal, and avoid potentially expensive Realm.authenticate() calls on every request.

Parameters: principal The new Principal, or null if none

setPrincipal

public void setPrincipal(Principal principal, boolean addDeltaRequest)

setVersion

public void setVersion(long version)

toString

public String toString()
Return a string representation of this object.

unlock

public void unlock()
Unlock after serialization

writeExternal

public void writeExternal(ObjectOutput out)

writeObject

protected void writeObject(ObjectOutputStream stream)
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 to true.

Parameters: stream The output stream to write to

Throws: IOException if an input/output error occurs

writeObjectData

public void writeObjectData(ObjectOutput stream)
Copyright © 2000-2011 Apache Software Foundation. All Rights Reserved.