commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject cvs commit: jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/jeez example.jelly
Date Fri, 19 Jul 2002 23:05:22 GMT
jstrachan    2002/07/19 16:05:22

  Modified:    jelly/src/java/org/apache/commons/jelly/tags/jeez
                        JeezTagLibrary.java
  Added:       jelly/src/java/org/apache/commons/jelly/tags/jeez
                        TagDefTag.java
               jelly/src/test/org/apache/commons/jelly/jeez example.jelly
  Log:
  Adding early version of the <tagdef> tag for use in Maven. This tag doesn't work just
yet until we perform the minor refactoring of the Tag protocol so that a TagScript can do
lazy bindings of the TagScript to the Tag instance, so that we can support dynamic Tags as
well as Ant Tasks inside the same tag library.
  
  Revision  Changes    Path
  1.4       +27 -8     jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/jeez/JeezTagLibrary.java
  
  Index: JeezTagLibrary.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/jeez/JeezTagLibrary.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- JeezTagLibrary.java	18 Jun 2002 18:36:43 -0000	1.3
  +++ JeezTagLibrary.java	19 Jul 2002 23:05:21 -0000	1.4
  @@ -7,7 +7,7 @@
    *
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 1999-2001 The Apache Software Foundation.  All rights
  + * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -56,7 +56,8 @@
    * individuals on behalf of the Apache Software Foundation.  For more
    * information on the Apache Software Foundation, please see
    * <http://www.apache.org/>.
  - *
  + * 
  + * $Id$
    */
   
   package org.apache.commons.jelly.tags.jeez;
  @@ -71,10 +72,13 @@
   import org.apache.commons.jelly.impl.TagScript;
   import org.apache.commons.jelly.Script;
   import org.apache.commons.jelly.TagLibrary;
  -import org.apache.commons.jelly.tags.werkz.WerkzTagLibrary;
   import org.apache.commons.jelly.tags.ant.AntTagLibrary;
  +import org.apache.commons.jelly.tags.define.DynamicTagLibrary;
  +import org.apache.commons.jelly.tags.werkz.WerkzTagLibrary;
   // import org.apache.commons.jelly.tags.core.CoreTagLibrary;
  +
   import org.apache.tools.ant.Project;
  +
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
   
  @@ -86,7 +90,7 @@
    * @author <a href="mailto:bob@eng.werken.com">bob mcwhirter</a>
    * @version $Revision$
    */
  -public class JeezTagLibrary extends TagLibrary {
  +public class JeezTagLibrary extends DynamicTagLibrary {
   
       /** The Log to which logging calls will be made. */
       private Log log = LogFactory.getLog(JeezTagLibrary.class);
  @@ -103,6 +107,14 @@
       private Set runtimeTasks;
   
       private Project project;
  +
  +    /**
  +     * Use a default ant Project
  +     */
  +    public JeezTagLibrary() {
  +        this( AntTagLibrary.createProject() );
  +    }
  +
       
       /** Construct.
        *
  @@ -117,8 +129,15 @@
           this.antTagLib    = new AntTagLibrary( antProject );
           this.werkzTagLib  = new WerkzTagLibrary();
   
  +        // #### this is a bit of a hack. 
  +        // when we introduce the concept of TagFactory objects
  +        // we could do a cleaner mechanism for this...
  +        TagDefTag.tagLibrary = this;
  +        
           registerTag( "target",
                        TargetTag.class );
  +        registerTag( "tagdef",
  +                     TagDefTag.class );
       }
   
       public TagScript createTagScript(String name,
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/jeez/TagDefTag.java
  
  Index: TagDefTag.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/JellyContext.java,v
1.10 2002/04/26 12:20:12 jstrachan Exp $
   * $Revision: 1.10 $
   * $Date: 2002/04/26 12:20:12 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2002 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", "Commons", 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/>.
   * 
   * $Id: JellyContext.java,v 1.10 2002/04/26 12:20:12 jstrachan Exp $
   */
  
  package org.apache.commons.jelly.tags.jeez;
  
  import org.apache.commons.jelly.JellyException;
  import org.apache.commons.jelly.tags.define.DefineTagTag;
  import org.apache.commons.jelly.tags.define.DynamicTagLibrary;
  
  /** 
   * This tag defines a dynamic tag in Jelly script. When the tag is invoked
   * any attributes will be passed in as variables and the definition of the
   * tag can use &lt;define:invokeBody&gt to invoke its body.
   * <p>
   * This tag is similar to the &lt;define:tag&gt; tag in the define
   * tag library. 
   *
   * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
   * @version $Revision: 1.1 $
   */
  public class TagDefTag extends DefineTagTag {
  
      protected static DynamicTagLibrary tagLibrary;
      
      public TagDefTag() {
      }
  
      /**
       * @return the current JeezTagLibrary instance
       */
      protected DynamicTagLibrary getTagLibrary() throws JellyException {
          return tagLibrary;
      }
  }
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/jeez/example.jelly
  
  Index: example.jelly
  ===================================================================
  <?xml version="1.0"?>
  <j:jelly xmlns:j="jelly:core" xmlns="jelly:jeez">
  
      <tagdef name="foo">
        This is called when the foo tag is created...
        
  	  <echo>Called with ${n}. The value of x is ${x} and now will increment</echo>
   	
  	  <j:set var="x" value="${x + 1}"/>
  	</tagdef>
  	
  	<!-- now lets use the tag -->
  	<foo n="a"/>
  	<foo n="b"/>			  			  	
    	
  
  </j:jelly>
  
  
  

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message