You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by di...@apache.org on 2003/01/15 15:58:07 UTC

cvs commit: jakarta-commons-sandbox/jelly/jelly-tags/define/src/test/org/apache/commons/jelly/tags/define TestDynamicTags.java MyRunnable.java jellyBeanSample.jelly babelfishTaglib.jelly DynamicTag.java beanSample.jelly TestJelly.java example.jelly suite.jelly

dion        2003/01/15 06:58:07

  Added:       jelly/jelly-tags/define/src/java/org/apache/commons/jelly/tags/define
                        SuperTag.java DynaBeanTag.java ScriptTag.java
                        DefineTagSupport.java InvokeBodyTag.java
                        BeanTag.java InvokeTag.java package.html
                        TaglibTag.java ExtendTag.java ClassLoaderTag.java
                        TagTag.java JellyBeanTag.java AttributeTag.java
                        DefineTagLibrary.java
               jelly/jelly-tags/define maven.xml project.properties
                        project.xml .cvsignore
               jelly/jelly-tags/define/src/test/org/apache/commons/jelly/tags/define
                        TestDynamicTags.java MyRunnable.java
                        jellyBeanSample.jelly babelfishTaglib.jelly
                        DynamicTag.java beanSample.jelly TestJelly.java
                        example.jelly suite.jelly
  Log:
  Move define taglib to separate build
  
  Revision  Changes    Path
  1.1                  jakarta-commons-sandbox/jelly/jelly-tags/define/src/java/org/apache/commons/jelly/tags/define/SuperTag.java
  
  Index: SuperTag.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/jelly/jelly-tags/define/src/java/org/apache/commons/jelly/tags/define/SuperTag.java,v 1.1 2003/01/15 14:58:01 dion Exp $
   * $Revision: 1.1 $
   * $Date: 2003/01/15 14:58:01 $
   *
   * ====================================================================
   *
   * 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: SuperTag.java,v 1.1 2003/01/15 14:58:01 dion Exp $
   */
  package org.apache.commons.jelly.tags.define;
  
  import org.apache.commons.jelly.JellyException;
  import org.apache.commons.jelly.TagSupport;
  import org.apache.commons.jelly.XMLOutput;
  
  /** 
   * &lt;super&gt; tag is used to invoke a parent tag implementation, when
   * a tag extends an existing tag
   *
   * @author <a href="mailto:tima@intalio.com">Tim Anderson</a>
   * @version $Revision: 1.1 $
   * @see ExtendTag
   */
  public class SuperTag extends TagSupport {
      
      public SuperTag() {
      }
      
      // Tag interface
      //-------------------------------------------------------------------------
      public void doTag(XMLOutput output) throws Exception {
          ExtendTag tag = (ExtendTag) findAncestorWithClass(ExtendTag.class);
          if (tag == null) {
              throw new JellyException( 
                  "<define:super> must be inside a <define:extend>");
          }
  
          tag.getSuperScript().run(getContext(), output);
      }
  }
  
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/jelly-tags/define/src/java/org/apache/commons/jelly/tags/define/DynaBeanTag.java
  
  Index: DynaBeanTag.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/jelly/jelly-tags/define/src/java/org/apache/commons/jelly/tags/define/DynaBeanTag.java,v 1.1 2003/01/15 14:58:01 dion Exp $
   * $Revision: 1.1 $
   * $Date: 2003/01/15 14:58:01 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 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: DynaBeanTag.java,v 1.1 2003/01/15 14:58:01 dion Exp $
   */
  
  package org.apache.commons.jelly.tags.define;
  
  import java.util.HashMap;
  import java.util.Map;
  
  import org.apache.commons.beanutils.DynaClass;
  import org.apache.commons.jelly.MissingAttributeException;
  import org.apache.commons.jelly.Tag;
  import org.apache.commons.jelly.XMLOutput;
  import org.apache.commons.jelly.impl.Attribute;
  import org.apache.commons.jelly.impl.DynamicDynaBeanTag;
  import org.apache.commons.jelly.impl.TagFactory;
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogFactory;
  import org.xml.sax.Attributes;
  
  /** 
   * Binds a Java bean to the given named Jelly tag so that the attributes of
   * the tag set the bean properties..
   * 
   * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
   * @version $Revision: 1.1 $
   */
  public class DynaBeanTag extends DefineTagSupport {
  
      /** The Log to which logging calls will be made. */
      private static final Log log = LogFactory.getLog(DynaBeanTag.class);
  
      /** An empty Map as I think Collections.EMPTY_MAP is only JDK 1.3 onwards */
      private static final Map EMPTY_MAP = new HashMap();
  
      /** the name of the tag to create */
      private String name;
      
      /** the DyanClass to bind to the tag */
      private DynaClass dynaClass;
  
      /** the name of the attribute used for the variable name */
      private String varAttribute = "var";
  
      /** the attribute definitions for this dynamic tag */
      private Map attributes;
      
      /**
       * Adds a new attribute definition to this dynamic tag 
       */
      public void addAttribute(Attribute attribute) {
          if ( attributes == null ) {
              attributes = new HashMap();
          }
          attributes.put( attribute.getName(), attribute );
      }
      
      // Tag interface
      //-------------------------------------------------------------------------                    
      public void doTag(XMLOutput output) throws Exception {
          invokeBody(output);
          
  		if (name == null) {
  			throw new MissingAttributeException("name");
  		}
  		if (dynaClass == null) {
  			throw new MissingAttributeException("dynaClass");
  		}
          
          final DynaClass theDynaClass = dynaClass;
          final Map beanAttributes = (attributes != null) ? attributes : EMPTY_MAP;
          
          TagFactory factory = new TagFactory() {
              public Tag createTag(String name, Attributes attributes) {
                  return  new DynamicDynaBeanTag(theDynaClass, beanAttributes, varAttribute);
              }
          };
          getTagLibrary().registerBeanTag(name, factory);
          
          // now lets clear the attributes for next invocation and help the GC
          attributes = null;
  	}
  
      
      // Properties
      //-------------------------------------------------------------------------                    
      
      /** 
       * Sets the name of the tag to create
       */
      public void setName(String name) {
          this.name = name;
      }
      
      /**
       * Sets the name of the attribute used to define the bean variable that this dynamic
       * tag will output its results as. This defaults to 'var' though this property
       * can be used to change this if it conflicts with a bean property called 'var'.
       */
      public void setVarAttribute(String varAttribute) {    
          this.varAttribute = varAttribute;
      }
          
      /**
       * Returns the dynaClass.
       * @return DynaClass
       */
      public DynaClass getDynaClass() {
          return dynaClass;
      }
  
      /**
       * Sets the {@link DynaClass} which will be bound to this dynamic tag.
       */
      public void setDynaClass(DynaClass dynaClass) {
          this.dynaClass = dynaClass;
      }
  
  }
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/jelly-tags/define/src/java/org/apache/commons/jelly/tags/define/ScriptTag.java
  
  Index: ScriptTag.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/jelly/jelly-tags/define/src/java/org/apache/commons/jelly/tags/define/ScriptTag.java,v 1.1 2003/01/15 14:58:01 dion Exp $
   * $Revision: 1.1 $
   * $Date: 2003/01/15 14:58:01 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 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: ScriptTag.java,v 1.1 2003/01/15 14:58:01 dion Exp $
   */
  package org.apache.commons.jelly.tags.define;
  
  import org.apache.commons.jelly.JellyException;
  import org.apache.commons.jelly.TagSupport;
  import org.apache.commons.jelly.XMLOutput;
  
  /** 
   * &lt;script&gt; tag is used to assign a Script object
   * to a variable. The script can then be called whenever the user wishes
   * maybe from inside an expression or more typically via the &lt;invoke&gt; tag.</p>
   *
   * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
   * @version $Revision: 1.1 $
   */
  public class ScriptTag extends TagSupport {
      
      private String var;
      
      public ScriptTag() {
      }
      
      // Tag interface
      //-------------------------------------------------------------------------                    
      public void doTag(XMLOutput output) throws Exception {
          if ( var == null ) {
              throw new JellyException( "<define:script> must have a var attribute" );
          }
          context.setVariable( var, getBody() );
      }    
      
      // Properties
      //-------------------------------------------------------------------------                    
      
      /** @return the variable name of the script to create */
      public String getVar() {
          return var;
      }
      
      /** Sets the variable name of the tag to create */
      public void setVar(String var) {
          this.var = var;
      }    
  }
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/jelly-tags/define/src/java/org/apache/commons/jelly/tags/define/DefineTagSupport.java
  
  Index: DefineTagSupport.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/jelly/jelly-tags/define/src/java/org/apache/commons/jelly/tags/define/DefineTagSupport.java,v 1.1 2003/01/15 14:58:01 dion Exp $
   * $Revision: 1.1 $
   * $Date: 2003/01/15 14:58:01 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 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: DefineTagSupport.java,v 1.1 2003/01/15 14:58:01 dion Exp $
   */
  
  package org.apache.commons.jelly.tags.define;
  
  import org.apache.commons.jelly.JellyException;
  import org.apache.commons.jelly.TagSupport;
  import org.apache.commons.jelly.impl.DynamicTagLibrary;
  
  /** 
   * An abstract base class useful for implementation inheritence.
   * 
   * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
   * @version $Revision: 1.1 $
   */
  public abstract class DefineTagSupport extends TagSupport {
  
      // Implementation methods
      //-------------------------------------------------------------------------                    
      
      /**
       * @return the current dynamic tag library instance or throws a JellyException
       * if one is not available
       */
      protected DynamicTagLibrary getTagLibrary() throws JellyException {
          TaglibTag tag 
              = (TaglibTag) findAncestorWithClass(TaglibTag.class);
          if ( tag == null ) {
              throw new JellyException( "<define:tag> must be inside <define:taglib>" );
          }
          return tag.getTagLibrary();
      }
      
  }
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/jelly-tags/define/src/java/org/apache/commons/jelly/tags/define/InvokeBodyTag.java
  
  Index: InvokeBodyTag.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/jelly/jelly-tags/define/src/java/org/apache/commons/jelly/tags/define/InvokeBodyTag.java,v 1.1 2003/01/15 14:58:01 dion Exp $
   * $Revision: 1.1 $
   * $Date: 2003/01/15 14:58:01 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 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: InvokeBodyTag.java,v 1.1 2003/01/15 14:58:01 dion Exp $
   */
  package org.apache.commons.jelly.tags.define;
  
  import org.apache.commons.jelly.JellyException;
  import org.apache.commons.jelly.Script;
  import org.apache.commons.jelly.Tag;
  import org.apache.commons.jelly.TagSupport;
  import org.apache.commons.jelly.XMLOutput;
  import org.apache.commons.jelly.impl.DynamicTag;
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogFactory;
  
  /** 
   * &lt;invokeBody&gt; tag is used inside a &lt;tag&gt; tag 
   * (i.e. the definition of a dynamic tag) to invoke the tags body when 
   * the tag is invoked.
   * 
   * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
   * @version $Revision: 1.1 $
   */
  public class InvokeBodyTag extends TagSupport {
  
      /** The Log to which logging calls will be made. */
      private static final Log log = LogFactory.getLog(InvokeBodyTag.class);
  
      public InvokeBodyTag() {
      }
  
      // Tag interface
      //-------------------------------------------------------------------------                    
      public void doTag(XMLOutput output) throws Exception {
          // Try find find the body from the reserved 'org.apache.commons.jelly.body' variable
          Script script = (Script) context.getVariable("org.apache.commons.jelly.body");
          if (script != null) {
              script.run(context, output);
          }
          else {
              // note this mechanism does not work properly for arbitrarily 
              // nested dynamic tags. A better way is required.
              Tag tag = findAncestorWithClass(this, DynamicTag.class);
              if (tag == null) {
                  throw new JellyException("Cannot invoke body, no dynamic tag is defined in this block");
              }
              else {
                  tag.invokeBody(output);
              }
          }
      }
  }
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/jelly-tags/define/src/java/org/apache/commons/jelly/tags/define/BeanTag.java
  
  Index: BeanTag.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/jelly/jelly-tags/define/src/java/org/apache/commons/jelly/tags/define/BeanTag.java,v 1.1 2003/01/15 14:58:01 dion Exp $
   * $Revision: 1.1 $
   * $Date: 2003/01/15 14:58:01 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 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: BeanTag.java,v 1.1 2003/01/15 14:58:01 dion Exp $
   */
  
  package org.apache.commons.jelly.tags.define;
  
  import java.lang.reflect.Method;
  import java.util.HashMap;
  import java.util.Map;
  
  import org.apache.commons.jelly.JellyException;
  import org.apache.commons.jelly.MissingAttributeException;
  import org.apache.commons.jelly.Tag;
  import org.apache.commons.jelly.XMLOutput;
  import org.apache.commons.jelly.impl.Attribute;
  import org.apache.commons.jelly.impl.DynamicBeanTag;
  import org.apache.commons.jelly.impl.TagFactory;
  
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogFactory;
  
  import org.xml.sax.Attributes;
  
  /** 
   * Binds a Java bean to the given named Jelly tag so that the attributes of
   * the tag set the bean properties..
   * 
   * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
   * @version $Revision: 1.1 $
   */
  public class BeanTag extends DefineTagSupport {
  
      /** The Log to which logging calls will be made. */
      private static final Log log = LogFactory.getLog(BeanTag.class);
  
      /** An empty Map as I think Collections.EMPTY_MAP is only JDK 1.3 onwards */
      private static final Map EMPTY_MAP = new HashMap();
  
      /** the name of the tag to create */
      private String name;
      
      /** the Java class name to use for the tag */
      private String className;
  
      /** the ClassLoader used to load beans */
      private ClassLoader classLoader;
      
      /** the name of the attribute used for the variable name */
      private String varAttribute = "var";
  
      /** the attribute definitions for this dynamic tag */
      private Map attributes;
      
      /**
       * Adds a new attribute definition to this dynamic tag 
       */
      public void addAttribute(Attribute attribute) {
          if ( attributes == null ) {
              attributes = new HashMap();
          }
          attributes.put( attribute.getName(), attribute );
      }
      
      // Tag interface
      //-------------------------------------------------------------------------                    
      public void doTag(XMLOutput output) throws Exception {
          invokeBody(output);
          
  		if (name == null) {
  			throw new MissingAttributeException("name");
  		}
  		if (className == null) {
  			throw new MissingAttributeException("className");
  		}
          
  		Class theClass = null;
  		try {
  			ClassLoader classLoader = getClassLoader();
  			theClass = classLoader.loadClass(className);
  		} 
  		catch (ClassNotFoundException e) {
  			try {
  				theClass = getClass().getClassLoader().loadClass(className);
  			} 
              catch (ClassNotFoundException e2) {
  				try {
  					theClass = Class.forName(className);
  				} 
                  catch (ClassNotFoundException e3) {
                      log.error( "Could not load class: " + className + " exception: " + e, e );
  					throw new JellyException(
  						"Could not find class: "
  							+ className
  							+ " using ClassLoader: "
  							+ classLoader);
  				}
  			}
  		}
          
          final Class beanClass = theClass;
          final Method invokeMethod = getInvokeMethod( theClass );
          final Map beanAttributes = (attributes != null) ? attributes : EMPTY_MAP;
          
          TagFactory factory = new TagFactory() {
              public Tag createTag(String name, Attributes attributes) {
                  return  new DynamicBeanTag(beanClass, beanAttributes, varAttribute, invokeMethod);
              }
          };
          getTagLibrary().registerBeanTag(name, factory);
          
          // now lets clear the attributes for next invocation and help the GC
          attributes = null;
  	}
  
      
      // Properties
      //-------------------------------------------------------------------------                    
      
      /** 
       * Sets the name of the tag to create
       */
      public void setName(String name) {
          this.name = name;
      }
      
      /** 
       * Sets the Java class name to use for the tag
       */
      public void setClassName(String className) {
          this.className = className;
      }
      
      /**
       * Sets the ClassLoader to use to load the class. 
       * If no value is set then the current threads context class
       * loader is used.
       */
      public void setClassLoader(ClassLoader classLoader) {
          this.classLoader = classLoader;
      }
  
      /**
       * @return the ClassLoader to use to load classes
       *  or will use the thread context loader if none is specified.
       */    
      public ClassLoader getClassLoader() {
          if ( classLoader == null ) {
              ClassLoader answer = Thread.currentThread().getContextClassLoader();
              if ( answer == null ) {
                  answer = getClass().getClassLoader();
              }
              return answer;
          }
          return classLoader;
      }
  
      /**
       * Sets the name of the attribute used to define the bean variable that this dynamic
       * tag will output its results as. This defaults to 'var' though this property
       * can be used to change this if it conflicts with a bean property called 'var'.
       */
      public void setVarAttribute(String varAttribute) {    
          this.varAttribute = varAttribute;
      }
          
      
      // Implementation methods
      //-------------------------------------------------------------------------                    
      
      /**
       * Extracts the invoke method for the class if one is used.
       */
      protected Method getInvokeMethod( Class theClass ) throws Exception {
          return null;
      }
  }
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/jelly-tags/define/src/java/org/apache/commons/jelly/tags/define/InvokeTag.java
  
  Index: InvokeTag.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/jelly/jelly-tags/define/src/java/org/apache/commons/jelly/tags/define/InvokeTag.java,v 1.1 2003/01/15 14:58:01 dion Exp $
   * $Revision: 1.1 $
   * $Date: 2003/01/15 14:58:01 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 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: InvokeTag.java,v 1.1 2003/01/15 14:58:01 dion Exp $
   */
  package org.apache.commons.jelly.tags.define;
  
  import org.apache.commons.jelly.MissingAttributeException;
  import org.apache.commons.jelly.Script;
  import org.apache.commons.jelly.TagSupport;
  import org.apache.commons.jelly.XMLOutput;
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogFactory;
  
  /** 
   * The &lt;invoke&gt; tag will invoke a given Script instance.
   * It can be used with the &lt;script&gt; tag which defines scripts
   * as variables that can later be invoked by this &lt;invoke&gt; tag.
   *
   * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
   * @version $Revision: 1.1 $
   */
  public class InvokeTag extends TagSupport {
  
      /** The Log to which logging calls will be made. */
      private static final Log log = LogFactory.getLog(InvokeTag.class);
  
      private Script script;
      
      
      public InvokeTag() {
      }
      
      /**
       * Sets the Script to be invoked by this tag, which typically has been previously
       * defined by the use of the &lt;script&gt; tag.
       */
      public void setScript(Script script) {
          this.script = script;
      }
  
      // Tag interface
      //-------------------------------------------------------------------------                    
      public void doTag(XMLOutput output) throws Exception {
          if ( script == null ) {
              throw new MissingAttributeException("script");
          }
          script.run(context, output);
      }
  }
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/jelly-tags/define/src/java/org/apache/commons/jelly/tags/define/package.html
  
  Index: package.html
  ===================================================================
  <html>
  <head>
  </head>
  <body>
  
    <p>Tag library which allows the creation of new tags using Jelly script itself.
    </p>
  </body>
  </html>
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/jelly-tags/define/src/java/org/apache/commons/jelly/tags/define/TaglibTag.java
  
  Index: TaglibTag.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/jelly/jelly-tags/define/src/java/org/apache/commons/jelly/tags/define/TaglibTag.java,v 1.1 2003/01/15 14:58:01 dion Exp $
   * $Revision: 1.1 $
   * $Date: 2003/01/15 14:58:01 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 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: TaglibTag.java,v 1.1 2003/01/15 14:58:01 dion Exp $
   */
  package org.apache.commons.jelly.tags.define;
  
  import org.apache.commons.jelly.TagSupport;
  import org.apache.commons.jelly.XMLOutput;
  import org.apache.commons.jelly.impl.DynamicTagLibrary;
  
  /** 
   * The &lt;taglib&gt; tag is used to define a new tag library
   * using a Jelly script..</p>
   *
   * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
   * @version $Revision: 1.1 $
   */
  public class TaglibTag extends TagSupport {
      
      /** The namespace URI */
      private String uri;
      /** The new tags being added */
      private DynamicTagLibrary tagLibrary;
      /** Whether or not inheritence is enabled */
      private boolean inherit = true;
      
      public TaglibTag() {
      }
      
      public TaglibTag(String uri) {
          this.uri = uri;
      }
      
      // Tag interface
      //-------------------------------------------------------------------------                    
      public void doTag(XMLOutput output) throws Exception {
          String uri = getUri();
          tagLibrary = new DynamicTagLibrary( uri );
  
          // inherit tags from an existing tag library
          if ( isInherit() ) {
              tagLibrary.setParent( context.getTagLibrary( uri ) );
          }
          context.registerTagLibrary( uri, tagLibrary );
          
          invokeBody(output);
  
          tagLibrary = null;
      }    
      
      // Properties
      //-------------------------------------------------------------------------                    
      public String getUri() {
          return uri;
      }
  
      /**
       * Sets the namespace URI to register this new dynamic tag library with
       */    
      public void setUri(String uri) {
          this.uri = uri;
      }
      
      public DynamicTagLibrary getTagLibrary() {
          return tagLibrary;
      }
      
      /**
       * Returns the inherit.
       * @return boolean
       */
      public boolean isInherit() {
          return inherit;
      }
  
      /**
       * Sets whether this dynamic tag should inherit from the current existing tag library 
       * of the same URI. This feature is enabled by default so that tags can easily be
       * some tags can be overridden in an existing library, such as when making Mock Tags.
       * 
       * You can disable this option if you want to disable any tags in the base library,
       * turning them into just normal static XML.
       *
       * @param inherit The inherit to set
       */
      public void setInherit(boolean inherit) {
          this.inherit = inherit;
      }
  
  }
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/jelly-tags/define/src/java/org/apache/commons/jelly/tags/define/ExtendTag.java
  
  Index: ExtendTag.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/jelly/jelly-tags/define/src/java/org/apache/commons/jelly/tags/define/ExtendTag.java,v 1.1 2003/01/15 14:58:01 dion Exp $
   * $Revision: 1.1 $
   * $Date: 2003/01/15 14:58:01 $
   *
   * ====================================================================
   *
   * 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: ExtendTag.java,v 1.1 2003/01/15 14:58:01 dion Exp $
   */
  package org.apache.commons.jelly.tags.define;
  
  import org.apache.commons.jelly.JellyException;
  import org.apache.commons.jelly.Script;
  import org.apache.commons.jelly.XMLOutput;
  import org.apache.commons.jelly.impl.DynamicTagLibrary;
  
  /** 
   * &lt;extend&gt; is used to extend a dynamic tag defined in an inherited 
   * dynamic tag library
   * <p/>
   *
   * @author <a href="mailto:tima@intalio.com">Tim Anderson</a>
   * @version $Revision: 1.1 $
   * @see SuperTag
   */
  public class ExtendTag extends DefineTagSupport {
      
      private String name;
  
      private Script superScript;
      
      public ExtendTag() {
      }
      
      // Tag interface
      //-------------------------------------------------------------------------                    
      public void doTag(XMLOutput output) throws Exception {
          DynamicTagLibrary library = getTagLibrary();
          DynamicTagLibrary owner = library.find(getName());
          if (owner == null) {
              throw new JellyException(
                  "Cannot extend " + getName() + ": dynamic tag not defined");
          }
          if (owner == library) {
              // disallow extension of tags defined within the same tag
              // library
              throw new JellyException("Cannot extend " + getName() + 
                                       ": dynamic tag defined locally");
          }
          superScript = owner.getDynamicTag(name);
          if (superScript == null) {
              // tag doesn't define a script - disallow this for the moment.
              throw new JellyException("Cannot extend " + getName() + 
                                       ": tag is not a dynamic tag");
          }
  
          owner.registerDynamicTag(getName() , getBody());
      }    
  
      // Properties
      //-------------------------------------------------------------------------
      
      /** 
       * @return the name of the tag to create 
       */
      public String getName() {
          return name;
      }
      
      /** 
       * Sets the name of the tag to create 
       */
      public void setName(String name) {
          this.name = name;
      }    
  
      /**
       * Returns the parent implementation of this tag
       */
      public Script getSuperScript() {
          return superScript;
      }
  }
  
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/jelly-tags/define/src/java/org/apache/commons/jelly/tags/define/ClassLoaderTag.java
  
  Index: ClassLoaderTag.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/jelly/jelly-tags/define/src/java/org/apache/commons/jelly/tags/define/ClassLoaderTag.java,v 1.1 2003/01/15 14:58:01 dion Exp $
   * $Revision: 1.1 $
   * $Date: 2003/01/15 14:58:01 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 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: ClassLoaderTag.java,v 1.1 2003/01/15 14:58:01 dion Exp $
   */
  
  package org.apache.commons.jelly.tags.define;
  
  import java.net.URL;
  import java.net.URLClassLoader;
  
  import org.apache.commons.jelly.MissingAttributeException;
  import org.apache.commons.jelly.XMLOutput;
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogFactory;
  
  
  /** 
   * Creates a new <code>URLClassLoader</code> to dynamically
   * load tags froms.
   * 
   * @author <a href="mailto:stephenh@chase3000.com">Stephen Haberman</a>
   * @version $Revision: 1.1 $
   */
  public class ClassLoaderTag extends BeanTag {
  
      /** The Log to which logging calls will be made. */
      private static final Log log = LogFactory.getLog(ClassLoaderTag.class);
      
      /** The name to export the classloader to. */
      private String var;
      
      /** The URL to load the classes from. */
      private String url;
      
      // Properties
      //-------------------------------------------------------------------------                    
      
      /**
       * @return the variable to store the class loader in
       */
      public String getVar() {
          return this.var;
      }
      
      /** 
       * @param var the variable to store the class loader in
       */
      public void setVar(String var) {
          this.var = var;
      }
  
      /**
       * @return the url to load the classes from
       */
      public String getUrl() {
          return this.url;
      }
      
      /**
       * @param url the url to load the classes from
       */
      public void setUrl(String url) {
          this.url = url;
      }
  
      // Implementation methods
      //-------------------------------------------------------------------------                    
      
      public void doTag(XMLOutput output) throws Exception {
          if ( getVar() == null ) {
              throw new MissingAttributeException( "var" );
          }
          if ( getUrl() == null ) {
              throw new MissingAttributeException( "url" );
          }
                  
          ClassLoader parent = Thread.currentThread().getContextClassLoader();
          if (parent == null) {
              parent = getClass().getClassLoader();
          }
          
          URLClassLoader newClassLoader = new URLClassLoader(
              new URL[] { new URL(getUrl()) },
              parent );
          
          log.debug("Storing the new classloader in " + getVar());
          
          context.setVariable(getVar(), newClassLoader);
      }
      
  }
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/jelly-tags/define/src/java/org/apache/commons/jelly/tags/define/TagTag.java
  
  Index: TagTag.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/jelly/jelly-tags/define/src/java/org/apache/commons/jelly/tags/define/TagTag.java,v 1.1 2003/01/15 14:58:01 dion Exp $
   * $Revision: 1.1 $
   * $Date: 2003/01/15 14:58:01 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 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: TagTag.java,v 1.1 2003/01/15 14:58:01 dion Exp $
   */
  package org.apache.commons.jelly.tags.define;
  
  import org.apache.commons.jelly.XMLOutput;
  
  /** 
   * &lt;tag&gt; is used to define a new tag
   * using a Jelly script to implement the behaviour of the tag.
   * Parameters can be passed into the new tag using normal XML attribute
   * notations. Inside the body of the tag definition, the attributes can
   * be accessed as normal Jelly variables.</p>
   *
   * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
   * @version $Revision: 1.1 $
   */
  public class TagTag extends DefineTagSupport {
      
      private String name;
      
      public TagTag() {
      }
      
      // Tag interface
      //-------------------------------------------------------------------------                    
      public void doTag(XMLOutput output) throws Exception {
          getTagLibrary().registerDynamicTag( getName(), getBody() );
      }    
      
      // Properties
      //-------------------------------------------------------------------------                    
      
      /** @return the name of the tag to create */
      public String getName() {
          return name;
      }
      
      /** Sets the name of the tag to create */
      public void setName(String name) {
          this.name = name;
      }    
  }
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/jelly-tags/define/src/java/org/apache/commons/jelly/tags/define/JellyBeanTag.java
  
  Index: JellyBeanTag.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/jelly/jelly-tags/define/src/java/org/apache/commons/jelly/tags/define/JellyBeanTag.java,v 1.1 2003/01/15 14:58:01 dion Exp $
   * $Revision: 1.1 $
   * $Date: 2003/01/15 14:58:01 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 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: JellyBeanTag.java,v 1.1 2003/01/15 14:58:01 dion Exp $
   */
  
  package org.apache.commons.jelly.tags.define;
  
  import java.lang.reflect.Method;
  
  import org.apache.commons.beanutils.MethodUtils;
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogFactory;
  
  
  /** 
   * Binds a Java bean to the given named Jelly tag so that the attributes of
   * the tag set the bean properties. After the body of this tag is invoked
   * then the beans invoke() method will be called, if the bean has one.
   * 
   * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
   * @version $Revision: 1.1 $
   */
  public class JellyBeanTag extends BeanTag {
  
      /** The Log to which logging calls will be made. */
      private static final Log log = LogFactory.getLog(JellyBeanTag.class);
  
      /** Empty parameter types for Method lookup */
      private static final Class[] emptyParamTypes = {};
      
      /** the name of the method to invoke on the bean */
      private String method;
      
      // Properties
      //-------------------------------------------------------------------------                    
      
      /**
       * @return the method name to use, which defaults to 'run' for Runnable
       * objects
       */
      public String getMethod() {
          if ( method == null ) {
              return "run";
          }
          return method;
      }
      
      /** 
       * Sets the name of the method to invoke on the bean. 
       * This defaults to "run" so that Runnable objects can be
       * invoked, but this property can be set to whatever is required,
       * such as "execute" or "invoke"
       */
      public void setMethod(String method) {
          this.method = method;
      }
      
      
      // Implementation methods
      //-------------------------------------------------------------------------                    
      
      protected Method getInvokeMethod( Class theClass ) throws Exception {
          Method invokeMethod =
              MethodUtils.getAccessibleMethod(
                  theClass,
                  getMethod(),
                  emptyParamTypes);
                  
          if ( invokeMethod == null ) {
          }
          return invokeMethod;
      }
  }
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/jelly-tags/define/src/java/org/apache/commons/jelly/tags/define/AttributeTag.java
  
  Index: AttributeTag.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/jelly/jelly-tags/define/src/java/org/apache/commons/jelly/tags/define/AttributeTag.java,v 1.1 2003/01/15 14:58:01 dion Exp $
   * $Revision: 1.1 $
   * $Date: 2003/01/15 14:58:01 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 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: AttributeTag.java,v 1.1 2003/01/15 14:58:01 dion Exp $
   */
  package org.apache.commons.jelly.tags.define;
  
  import org.apache.commons.jelly.JellyException;
  import org.apache.commons.jelly.TagSupport;
  import org.apache.commons.jelly.XMLOutput;
  import org.apache.commons.jelly.expression.Expression;
  import org.apache.commons.jelly.impl.Attribute;
  
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogFactory;
  
  /** 
   * This tag is bound onto a Java Bean class. When the tag is invoked a bean will be created
   * using the tags attributes. 
   * The bean may also have an invoke method called invoke(), run(), execute() or some such method
   * which will be invoked after the bean has been configured.</p>
   *
   * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
   * @author <a href="mailto:jason@zenplex.com">Jason van Zyl</a>
   * @version $Revision: 1.1 $
   */
  public class AttributeTag extends TagSupport {
  
      /** The Log to which logging calls will be made. */
      private static final Log log = LogFactory.getLog(AttributeTag.class);
  
      /** the attribute definition */
      private Attribute attribute;    
          
      public AttributeTag() {
          attribute = new Attribute();
      }
  
      public AttributeTag(Attribute attribute) {
          this.attribute = attribute;
      }
  
      // Tag interface
      //-------------------------------------------------------------------------                    
      public void doTag(XMLOutput output) throws Exception {
          BeanTag tag = (BeanTag) findAncestorWithClass( BeanTag.class );
          if ( tag == null ) {
              throw new JellyException( "This tag should be nested inside a <define:bean> or <define:jellybean> tag" );
          }
  
          tag.addAttribute( attribute );        
      }
      
      // Properties
      //-------------------------------------------------------------------------                    
      
      /**
       * Sets the name of the attribute 
       */
      public void setName(String name) {
          attribute.setName(name);
      }
      
      /**
       * Sets whether this attribute is mandatory or not
       */
      public void setRequired(boolean required) {
          attribute.setRequired(required);
      }
      
      /**
       * Sets the default value of this attribute
       */
      public void setDefaultValue(Expression defaultValue) {
          attribute.setDefaultValue(defaultValue);
      }
  }
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/jelly-tags/define/src/java/org/apache/commons/jelly/tags/define/DefineTagLibrary.java
  
  Index: DefineTagLibrary.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/jelly/jelly-tags/define/src/java/org/apache/commons/jelly/tags/define/DefineTagLibrary.java,v 1.1 2003/01/15 14:58:01 dion Exp $
   * $Revision: 1.1 $
   * $Date: 2003/01/15 14:58:01 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 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: DefineTagLibrary.java,v 1.1 2003/01/15 14:58:01 dion Exp $
   */
  package org.apache.commons.jelly.tags.define;
  
  import org.apache.commons.jelly.TagLibrary;
  
  
  /** Describes the Taglib. This class could be generated by XDoclet
    *
    * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
    * @version $Revision: 1.1 $
    */
  public class DefineTagLibrary extends TagLibrary {
  
      public DefineTagLibrary() {
          registerTag( "taglib", TaglibTag.class );
          registerTag( "tag", TagTag.class );
          registerTag( "bean", BeanTag.class );
          registerTag( "dynaBean", DynaBeanTag.class );
          registerTag( "jellybean", JellyBeanTag.class );
          registerTag( "attribute", AttributeTag.class );
          registerTag( "invokeBody", InvokeBodyTag.class );
          registerTag( "script", ScriptTag.class );
          registerTag( "invoke", InvokeTag.class );
          registerTag( "classLoader", ClassLoaderTag.class );
          registerTag( "extend", ExtendTag.class );
          registerTag( "super", SuperTag.class );
      }
  }
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/jelly-tags/define/maven.xml
  
  Index: maven.xml
  ===================================================================
  <project default="java:jar">
  
  </project>
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/jelly-tags/define/project.properties
  
  Index: project.properties
  ===================================================================
  # -------------------------------------------------------------------
  # P R O J E C T  P R O P E R T I E S
  # -------------------------------------------------------------------
  
  maven.junit.fork=true
  
  maven.compile.deprecation = on
  
  # Installation dir
  maven.dist.install.dir = /usr/local/jelly
  
  maven.checkstyle.properties=../tag-checkstyle.properties
  
  
  1.1                  jakarta-commons-sandbox/jelly/jelly-tags/define/project.xml
  
  Index: project.xml
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  <!DOCTYPE project [
    <!-- see file for description -->
    <!ENTITY commonDeps SYSTEM "file:../../commonDependencies.ent">
  ]>
  <project>
    <extend>../tag-project.xml</extend>
    <id>commons-jelly-tags-define</id>
    <name>commons-jelly-tags-define</name>
  
    <package>org.apache.commons.jelly.tags.define</package>
  
    <description>
    	 The Jelly Define Tag Library
    </description>
    <shortDescription>Commons Jelly Define Tag Library</shortDescription>
    
    <url>http://jakarta.apache.org/commons/sandbox/jelly/tags/define/</url>
  
    <siteDirectory>/www/jakarta.apache.org/commons/sandbox/jelly/define/</siteDirectory>
    <distributionDirectory>/www/jakarta.apache.org/builds/jakarta-commons-sandbox/jelly/tags/define</distributionDirectory>
    <repository>
      <connection>scm:cvs:pserver:anoncvs@cvs.apache.org:/home/cvspublic:jakarta-commons-sandbox/jelly/jelly-tags/define/</connection>
      <url>http://cvs.apache.org/viewcvs/jakarta-commons-sandbox/jelly/jelly-tags/define/</url>
    </repository>
    
    <dependencies>
    
      &commonDeps;
    
      <!-- START for compilation -->
    
      <dependency>
        <id>commons-jelly</id>
        <version>SNAPSHOT</version>
      </dependency>
        
      <!-- END for compilation -->
      
    </dependencies>
    
  </project>
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/jelly-tags/define/.cvsignore
  
  Index: .cvsignore
  ===================================================================
  target
  maven.log
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/jelly-tags/define/src/test/org/apache/commons/jelly/tags/define/TestDynamicTags.java
  
  Index: TestDynamicTags.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/jelly/jelly-tags/define/src/test/org/apache/commons/jelly/tags/define/TestDynamicTags.java,v 1.1 2003/01/15 14:58:05 dion Exp $
   * $Revision: 1.1 $
   * $Date: 2003/01/15 14:58:05 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 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: TestDynamicTags.java,v 1.1 2003/01/15 14:58:05 dion Exp $
   */
  package org.apache.commons.jelly.tags.define;
  
  import java.io.File;
  import java.io.StringWriter;
  
  import junit.framework.Test;
  import junit.framework.TestCase;
  import junit.framework.TestSuite;
  import junit.textui.TestRunner;
  
  import org.apache.commons.jelly.JellyContext;
  import org.apache.commons.jelly.XMLOutput;
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogFactory;
  
  /** Tests dynamic tags
    *
    * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
    * @version $Revision: 1.1 $
    */
  public class TestDynamicTags extends TestCase {
  
      JellyContext context = new JellyContext();
      XMLOutput output;
  
      /** The Log to which logging calls will be made. */
      private static final Log log = LogFactory.getLog(TestDynamicTags.class);
  
      public static void main(String[] args) {
          TestRunner.run(suite());
      }
  
      public static Test suite() {
          return new TestSuite(TestDynamicTags.class);
      }
  
      public TestDynamicTags(String testName) {
          super(testName);
      }
  
      public void testParse() throws Exception {
          StringWriter buffer = new StringWriter();        
          output = XMLOutput.createXMLOutput(buffer);
          
          //runScript("src/test/org/apache/commons/jelly/define/babelfishTaglib.jelly");
          runScript("src/test/org/apache/commons/jelly/tags/define/example.jelly");
          
          log.info("The output was as follows");
          log.info(buffer.toString());
      }
      
      public void testJellyBean() throws Exception {
          StringWriter buffer = new StringWriter();        
          output = XMLOutput.createXMLOutput(buffer);
          
  	log.warn("commented out test, need to rewrite without ant");
          //runScript("src/test/org/apache/commons/jelly/define/jellyBeanSample.jelly");
          
          log.info("The output was as follows");
          log.info(buffer.toString());
      }
      
      protected void runScript(String name) throws Exception {
          context.runScript(new File(name), output);
      }
  }
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/jelly-tags/define/src/test/org/apache/commons/jelly/tags/define/MyRunnable.java
  
  Index: MyRunnable.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/jelly/jelly-tags/define/src/test/org/apache/commons/jelly/tags/define/MyRunnable.java,v 1.1 2003/01/15 14:58:05 dion Exp $
   * $Revision: 1.1 $
   * $Date: 2003/01/15 14:58:05 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 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: MyRunnable.java,v 1.1 2003/01/15 14:58:05 dion Exp $
   */
  package org.apache.commons.jelly.tags.define;
  
  import java.util.ArrayList;
  import java.util.List;
  
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogFactory;
  
  //import org.apache.tools.ant.types.FileSet;
  
  /** 
   * An example Runnable bean that is framework neutral and just performs
   * some useful function.
   *
   * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
   * @version $Revision: 1.1 $
   */
  public class MyRunnable implements Runnable {
  
      /** The Log to which logging calls will be made. */
      private static final Log log = LogFactory.getLog(MyRunnable.class);
  
      private int x;
      private String y;
      private List fileSets = new ArrayList();    
          
      public MyRunnable() {
      }
      
      
      // Adder methods
      //-------------------------------------------------------------------------
      /*
      
      Commented out method to remove test-only dependency on ant
      
      public void addFileset(FileSet fileSet) {
          fileSets.add(fileSet);
      }
      */
      
      // Runnable interface
      //-------------------------------------------------------------------------
      public void run() {
          log.info( "About to do something where x = " + getX() + " y = " + getY() );
          log.info( "FileSets are: " + fileSets );
      }
  
  
      // Properties
      //-------------------------------------------------------------------------
      public int getX() {
          return x;
      }
      
      public void setX(int x) {
          this.x = x;
      }
      
      public String getY() {
          return y;
      }
      
      public void setY(String y) {
          this.y = y;
      }
  }
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/jelly-tags/define/src/test/org/apache/commons/jelly/tags/define/jellyBeanSample.jelly
  
  Index: jellyBeanSample.jelly
  ===================================================================
  <?xml version="1.0"?>
  
  <!-- uses a JellyBean, which invokes the run() method -->
  <j:jelly 
  	xmlns:j="jelly:core" 
  	xmlns:define="jelly:define" 
  	xmlns:log="jelly:log" 
  	xmlns:my="myDummyTagLib"
  	xmlns="jelly:ant">
  	
  <testcase>
  
    <log:info>Lets define a new tag library</log:info>
    
    <define:taglib uri="myDummyTagLib">  
    
      <define:jellybean name="foo" className="org.apache.commons.jelly.tags.define.MyRunnable">
        <define:attribute name="y" defaultValue="wine"/>
      </define:jellybean>
      
      <!-- 
        This was added to demonstrate a ClassCastException when a
        dynamic tag is created that uses a dynamically jelly bean and
        called more than once. You should be able to call the dynamically
        created tag n times without problem now.
      -->
      
      <define:tag name="bar">
        <my:foo x="2" y="cheese">
          <fileset dir=".">
            <include name="*.xml"/>
          </fileset>
          <fileset dir="src/java">
            <include name="*.java"/>
          </fileset>
        </my:foo>
      </define:tag>
  
    </define:taglib>
  
    <log:info>Now lets invoke the new Jelly bean tag</log:info>
    
    <my:foo x="2" y="cheese">
      <fileset dir=".">
        <include name="*.xml"/>
      </fileset>
      <fileset dir="src/java">
        <include name="*.java"/>
      </fileset>
    </my:foo>
  
    <log:info>Did that work?</log:info>
    
    <my:foo x="2">
      <fileset dir=".">
        <include name="*.xml"/>
      </fileset>
    </my:foo>
    
    <!-- You should be able to run dynamic tags n times without ClassCastExceptions -->
    <my:bar/>
    <my:bar/>
    
  </testcase>
    		
  </j:jelly>
  
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/jelly-tags/define/src/test/org/apache/commons/jelly/tags/define/babelfishTaglib.jelly
  
  Index: babelfishTaglib.jelly
  ===================================================================
  <?xml version="1.0"?>
  
  <!-- defines a new taglib of babelfish soap services -->
  
  <j:jelly xmlns:j="jelly:core" xmlns:x="jelly:xml" xmlns:define="jelly:define" xmlns:http="notImplementedYet">
    <define:taglib uri="babelfish">  
  
      <!-- defines the <translate> tag                                            -->
      <!-- notice how the 'from' and 'to' attributes are available as variables   -->
      <!-- and the body of the <translate> tag is invoked via <define:invokeBody> -->
      <define:tag name="translate">
        <http:post url="http://services.xmethods.net:80/perl/soaplite.cgi">
         <http:header name="SOAPAction" value="urn:xmethodsBabelFish#BabelFish"/>
         <http:header name="Content-Type" value="text/xml"/>
         <http:body>
          <env:Envelope 
            xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
            env:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
            <env:Body>
              <m:BabelFish xmlns:m="urn:xmethodsBabelFish">
                <translationmode>${from}_${to}</translationmode>      
                <sourcedata>
                  <define:invokeBody/>
                </sourcedata>    
              </m:BabelFish>
            </env:Body>
          </env:Envelope>
         </http:body>
        </http:post>
      </define:tag>
      
    </define:taglib>    
  </j:jelly>
  
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/jelly-tags/define/src/test/org/apache/commons/jelly/tags/define/DynamicTag.java
  
  Index: DynamicTag.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/jelly/jelly-tags/define/src/test/org/apache/commons/jelly/tags/define/DynamicTag.java,v 1.1 2003/01/15 14:58:05 dion Exp $
   * $Revision: 1.1 $
   * $Date: 2003/01/15 14:58:05 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 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: DynamicTag.java,v 1.1 2003/01/15 14:58:05 dion Exp $
   */
   package org.apache.commons.jelly.tags.define;
  
  import org.apache.commons.jelly.TagSupport;
  import org.apache.commons.jelly.XMLOutput;
  
  /**
   * @author stephen
   * @version $Revision: 1.1 $
   */
  public class DynamicTag extends TagSupport
  {
  
      /**
       * @see org.apache.commons.jelly.Tag#doTag(XMLOutput)
       */
      public void doTag(XMLOutput output) throws Exception
      {
          output.write("output - ignored body");
      }
  
  }
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/jelly-tags/define/src/test/org/apache/commons/jelly/tags/define/beanSample.jelly
  
  Index: beanSample.jelly
  ===================================================================
  <?xml version="1.0"?>
  
  <!-- creates a Bean -->
  <j:jelly 
  	xmlns:j="jelly:core" 
  	xmlns:define="jelly:define" 
  	xmlns:log="jelly:log" 
  	xmlns:my="myDummyTagLib">
  	
  <testcase>
  
    <log:info>Lets define a new tag library</log:info>
    
    <define:taglib uri="myDummyTagLib">  
    
    	<!-- 
    	  || map the given bean to a jelly tag 
    	  || we'll specify some required attributes and some default values
    	  -->
    	  
      <define:bean name="customer" className="org.apache.commons.jelly.core.Customer">
  	  <define:attribute name="name" required="true"/>
  	  <define:attribute name="location" defaultValue="UK"/>
  	</define:bean>    	
  	
    </define:taglib>
  
    <log:info>Now lets invoke the new Jelly bean tag</log:info>
    
    <my:customer var="c1" name="James"/>
    
    <log:info>Created a customer with name ${c1.name} and location ${c1.location}</log:info>
  
    <my:customer var="c2" name="Bob" location="US"/>
    
    <log:info>Created a customer with name ${c2.name} and location ${c2.location}</log:info>
  
  		
    <j:catch var="exception">
    	<my:customer location="UK"/>
    </j:catch>
    
    <log:info>Caught exception ${exception} with reason: ${exception.reason}</log:info>
    
    <j:if test="${exception == null}">
    	<log:error>Failed! I should have an exception since I didn't specify a 'name' attribute</log:error>
    </j:if>
    
    
  </testcase>
    		
  </j:jelly>
  
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/jelly-tags/define/src/test/org/apache/commons/jelly/tags/define/TestJelly.java
  
  Index: TestJelly.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/jelly/jelly-tags/define/src/test/org/apache/commons/jelly/tags/define/TestJelly.java,v 1.1 2003/01/15 14:58:05 dion Exp $
   * $Revision: 1.1 $
   * $Date: 2003/01/15 14:58:05 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 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: TestJelly.java,v 1.1 2003/01/15 14:58:05 dion Exp $
   */
  package org.apache.commons.jelly.tags.define;
  
  import junit.framework.TestSuite;
  import junit.textui.TestRunner;
  
  import org.apache.commons.jelly.tags.junit.JellyTestSuite;
  
  /** 
   * A helper class to run jelly test cases as part of Ant's JUnit tests
   *
   * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
   * @version $Revision: 1.1 $
   */
  public class TestJelly extends JellyTestSuite {
  
      public static void main( String[] args ) throws Exception {
          TestRunner.run( suite() );
      }
      
      public static TestSuite suite() throws Exception {
          return createTestSuite(TestJelly.class, "suite.jelly");        
      }
  }
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/jelly-tags/define/src/test/org/apache/commons/jelly/tags/define/example.jelly
  
  Index: example.jelly
  ===================================================================
  <?xml version="1.0"?>
  
  <!-- uses the babelfish taglib -->
  <j:jelly xmlns:j="jelly:core" xmlns:babelfish="babelfish">
  
    <j:include uri="babelfishTaglib.jelly"/>
    
    This example should output a web service call...
  
    <babelfish:translate from="EN" to="FR">
      Jelly is cool stuff!
    </babelfish:translate>
  
    ... OK did that work?
  
  </j:jelly>
  
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/jelly-tags/define/src/test/org/apache/commons/jelly/tags/define/suite.jelly
  
  Index: suite.jelly
  ===================================================================
  <?xml version="1.0"?>
  <test:suite 
  	xmlns:j="jelly:core" 
  	xmlns:x="jelly:xml" 
  	xmlns:test="jelly:junit" 
  	xmlns:log="jelly:log" 
  	xmlns:define="jelly:define"
  	xmlns:dynamicTest="dynamicTest">
  
  <test:case name="invoke">
  
    <define:script var="fooScript">
    	<log:info>Generating some XML</log:info>
    	
      <foo id="1">
        <bar>some XML</bar>
      </foo>
    </define:script>
    
    
    <!-- now lets invoke the script -->
    
    
    <x:parse var="doc">
    	<log:info>About to invoke the script!</log:info>
    	
    	<define:invoke script="${fooScript}"/>
    </x:parse>
    	   	
    	   	
    <x:forEach select="$doc//foo">
      <test:assert xpath="bar"/>
    </x:forEach>
      
      			  	   	
    <test:assert xpath="$doc/foo/bar"/>
    
  </test:case>
  
  <test:case name="dynamicTag">
  
    <!-- Init the new tag. -->
    <define:taglib uri="dynamicTest">
      <define:jellybean
        name="test"
        className="org.apache.commons.jelly.tags.define.DynamicTag"
      />
    </define:taglib>
  
    <j:set var="output">
      <dynamicTest:test>
        ignored output to make sure doTag is being called
      </dynamicTest:test>
    </j:set>
  
    <test:assertEquals
      expected="output - ignored body"
      actual="${output}"
    />
  
  </test:case>
     
  
  <test:case name="dynaBeans" 
  	xmlns:dynabean="jelly:dynabean"
  	xmlns:my="dynamicDynaBeanTest">
  
  	<!-- create a DynaClass -->
    <dynabean:dynaclass var="CustomerType" name="CustomerDynaClass"> 
  		<dynabean:property name="name" type="String" />
  		<dynabean:property name="address" type="String" />
  	</dynabean:dynaclass>
  
    <!-- Create a new tag library binding the dynabeans. -->
    <define:taglib uri="dynamicDynaBeanTest">
      <define:dynaBean
        name="customer"
        dynaClass="${CustomerType}"
      />
    </define:taglib>
  
  	<!-- now lets create a customer -->
  	<my:customer var="customer" name="Customer 1" address="Address of Customer 1" />
  
  	<test:assert test="${customer != null}">Created a customer DynaBean</test:assert>
  	
  	<test:assertEquals 
  		expected="Customer 1" 
  		actual="${customer.name}"/>
  		
  	<test:assertEquals 
  		expected="Address of Customer 1" 
  		actual="${customer.address}"/>
  		
  	<test:assertEquals 
  		expected="CustomerDynaClass" 
  		actual="${customer.dynaClass.name}"/>
  
  </test:case>
  
  <test:case name="testTaglibInheritTest" xmlns="taglibInherit">
  
    <define:taglib uri="taglibInherit" inherit="false">
       <define:tag name="foo">
          bar
       </define:tag>
    </define:taglib>
  
    <define:taglib uri="taglibInherit" inherit="true">
       <define:tag name="foo2">
          bar2
       </define:tag>
    </define:taglib>
  
    <j:set var="output">
      <foo/>
    </j:set>
  
    <test:assertEquals expected="bar" actual="${output}"/>
  
  </test:case>
  
  <test:case name="testExtend" xmlns="taglibExtend">
  
    <define:taglib uri="taglibExtend" inherit="false">
       <define:tag name="foo">
          foo
       </define:tag>
    </define:taglib>
  
    <j:set var="output"><foo/></j:set>
    <test:assertEquals expected="foo" actual="${output}"/>
  
    <!-- extend the foo tag -->
    <define:taglib uri="taglibExtend" inherit="true">
       <define:extend name="foo">
          bar
       </define:extend>
    </define:taglib>
  
    <j:set var="output">
       <foo/>
    </j:set>
    <test:assertEquals expected="bar" actual="${output}"/>
  
  </test:case>
  
  <test:case name="testSuper" xmlns="taglibSuper">
  
    <define:taglib uri="taglibSuper" inherit="false">
       <define:tag name="foo">
          foo
       </define:tag>
    </define:taglib>
  
    <!-- extend the foo tag -->
    <define:taglib uri="taglibSuper" inherit="true">
       <define:extend name="foo">
          <define:super/>
          bar
       </define:extend>
    </define:taglib>
  
    <j:set var="output">
      <foo/>
    </j:set>
    <test:assertEquals expected="foobar" actual="${output}"/>
  
    <!-- extend the foo tag -->
    <define:taglib uri="taglibSuper" inherit="true">
       <define:extend name="foo">
          bar
          <define:super/>
       </define:extend>
    </define:taglib>
  
    <j:set var="output">
      <foo/>
    </j:set>
    <test:assertEquals expected="barfoobar" actual="${output}"/>
  
  </test:case>
  
  
     
  </test:suite>
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>