cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject cvs commit: xml-cocoon2/src/org/apache/cocoon/transformation TraxTransformer.java
Date Tue, 13 Nov 2001 07:36:24 GMT
cziegeler    01/11/12 23:36:24

  Modified:    src/org/apache/cocoon/transformation TraxTransformer.java
  Log:
  [Patch] session-info for TraxTransformer
  Submitted by: Jörn Heid [heid@fh-heilbronn.de]
  
  Revision  Changes    Path
  1.36      +39 -1     xml-cocoon2/src/org/apache/cocoon/transformation/TraxTransformer.java
  
  Index: TraxTransformer.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/transformation/TraxTransformer.java,v
  retrieving revision 1.35
  retrieving revision 1.36
  diff -u -r1.35 -r1.36
  --- TraxTransformer.java	2001/11/06 10:48:48	1.35
  +++ TraxTransformer.java	2001/11/13 07:36:24	1.36
  @@ -25,6 +25,7 @@
   import org.apache.cocoon.caching.TimeStampCacheValidity;
   import org.apache.cocoon.components.browser.Browser;
   import org.apache.cocoon.components.xslt.XSLTProcessor;
  +import org.apache.cocoon.environment.Session;
   import org.apache.cocoon.environment.Cookie;
   import org.apache.cocoon.environment.Request;
   import org.apache.cocoon.environment.Source;
  @@ -49,6 +50,7 @@
    * &lt;map:transformer name="xslt" src="org.apache.cocoon.transformation.TraxTransformer"&gt;<br>
    *   &lt;use-request-parameters&gt;false&lt;/use-request-parameters&gt;
    *   &lt;use-browser-capabilities-db&gt;false&lt;/use-browser-capabilities-db&gt;
  + *   &lt;use-session-info&gt;false&lt;/use-session-info&gt;
    *   &lt;xslt-processor-role&gt;org.apache.cocoon.components.xslt.XSLTProcessor&lt;/xslt-processor-role&gt;
    * &lt;/map:transformer&gt;
    * </pre>
  @@ -69,7 +71,16 @@
    * Note that this might have issues concerning cachability of the generated output of this
    * transformer.<br>
    * This property is false by default.
  + * <p>
  + * The &lt;use-session-info&gt; configuration forces the transformer to make all
  + * of the session information available in the XSLT stylesheetas.<br>
  + * These infos are (boolean values are "true" or "false" strings: session-is-new,
  + * session-id-from-cookie, session-id-from-url, session-valid, session-id.<br>
  + * Note that this might have issues concerning cachability of the generated output of this
  + * transformer.<br>
  + * This property is false by default.
    *
  + *
    * The &lt;xslt-processor&gt; configuration allows to specify the XSLT processor
that will be
    * used by its role name. This allows to have several XSLT processors in the configuration
    * (e.g. Xalan and Saxon) and choose one or the other depending on the needs of stylesheet
  @@ -92,7 +103,7 @@
    * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
    * @author <a href="mailto:giacomo@apache.org">Giacomo Pati</a>
    * @author <a href="mailto:ovidiu@cup.hp.com">Ovidiu Predescu</a>
  - * @version CVS $Id: TraxTransformer.java,v 1.35 2001/11/06 10:48:48 sylvain Exp $
  + * @version CVS $Id: TraxTransformer.java,v 1.36 2001/11/13 07:36:24 cziegeler Exp $
    */
   public class TraxTransformer extends AbstractTransformer
   implements Transformer, Composable, Recyclable, Configurable, Cacheable, Disposable {
  @@ -114,6 +125,10 @@
       private boolean useCookies = false;
       private boolean _useCookies = false;
   
  +    /** Should we info about the session availalbe in the stylesheet? (default is off)
*/
  +    private boolean useSessionInfo = false;
  +    private boolean _useSessionInfo = false;
  +
       private ComponentManager manager;
   
       /** The trax TransformerHandler */
  @@ -151,6 +166,12 @@
             this._useBrowserCap = this.useBrowserCap;
             getLogger().debug("Use browser capabilities is " + this.useBrowserCap + " for
" + this);
             
  +          child = conf.getChild("use-session-info");
  +          this.useSessionInfo = child.getValueAsBoolean(false);
  +          this._useSessionInfo = this.useSessionInfo;
  +          getLogger().debug("Use session info is " + this.useSessionInfo + " for " + this);
  +
  +
             child = conf.getChild("xslt-processor-role");
             String xsltRole = child.getValue(XSLTProcessor.ROLE);
             getLogger().debug("Use XSLTProcessor of role " + xsltRole);
  @@ -194,6 +215,7 @@
           _useParameters = par.getParameterAsBoolean("use-request-parameters", this.useParameters);
           _useBrowserCap = par.getParameterAsBoolean("use-browser-capabilities-db", this.useBrowserCap);
           _useCookies = par.getParameterAsBoolean("use-cookies", this.useCookies);
  +        _useSessionInfo = par.getParameterAsBoolean("use-session-info", this.useSessionInfo);
       }
   
       /**
  @@ -317,6 +339,21 @@
               }
           }
   
  +        if (this._useSessionInfo) {
  +            /** The Request object */
  +            Request request = (Request) objectModel.get(Constants.REQUEST_OBJECT);
  +            if (map == null) map = new HashMap(5);
  +
  +            if (request != null) {               
  +               Session session = request.getSession(true);
  +               map.put("session-is-new",session.isNew()?"true":"false");
  +               map.put("session-id-from-cookie",request.isRequestedSessionIdFromCookie()?"true":"false");
  +               map.put("session-id-from-url",request.isRequestedSessionIdFromURL()?"true":"false");
  +               map.put("session-valid",request.isRequestedSessionIdValid()?"true":"false");
  +               map.put("session-id",session.getId());
  +            }
  +        }
  +
           if (this._useCookies) {
               Request request = (Request) objectModel.get(Constants.REQUEST_OBJECT);
               Cookie cookies[] = request.getCookies();
  @@ -436,6 +473,7 @@
           this._useParameters = this.useParameters;
           this._useCookies = this.useCookies;
           this._useBrowserCap = this.useBrowserCap;
  +        this._useSessionInfo = this.useSessionInfo;
           super.recycle();
       }
   }
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          cocoon-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-cvs-help@xml.apache.org


Mime
View raw message