Class SimpleSessionHandler

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

    public class SimpleSessionHandler
    extends BasicHandler
    This handler uses SOAP headers to do simple session management.

    Essentially, you install it on both the request and response chains of your service, on both the client and the server side.

    ON THE SERVER:

    • The REQUEST is checked for a session ID header. If present, we look up the correct SimpleSession. If not, we create a new session. In either case, we install the session into the MessageContext, and put its ID in the SESSION_ID property.
    • The RESPONSE gets a session ID header tacked on, assuming we found a SESSION_ID property in the MessageContext.

    ON THE CLIENT:

    • The RESPONSE messages are checked for session ID headers. If present, we pull the ID out and insert it into an option in the AxisClient. This works because a given Call object is associated with a single AxisClient. However, we might want to find a way to put it into the Call object itself, which would make a little more sense. This would mean being able to get to the Call from the MC, i.e. adding a getCall() API (which would only work on the client side)....
    • When REQUESTS are generated, we look to see if an ID option is present in the AxisClient associated with the MessageContext. If so, we insert a session ID header with the appropriate ID.

    SimpleSessions are "reaped" periodically via a very simplistic mechanism. Each time the handler is invoke()d we check to see if more than reapPeriodicity milliseconds have elapsed since the last reap. If so, we walk the collection of active Sessions, and for each one, if it hasn't been "touched" (i.e. had a getProperty() or setProperty() performed) in longer than its timeout, we remove it from the collection.

    Author:
    Glen Daniels (gdaniels@apache.org)
    See Also:
    Serialized Form
    • Field Detail

      • log

        protected static org.apache.commons.logging.Log log
      • SESSION_LOCALPART

        public static final java.lang.String SESSION_LOCALPART
        See Also:
        Constant Field Values
      • sessionHeaderName

        public static final QName sessionHeaderName
    • Constructor Detail

      • SimpleSessionHandler

        public SimpleSessionHandler()
    • Method Detail

      • invoke

        public void invoke​(MessageContext context)
                    throws AxisFault
        Process a MessageContext.
        Parameters:
        context - the MessageContext to process with this Handler.
        Throws:
        AxisFault - if the handler encounters an error
      • setReapPeriodicity

        public void setReapPeriodicity​(long reapTime)
        Set the reaper periodicity in SECONDS Convenience method for testing. !!! TODO: Should be able to set this via options on the Handler or perhaps the engine.
      • setDefaultSessionTimeout

        public void setDefaultSessionTimeout​(int defaultSessionTimeout)
        Set the default session timeout in SECONDS Again, for testing.