You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by di...@apache.org on 2002/03/03 14:30:39 UTC

cvs commit: jakarta-commons/latka/src/java/org/apache/commons/latka/xml SessionHandler.java

dion        02/03/03 05:30:39

  Modified:    latka/src/java/org/apache/commons/latka/xml
                        SessionHandler.java
  Log:
  Javadocs
  
  Revision  Changes    Path
  1.12      +88 -81    jakarta-commons/latka/src/java/org/apache/commons/latka/xml/SessionHandler.java
  
  Index: SessionHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/latka/src/java/org/apache/commons/latka/xml/SessionHandler.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- SessionHandler.java	7 Feb 2002 06:25:00 -0000	1.11
  +++ SessionHandler.java	3 Mar 2002 13:30:39 -0000	1.12
  @@ -3,7 +3,7 @@
    *
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 1999 The Apache Software Foundation.  All rights 
  + * Copyright (c) 1999 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -11,7 +11,7 @@
    * are met:
    *
    * 1. Redistributions of source code must retain the above copyright
  - *    notice, this list of conditions and the following disclaimer. 
  + *    notice, this list of conditions and the following disclaimer.
    *
    * 2. Redistributions in binary form must reproduce the above copyright
    *    notice, this list of conditions and the following disclaimer in
  @@ -19,15 +19,15 @@
    *    distribution.
    *
    * 3. The end-user documentation included with the redistribution, if
  - *    any, must include the following acknowlegement:  
  - *       "This product includes software developed by the 
  + *    any, must include the following acknowlegement:
  + *       "This product includes software developed by the
    *        Apache Software Foundation (http://www.apache.org/)."
    *    Alternately, this acknowlegement may appear in the software itself,
    *    if and wherever such third-party acknowlegements normally appear.
    *
    * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
    *    Foundation" must not be used to endorse or promote products derived
  - *    from this software without prior written permission. For written 
  + *    from this software without prior written permission. For written
    *    permission, please contact apache@apache.org.
    *
    * 5. Products derived from this software may not be called "Apache"
  @@ -55,7 +55,7 @@
    *
    * [Additional notices, if required by prior licensing conditions]
    *
  - */   
  + */
   
   package org.apache.commons.latka.xml;
   
  @@ -75,85 +75,92 @@
    *
    * @author Morgan Delagrange
    * @author dIon Gillard
  - * @version $Id: SessionHandler.java,v 1.11 2002/02/07 06:25:00 dion Exp $
  + * @version $Id: SessionHandler.java,v 1.12 2002/03/03 13:30:39 dion Exp $
    */
   public class SessionHandler extends LatkaHandler {
  -  protected LatkaEventInfo _listener = null;
  -
  -  protected SessionImpl _session = null;
  -
  -  // session cache
  -  protected Map _sessionCache = null;
  -
  -  protected static Category _log =
  -    Category.getInstance(SessionHandler.class);
  -
  -  public SessionHandler(XMLReader reader, LatkaEventInfo listener,
  -                        Map sessionCache) {
  -    super(reader);
  -    _listener = listener;
  -    // the suite handler class is responsible for storing
  -    // the session cache
  -    _sessionCache = sessionCache;
  -    log.debug("session handler instantiated");
  -  }
  -
  -  public void startElement(String uri, String localName,
  -                           String qName, Attributes atts)
  -  throws SAXException {
  -
  -    if (localName.equals("session")) {
  -      _session = generateSession(atts);
  -    } else if (localName.equals("request")) {
  -        RequestHandler handler = null;
  -        if (_listener.didSessionSucceed(_session) == false) {
  -            handler =
  -              new RequestHandler(_reader, _session,
  -                                 _listener, true);
  -        } else {
  -            handler =
  -              new RequestHandler(_reader, _session,
  -                                 _listener);
  -        }
  -        handler.delegate(uri, localName, qName, atts);
  +    /** listener to receive events as they occurr*/
  +    protected LatkaEventInfo _listener = null;
  +    /** the http session*/
  +    protected SessionImpl _session = null;
  +    
  +    /** session cache */
  +    protected Map _sessionCache = null;
  +    /** log4j category to append data to */
  +    protected static Category _log = Category.getInstance(SessionHandler.class);
  +    
  +    /**
  +     * @param reader source of XML data
  +     * @param listener to broadcast events to
  +     * @param sessionCache sessions shared between handlers
  +     */
  +    public SessionHandler(XMLReader reader, LatkaEventInfo listener,
  +                           Map sessionCache) {
  +        super(reader);
  +        _listener = listener;
  +        // the suite handler class is responsible for storing
  +        // the session cache
  +        _sessionCache = sessionCache;
  +        log.debug("session handler instantiated");
       }
  -  }
  -
  -  public void endElement(String namespaceURI, String localName,
  -                         String rawName) {
  -    if (localName.equals("session")) {
  -      release();
  +    
  +    public void startElement(String uri, String localName, String qName,
  +                             Attributes atts) throws SAXException {
  +        if (localName.equals("session")) {
  +            _session = generateSession(atts);
  +        } else if (localName.equals("request")) {
  +            RequestHandler handler = null;
  +            if (_listener.didSessionSucceed(_session) == false) {
  +                handler = new RequestHandler(_reader, _session, _listener, true);
  +            } else {
  +                handler = new RequestHandler(_reader, _session, _listener);
  +            }
  +            handler.delegate(uri, localName, qName, atts);
  +        }
       }
  -
  -  }
  -
  -
  -  /**
  -   * Checks the session_id and returns a cached SessionImpl
  -   * if the id has been used previously
  -   *
  -   * @param atts   Attributes of the "session" element
  -   * @return A SessionImpl object
  -   */
  -  protected SessionImpl generateSession(Attributes atts) {
  -
  -    String sessionId = atts.getValue("sessionId");
  -    if (sessionId == null) {
  -      _log.debug("generating new session with no session id");
  -      return new SessionImpl();
  +    
  +    /**
  +     * Process an end session tag by releasing resources
  +     * @param namespaceURI - The Namespace URI, or the empty string if the
  +     *      element has no Namespace URI or if Namespace processing is not 
  +     *      being performed
  +     * @param localName - The local name (without prefix), or the empty string
  +     *      if Namespace processing is not being performed
  +     * @param rawName - The qualified XML 1.0 name (with prefix), or the empty
  +     *      string if qualified names are not available
  +     */
  +    public void endElement(String namespaceURI, String localName, 
  +                           String rawName) {
  +        if (localName.equals("session")) {
  +            release();
  +        }
       }
  -
  -    SessionImpl cachedSession = (SessionImpl) _sessionCache.get(sessionId);
  -    if (cachedSession != null) {
  -      _log.debug("returning cached session: " + sessionId);
  -      return cachedSession;
  +    
  +    
  +    /**
  +     * Checks the session_id and returns a cached SessionImpl
  +     * if the id has been used previously
  +     *
  +     * @param atts   Attributes of the "session" element
  +     * @return A SessionImpl object
  +     */
  +    protected SessionImpl generateSession(Attributes atts) {
  +        
  +        String sessionId = atts.getValue("sessionId");
  +        if (sessionId == null) {
  +            _log.debug("generating new session with no session id");
  +            return new SessionImpl();
  +        }
  +        
  +        SessionImpl cachedSession = (SessionImpl) _sessionCache.get(sessionId);
  +        if (cachedSession != null) {
  +            _log.debug("returning cached session: " + sessionId);
  +            return cachedSession;
  +        }
  +        
  +        SessionImpl session = new SessionImpl();
  +        _log.debug("generating new session with id: " + sessionId);
  +        _sessionCache.put(sessionId, session);
  +        return session;
       }
  -
  -    SessionImpl session = new SessionImpl();
  -    _log.debug("generating new session with id: " + sessionId);
  -    _sessionCache.put(sessionId, session);
  -    return session;
  -
  -  }
  -
  +    
   }
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>