Class DeltaRequest

  • All Implemented Interfaces:
    java.io.Externalizable, java.io.Serializable

    public class DeltaRequest
    extends java.lang.Object
    implements java.io.Externalizable
    This class is used to track the series of actions that happens when a request is executed. These actions will then translate into invocations of methods on the actual session.

    This class is NOT thread safe. One DeltaRequest per session.

    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int ACTION_REMOVE
      Action to remove a value.
      static int ACTION_SET
      Action to set a value.
      static Log log
      The logger for this class.
      static java.lang.String NAME_AUTHTYPE
      Name used for auth type actions.
      static java.lang.String NAME_ISNEW
      Name used for new flag actions.
      static java.lang.String NAME_LISTENER
      Name used for listener actions.
      static java.lang.String NAME_MAXINTERVAL
      Name used for max inactive interval actions.
      static java.lang.String NAME_PRINCIPAL
      Name used for principal actions.
      protected static StringManager sm
      The string manager for this package.
      static int TYPE_ATTRIBUTE
      Action type for session attributes.
      static int TYPE_AUTHTYPE
      Action type for session authentication type.
      static int TYPE_ISNEW
      Action type for session new flag.
      static int TYPE_LISTENER
      Action type for session listener.
      static int TYPE_MAXINTERVAL
      Action type for session max inactive interval.
      static int TYPE_NOTE
      Action type for session note.
      static int TYPE_PRINCIPAL
      Action type for session principal.
    • Constructor Summary

      Constructors 
      Constructor Description
      DeltaRequest()
      Default constructor required by Externalizable.
      DeltaRequest​(java.lang.String sessionId, boolean recordAllActions)
      Construct a new DeltaRequest.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void addAction​(int type, int action, java.lang.String name, java.lang.Object value)
      Add an action to the list of actions to be executed.
      void addSessionListener​(SessionListener listener)
      Record an add session listener action.
      void clear()
      Clear all actions and the action pool.
      void execute​(DeltaSession session, boolean notifyListeners)
      Execute all recorded actions on the given session.
      java.lang.String getSessionId()
      Get the session identifier.
      int getSize()
      Get the number of actions recorded.
      void readExternal​(java.io.ObjectInput in)  
      void removeAttribute​(java.lang.String name)
      Record a remove attribute action.
      void removeNote​(java.lang.String name)
      Record a remove note action.
      void removeSessionListener​(SessionListener listener)
      Record a remove session listener action.
      void reset()
      Reset this request, returning all action objects to the pool.
      protected byte[] serialize()
      serialize DeltaRequest
      void setAttribute​(java.lang.String name, java.lang.Object value)
      Record a set attribute action.
      void setAuthType​(java.lang.String authType)
      Record a set auth type action.
      void setMaxInactiveInterval​(int interval)
      Record a set max inactive interval action.
      void setNew​(boolean n)
      Record a set new action.
      void setNote​(java.lang.String name, java.lang.Object value)
      Record a set note action.
      void setPrincipal​(java.security.Principal p)
      Only support principals from type GenericPrincipal
      void setSessionId​(java.lang.String sessionId)
      Set the session identifier.
      void writeExternal​(java.io.ObjectOutput out)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • log

        public static final Log log
        The logger for this class.
      • sm

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

        public static final int TYPE_ATTRIBUTE
        Action type for session attributes.
        See Also:
        Constant Field Values
      • TYPE_PRINCIPAL

        public static final int TYPE_PRINCIPAL
        Action type for session principal.
        See Also:
        Constant Field Values
      • TYPE_ISNEW

        public static final int TYPE_ISNEW
        Action type for session new flag.
        See Also:
        Constant Field Values
      • TYPE_MAXINTERVAL

        public static final int TYPE_MAXINTERVAL
        Action type for session max inactive interval.
        See Also:
        Constant Field Values
      • TYPE_AUTHTYPE

        public static final int TYPE_AUTHTYPE
        Action type for session authentication type.
        See Also:
        Constant Field Values
      • TYPE_LISTENER

        public static final int TYPE_LISTENER
        Action type for session listener.
        See Also:
        Constant Field Values
      • TYPE_NOTE

        public static final int TYPE_NOTE
        Action type for session note.
        See Also:
        Constant Field Values
      • ACTION_REMOVE

        public static final int ACTION_REMOVE
        Action to remove a value.
        See Also:
        Constant Field Values
      • NAME_PRINCIPAL

        public static final java.lang.String NAME_PRINCIPAL
        Name used for principal actions.
        See Also:
        Constant Field Values
      • NAME_MAXINTERVAL

        public static final java.lang.String NAME_MAXINTERVAL
        Name used for max inactive interval actions.
        See Also:
        Constant Field Values
      • NAME_ISNEW

        public static final java.lang.String NAME_ISNEW
        Name used for new flag actions.
        See Also:
        Constant Field Values
      • NAME_AUTHTYPE

        public static final java.lang.String NAME_AUTHTYPE
        Name used for auth type actions.
        See Also:
        Constant Field Values
      • NAME_LISTENER

        public static final java.lang.String NAME_LISTENER
        Name used for listener actions.
        See Also:
        Constant Field Values
    • Constructor Detail

      • DeltaRequest

        public DeltaRequest()
        Default constructor required by Externalizable.
      • DeltaRequest

        public DeltaRequest​(java.lang.String sessionId,
                            boolean recordAllActions)
        Construct a new DeltaRequest.
        Parameters:
        sessionId - Session identifier
        recordAllActions - Record all actions, including duplicates
    • Method Detail

      • setAttribute

        public void setAttribute​(java.lang.String name,
                                 java.lang.Object value)
        Record a set attribute action.
        Parameters:
        name - Attribute name
        value - Attribute value
      • removeAttribute

        public void removeAttribute​(java.lang.String name)
        Record a remove attribute action.
        Parameters:
        name - Attribute name
      • setNote

        public void setNote​(java.lang.String name,
                            java.lang.Object value)
        Record a set note action.
        Parameters:
        name - Note name
        value - Note value
      • removeNote

        public void removeNote​(java.lang.String name)
        Record a remove note action.
        Parameters:
        name - Note name
      • setMaxInactiveInterval

        public void setMaxInactiveInterval​(int interval)
        Record a set max inactive interval action.
        Parameters:
        interval - Max inactive interval in seconds
      • setPrincipal

        public void setPrincipal​(java.security.Principal p)
        Only support principals from type GenericPrincipal
        Parameters:
        p - Session principal
        See Also:
        GenericPrincipal
      • setNew

        public void setNew​(boolean n)
        Record a set new action.
        Parameters:
        n - New flag value
      • setAuthType

        public void setAuthType​(java.lang.String authType)
        Record a set auth type action.
        Parameters:
        authType - Authentication type
      • addSessionListener

        public void addSessionListener​(SessionListener listener)
        Record an add session listener action.
        Parameters:
        listener - Session listener to add
      • removeSessionListener

        public void removeSessionListener​(SessionListener listener)
        Record a remove session listener action.
        Parameters:
        listener - Session listener to remove
      • addAction

        protected void addAction​(int type,
                                 int action,
                                 java.lang.String name,
                                 java.lang.Object value)
        Add an action to the list of actions to be executed.
        Parameters:
        type - Action type
        action - Action (set or remove)
        name - Attribute or property name
        value - Attribute or property value
      • execute

        public void execute​(DeltaSession session,
                            boolean notifyListeners)
        Execute all recorded actions on the given session.
        Parameters:
        session - Target session
        notifyListeners - Whether to notify session listeners
      • reset

        public void reset()
        Reset this request, returning all action objects to the pool.
      • getSessionId

        public java.lang.String getSessionId()
        Get the session identifier.
        Returns:
        Session identifier
      • setSessionId

        public void setSessionId​(java.lang.String sessionId)
        Set the session identifier.
        Parameters:
        sessionId - Session identifier
      • getSize

        public int getSize()
        Get the number of actions recorded.
        Returns:
        Number of actions
      • clear

        public void clear()
        Clear all actions and the action pool.
      • 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
      • writeExternal

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

        protected byte[] serialize()
                            throws java.io.IOException
        serialize DeltaRequest
        Returns:
        serialized delta request
        Throws:
        java.io.IOException - IO error serializing
        See Also:
        writeExternal(java.io.ObjectOutput)