Class DeltaSession

    • Field Detail

      • log

        public static final Log log
      • sm

        protected static final StringManager sm
        The string manager for this package.
      • diffLock

        protected final java.util.concurrent.locks.Lock diffLock
    • Constructor Detail

      • DeltaSession

        public DeltaSession()
      • DeltaSession

        public DeltaSession​(Manager manager)
        Construct a new Session associated with the specified Manager.
        Parameters:
        manager - The manager with which this Session is associated
    • Method Detail

      • createRequest

        protected DeltaRequest createRequest​(java.lang.String sessionId,
                                             boolean recordAllActions)
      • isDirty

        public boolean isDirty()
        Has the object changed since last replication and is not in a locked state
        Specified by:
        isDirty in interface ReplicatedMapEntry
        Returns:
        boolean
      • isDiffable

        public boolean isDiffable()
        If this returns true, the map will extract the diff using getDiff() Otherwise it will serialize the entire object.
        Specified by:
        isDiffable in interface ReplicatedMapEntry
        Returns:
        boolean
      • getDiff

        public byte[] getDiff()
                       throws java.io.IOException
        Returns a diff and sets the dirty map to false
        Specified by:
        getDiff in interface ReplicatedMapEntry
        Returns:
        a serialized view of the difference
        Throws:
        java.io.IOException - IO error serializing
      • getClassLoaders

        public java.lang.ClassLoader[] getClassLoaders()
      • applyDiff

        public void applyDiff​(byte[] diff,
                              int offset,
                              int length)
                       throws java.io.IOException,
                              java.lang.ClassNotFoundException
        Applies a diff to an existing object.
        Specified by:
        applyDiff in 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
      • resetDiff

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

        This implementation is a NO-OP. The diff is reset in getDiff().

        Specified by:
        resetDiff in interface ReplicatedMapEntry
      • lock

        public void lock()
        Lock during serialization

        This implementation is a NO-OP. Any required locking takes place in the methods that make modifications.

        Specified by:
        lock in interface ReplicatedMapEntry
      • unlock

        public void unlock()
        Unlock after serialization

        This implementation is a NO-OP. Any required unlocking takes place in the methods that make modifications.

        Specified by:
        unlock in interface ReplicatedMapEntry
      • setOwner

        public void setOwner​(java.lang.Object owner)
        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 interface ReplicatedMapEntry
        Parameters:
        owner - Object
      • isAccessReplicate

        public boolean isAccessReplicate()
        If this returns true, to replicate that an object has been accessed
        Specified by:
        isAccessReplicate in interface ReplicatedMapEntry
        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.
        Specified by:
        isPrimarySession in interface ClusterSession
        Returns:
        True if this session is primary
      • setPrimarySession

        public void setPrimarySession​(boolean primarySession)
        Sets whether this is the primary session or not.
        Specified by:
        setPrimarySession in interface ClusterSession
        Parameters:
        primarySession - Flag value
      • setId

        public void setId​(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.
        Specified by:
        setId in interface Session
        Overrides:
        setId in class StandardSession
        Parameters:
        id - The new session identifier
        notify - Should any associated listeners be notified that a new session has been created?
      • setId

        public void setId​(java.lang.String id)
        Set the session identifier for this session.
        Specified by:
        setId in interface Session
        Overrides:
        setId in class StandardSession
        Parameters:
        id - The new session identifier
      • setMaxInactiveInterval

        public void setMaxInactiveInterval​(int interval,
                                           boolean addDeltaRequest)
      • setNew

        public void setNew​(boolean isNew)
        Set the isNew flag for this session.
        Specified by:
        setNew in interface Session
        Overrides:
        setNew in class StandardSession
        Parameters:
        isNew - The new value for the isNew flag
      • setNew

        public void setNew​(boolean isNew,
                           boolean addDeltaRequest)
      • setPrincipal

        public void setPrincipal​(java.security.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.
        Specified by:
        setPrincipal in interface Session
        Overrides:
        setPrincipal in class StandardSession
        Parameters:
        principal - The new Principal, or null if none
      • setPrincipal

        public void setPrincipal​(java.security.Principal principal,
                                 boolean addDeltaRequest)
      • setAuthType

        public void setAuthType​(java.lang.String authType)
        Set the authentication type used to authenticate our cached Principal, if any.
        Specified by:
        setAuthType in interface Session
        Overrides:
        setAuthType in class StandardSession
        Parameters:
        authType - The new cached authentication type
      • setAuthType

        public void setAuthType​(java.lang.String authType,
                                boolean addDeltaRequest)
      • isValid

        public boolean isValid()
        Return the isValid flag for this session.
        Specified by:
        isValid in interface Session
        Overrides:
        isValid in class StandardSession
        Returns:
        true if the session is still valid
      • endAccess

        public void endAccess()
        End the access and register to ReplicationValve (crossContext support)
        Specified by:
        endAccess in interface Session
        Overrides:
        endAccess in class StandardSession
      • 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.
        Overrides:
        expire in class StandardSession
        Parameters:
        notify - Should we notify listeners about the demise of this session?
      • expire

        public void expire​(boolean notify,
                           boolean notifyCluster)
      • recycle

        public void recycle()
        Release all object references, and initialize instance variables, in preparation for reuse of this object.
        Specified by:
        recycle in interface Session
        Overrides:
        recycle in class StandardSession
      • toString

        public java.lang.String toString()
        Return a string representation of this object.
        Overrides:
        toString in class StandardSession
      • addSessionListener

        public void addSessionListener​(SessionListener listener,
                                       boolean addDeltaRequest)
      • removeSessionListener

        public void removeSessionListener​(SessionListener listener,
                                          boolean addDeltaRequest)
      • readExternal

        public void readExternal​(java.io.ObjectInput in)
                          throws java.io.IOException,
                                 java.lang.ClassNotFoundException
        Specified by:
        readExternal in interface java.io.Externalizable
        Throws:
        java.io.IOException
        java.lang.ClassNotFoundException
      • readObjectData

        public void readObjectData​(java.io.ObjectInputStream stream)
                            throws java.lang.ClassNotFoundException,
                                   java.io.IOException
        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 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
      • readObjectData

        public void readObjectData​(java.io.ObjectInput stream)
                            throws java.lang.ClassNotFoundException,
                                   java.io.IOException
        Throws:
        java.lang.ClassNotFoundException
        java.io.IOException
      • writeObjectData

        public void writeObjectData​(java.io.ObjectOutputStream stream)
                             throws java.io.IOException
        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 class StandardSession
        Parameters:
        stream - The object output stream to write to
        Throws:
        java.io.IOException - if an input/output error occurs
      • writeObjectData

        public void writeObjectData​(java.io.ObjectOutput stream)
                             throws java.io.IOException
        Throws:
        java.io.IOException
      • resetDeltaRequest

        public void resetDeltaRequest()
      • deserializeAndExecuteDeltaRequest

        protected void deserializeAndExecuteDeltaRequest​(byte[] delta)
                                                  throws java.io.IOException,
                                                         java.lang.ClassNotFoundException
        Throws:
        java.io.IOException
        java.lang.ClassNotFoundException
      • removeAttribute

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

        Overrides:
        removeAttribute in 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
      • removeAttribute

        public void removeAttribute​(java.lang.String name,
                                    boolean notify,
                                    boolean addDeltaRequest)
      • setAttribute

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

        Specified by:
        setAttribute in interface HttpSession
        Overrides:
        setAttribute in 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
      • setAttribute

        public void setAttribute​(java.lang.String name,
                                 java.lang.Object value,
                                 boolean notify,
                                 boolean addDeltaRequest)
      • removeNote

        public void removeNote​(java.lang.String name)
        Description copied from class: StandardSession
        Remove any object bound to the specified name in the internal notes for this session.
        Specified by:
        removeNote in interface Session
        Overrides:
        removeNote in class StandardSession
        Parameters:
        name - Name of the note to be removed
      • removeNote

        public void removeNote​(java.lang.String name,
                               boolean addDeltaRequest)
      • setNote

        public void setNote​(java.lang.String name,
                            java.lang.Object value)
        Description copied from class: StandardSession
        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 interface Session
        Overrides:
        setNote in class StandardSession
        Parameters:
        name - Name to which the object should be bound
        value - Object to be bound to the specified name
      • setNote

        public void setNote​(java.lang.String name,
                            java.lang.Object value,
                            boolean addDeltaRequest)
      • doReadObject

        protected void doReadObject​(java.io.ObjectInputStream stream)
                             throws java.lang.ClassNotFoundException,
                                    java.io.IOException
        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 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
      • writeExternal

        public void writeExternal​(java.io.ObjectOutput out)
                           throws java.io.IOException
        Specified by:
        writeExternal in interface java.io.Externalizable
        Throws:
        java.io.IOException
      • doWriteObject

        protected void doWriteObject​(java.io.ObjectOutputStream stream)
                              throws java.io.IOException
        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.

        Overrides:
        doWriteObject in class StandardSession
        Parameters:
        stream - The output stream to write to
        Throws:
        java.io.IOException - if an input/output error occurs
      • removeAttributeInternal

        protected void removeAttributeInternal​(java.lang.String name,
                                               boolean notify,
                                               boolean addDeltaRequest)
      • 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 interface ReplicatedMapEntry
        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 interface ReplicatedMapEntry
        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 interface ReplicatedMapEntry
        Parameters:
        version - long
      • setAccessCount

        protected void setAccessCount​(int count)