KickJava   Java API By Example, From Geeks To Geeks.

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


1 package org.sapia.soto.state.cocoon;
2
3 import org.apache.cocoon.environment.http.HttpRequest;
4
5 import org.apache.commons.lang.ClassUtils;
6
7 import org.sapia.soto.Debug;
8 import org.sapia.soto.state.Result;
9 import org.sapia.soto.state.helpers.CompositeStep;
10
11
12 /**
13  * @author Yanick Duchesne
14  * <dl>
15  * <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>
16  * <dt><b>License:</b><dd>Read the license.txt file of the jar or visit the
17  * <a HREF="http://www.sapia-oss.org/license.html">license page</a> at the Sapia OSS web site</dd></dt>
18  * </dl>
19  */

20 public class IfNotSession extends CompositeStep {
21   public IfNotSession() {
22   }
23
24   /**
25    * @see org.sapia.soto.state.Step#getName()
26    */

27   public String JavaDoc getName() {
28     return ClassUtils.getShortClassName(getClass());
29   }
30
31   /**
32    * @see org.sapia.soto.state.helpers.CompositeStep#doExecute(org.sapia.soto.state.Result)
33    */

34   protected boolean doExecute(Result res) {
35     HttpRequest req = (HttpRequest) ((CocoonContext) res.getContext()).getRequest();
36     boolean exists = req.getSession(false) != null;
37
38     if (Debug.DEBUG) {
39       Debug.debug("Session exists: " + exists);
40     }
41
42     return !exists;
43   }
44 }
45
Popular Tags