View Javadoc

    1   package org.codehaus.xfire.transport.http;
    2
    3   import javax.servlet.http.HttpServletRequest;
    4   import javax.servlet.http.HttpSession;
    5
    6   import org.codehaus.xfire.transport.Session;
    7
    8   /***
    9    * The default servlet session implementation.
    10   *
    11   * @author <a href="mailto:dan@envoisolutions.com">Dan Diephouse</a>
    12   */
    13  public class XFireHttpSession
    14      implements Session
    15  {
    16      public final static String HTTP_SERVLET_REQUEST_KEY = "xfire.httpServletRequest";
    17
    18      private HttpServletRequest request;
    19
    20      private HttpSession session;
    21
    22  	public XFireHttpSession( HttpServletRequest request )
    23      {
    24          this.request = request;
    25      }
    26
    27  	/***
    28  	 * @see org.codehaus.xfire.transport.Session#get(java.lang.Object)
    29  	 */
    30  	public Object get(Object key)
    31  	{
    32  		return getSession().getAttribute((String)key);
    33  	}
    34
    35  	/***
    36  	 * @see org.codehaus.xfire.transport.Session#put(java.lang.Object, java.lang.Object)
    37  	 */
    38  	public void put(Object key, Object value)
    39  	{
    40  		getSession().setAttribute((String)key, value);
    41  	}
    42
    43      public HttpSession getSession()
    44      {
    45      	if ( session == null )
    46          {
    47      		session = request.getSession();
    48          }
    49
    50          return session;
    51      }
    52  }