jakarta-taglibs-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From morg...@apache.org
Subject cvs commit: jakarta-taglibs-sandbox/latka-taglib/xml latka-taglib.xml
Date Fri, 31 Aug 2001 18:15:49 GMT
morgand     01/08/31 11:15:49

  Modified:    latka-taglib/src/org/apache/taglibs/latka
                        ExecuteSuiteTag.java
               latka-taglib/xml latka-taglib.xml
  Added:       latka-taglib/src/org/apache/taglibs/latka
                        SessionPropertiesTEI.java SessionPropertiesTag.java
  Log:
  added useful tag for setting properties in the session
  
  Revision  Changes    Path
  1.7       +16 -2     jakarta-taglibs-sandbox/latka-taglib/src/org/apache/taglibs/latka/ExecuteSuiteTag.java
  
  Index: ExecuteSuiteTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs-sandbox/latka-taglib/src/org/apache/taglibs/latka/ExecuteSuiteTag.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- ExecuteSuiteTag.java	2001/08/29 23:15:54	1.6
  +++ ExecuteSuiteTag.java	2001/08/31 18:15:49	1.7
  @@ -37,8 +37,8 @@
     // with every invocation
     // this may be more elegant if we implement 
     // trycatchfinally
  -  protected Properties _propStore = 
  -    (Properties) LatkaProperties.getProperties().clone();
  +  protected Properties _props = 
  +    (Properties) LatkaProperties.getProperties();
   
     /**
      * The full path to the test file.  If this property
  @@ -49,6 +49,20 @@
      */
     public void setTestFile(String fileName) {
       _testFile = fileName;
  +  }
  +
  +  /**
  +   * Given the name of a Property attribute, this method 
  +   * will add all the contained properties to Latka before
  +   * executing a test.  Note: these properties will NOT be
  +   * retained in future executions of the tag.
  +   * 
  +   * @param propertyAttribute
  +   *               Reference to a Properties attribute
  +   */
  +  public void setProperties(String propertyAttribute) {
  +    Properties localProps = (Properties) pageContext.findAttribute(propertyAttribute);
  +    _props.putAll(localProps);
     }
   
     public int doStartTag() {
  
  
  
  1.1                  jakarta-taglibs-sandbox/latka-taglib/src/org/apache/taglibs/latka/SessionPropertiesTEI.java
  
  Index: SessionPropertiesTEI.java
  ===================================================================
  /*
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  package org.apache.taglibs.latka;
  
  import javax.servlet.jsp.tagext.TagData;
  import javax.servlet.jsp.tagext.TagExtraInfo;
  import javax.servlet.jsp.tagext.VariableInfo;
  
  public class SessionPropertiesTEI extends TagExtraInfo {
  
    public final VariableInfo[] getVariableInfo(TagData data)
    {
      return new VariableInfo[]
      {
        new VariableInfo(
                        data.getAttributeString("id"),
                        "java.util.Properties",
                        true,
                        VariableInfo.AT_BEGIN 
                        ),
      };
    }
  }
  
  
  
  
  1.1                  jakarta-taglibs-sandbox/latka-taglib/src/org/apache/taglibs/latka/SessionPropertiesTag.java
  
  Index: SessionPropertiesTag.java
  ===================================================================
  package org.apache.taglibs.latka;
  
  import java.util.Properties;
  
  import javax.servlet.http.HttpSession;
  import javax.servlet.jsp.tagext.BodyTagSupport;
  
  import org.apache.commons.latka.LatkaProperties;
  
  /**
   * Upon the first invocation of this tag in the session,
   * it will instantiate a clone of the default Latka 
   * properties and assign them as a Session attribute.
   * That properties object will be returned on this and
   * subsequent invocations of the Tag.  This is an
   * excellent way to statefully assign and change Latka
   * properties. 
   * 
   * @see ExecuteSuiteTag#setProperties(String)
   */
  public class SessionPropertiesTag extends BodyTagSupport {
  
    public int doStartTag() {
  
      HttpSession session = pageContext.getSession();
  
      Properties props = (Properties) session.getAttribute("latka.sessionProperties");
      if (props == null) {
        props = (Properties) LatkaProperties.getProperties().clone();
        session.setAttribute("latka.sessionProperties",props);
      }
  
      pageContext.setAttribute(getId(),props);
  
      return SKIP_BODY;
  
    }
  
  }
  
  
  
  1.4       +58 -0     jakarta-taglibs-sandbox/latka-taglib/xml/latka-taglib.xml
  
  Index: latka-taglib.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs-sandbox/latka-taglib/xml/latka-taglib.xml,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- latka-taglib.xml	2001/08/29 23:16:15	1.3
  +++ latka-taglib.xml	2001/08/31 18:15:49	1.4
  @@ -83,6 +83,17 @@
           </description>
           <availability>1.0</availability>
         </attribute>
  +      
  +      <attribute>
  +        <name>properties</name>
  +        <required>no</required>
  +        <rtexprvalue>yes</rtexprvalue>
  +        <description>
  +          Optional properties to add to the test.  This is a good way
  +          to set properties required in a particular test file.
  +        </description>
  +        <availability>1.0</availability>
  +      </attribute>
               
         <example>
           <usage>
  @@ -196,6 +207,53 @@
             <code>
   <![CDATA[
   <latka:findVariables id="varSet" testFile="/lib/latka/tests/test1.xml"/>
  +]]>
  +          </code>
  +        </usage>
  +      </example>
  +    </tag>
  +
  +    <tag>
  +      <name>sessionProperties</name>
  +      <tag-class>org.apache.taglibs.latka.SessionPropertiesTag</tag-class>
  +      <tei-class>org.apache.taglibs.latka.SessionPropertiesTEI</tei-class>
  +      <body-content>empty</body-content>
  +
  +      <description>
  +        Upon the first invocation of this tag in the session,
  +        it will instantiate a clone of the default Latka 
  +        properties and assign them as a Session attribute.
  +        That properties object will be returned on this and
  +        subsequent invocations of the Tag.  This is an
  +        excellent way to statefully assign and change Latka
  +        properties.
  +      </description>
  +      <availability>1.0</availability>
  +      
  +      <variable>
  +        <name-from-attribute>id</name-from-attribute>
  +        <variable-class>java.util.Properties</variable-class>
  +        <declare>true</declare>
  +        <scope>AT_BEGIN</scope>
  +        <availability>1.0</availability>
  +      </variable>
  +
  +      <attribute>
  +        <name>id</name>
  +        <required>yes</required>
  +        <rtexprvalue>yes</rtexprvalue>
  +        <description>
  +          Script variable id, assigns a Properties object 
  +        </description>
  +        <availability>1.0</availability>
  +      </attribute>
  +            
  +      <example>
  +        <usage>
  +          <code>
  +<![CDATA[
  +<latka:sessionProperties id="props"/>
  +Default host: <%= props.getProperty("defaultHost") >
   ]]>
             </code>
           </usage>
  
  
  

Mime
View raw message