View Javadoc

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