KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > sapia > soto > state > cocoon > RequestScope


1 package org.sapia.soto.state.cocoon;
2
3 import org.apache.cocoon.environment.Request;
4
5 import org.sapia.soto.state.Scope;
6
7
8 /**
9  * Implements the <code>Scope</code> interface over a Cocoon <code>Request</code>.
10  *
11  * @author Yanick Duchesne
12  * <dl>
13  * <dt><b>Copyright:</b><dd>Copyright &#169; 2002-2003 <a HREF="http://www.sapia-oss.org">Sapia Open Source Software</a>. All Rights Reserved.</dd></dt>
14  * <dt><b>License:</b><dd>Read the license.txt file of the jar or visit the
15  * <a HREF="http://www.sapia-oss.org/license.html">license page</a> at the Sapia OSS web site</dd></dt>
16  * </dl>
17  */

18 public class RequestScope implements Scope {
19   public static final String JavaDoc CONTEXT_PATH_KEY = "contextPath";
20   private Request _req;
21
22   /**
23    * Constructs an instance of this class that wraps the given request.
24    * @param req a <code>Request</code>.
25    */

26   public RequestScope(Request req) {
27     _req = req;
28     _req.setAttribute(CONTEXT_PATH_KEY, req.getContextPath());
29   }
30
31   /**
32    * @see org.sapia.soto.state.Scope#getVal(java.lang.Object)
33    */

34   public Object JavaDoc getVal(Object JavaDoc key) {
35     return _req.getAttribute(key.toString());
36   }
37
38   /**
39    * @see org.sapia.soto.state.Scope#putVal(java.lang.Object, java.lang.Object)
40    */

41   public void putVal(Object JavaDoc key, Object JavaDoc value) {
42     _req.setAttribute(key.toString(), value);
43   }
44
45   /**
46    * @return the <code>Request</code> wrapped by this instance.
47    */

48   public Request getRequest() {
49     return _req;
50   }
51 }
52
Popular Tags