commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wer...@apache.org
Subject cvs commit: jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/werkz example.jelly
Date Wed, 12 Jun 2002 06:07:29 GMT
werken      2002/06/11 23:07:29

  Modified:    jelly    build.xml
               jelly/src/java/org/apache/commons/jelly/tags/ant
                        AntTagLibrary.java TaskPropertyTag.java
               jelly/src/java/org/apache/commons/jelly/tags/werkz
                        WerkzTagLibrary.java
               jelly/src/test/org/apache/commons/jelly/werkz example.jelly
  Added:       jelly/src/java/org/apache/commons/jelly/tags/werkz
                        AttainGoalTag.java AttainTag.java GoalTag.java
                        PostGoalTag.java PreGoalTag.java
  Removed:     jelly/src/java/org/apache/commons/jelly/tags/werkz
                        CallTargetTag.java PostTargetTag.java
                        PreTargetTag.java TargetTag.java
  Log:
  * demo.werkz2 now actually works and runs the demo.
  
  * Re-aligned the Werkz taglib to the actual werkz vocabulary and semantics.
    -- renamed everything Target to Goal.
    -- changed Call to Attain.
    -- Implemented one-off and multi-goals-within-a-session attainment.
  
  * Fixed build.xml to pick up the Jelly default properties for the
    internally registered jelly:foo taglibs.  Still munging test.classpath.
  
  Revision  Changes    Path
  1.42      +1 -0      jakarta-commons-sandbox/jelly/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/build.xml,v
  retrieving revision 1.41
  retrieving revision 1.42
  diff -u -r1.41 -r1.42
  --- build.xml	12 Jun 2002 04:32:27 -0000	1.41
  +++ build.xml	12 Jun 2002 06:07:29 -0000	1.42
  @@ -16,6 +16,7 @@
     
     <path id="test.classpath">
       <pathelement path="${maven.build.dest}"/>
  +    <pathelement path="${maven.src.dir}/java"/>
       <pathelement path="${basedir}"/>
       <path refid="maven.dependency.classpath"/>
       <pathelement location="${lib.repo}/xmlParserAPIs-2.0.0.jar"/>
  
  
  
  1.6       +13 -1     jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/ant/AntTagLibrary.java
  
  Index: AntTagLibrary.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/ant/AntTagLibrary.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- AntTagLibrary.java	11 Jun 2002 22:59:22 -0000	1.5
  +++ AntTagLibrary.java	12 Jun 2002 06:07:29 -0000	1.6
  @@ -80,6 +80,8 @@
   
   import org.apache.tools.ant.Project;
   import org.apache.tools.ant.Task;
  +import org.apache.tools.ant.BuildLogger;
  +import org.apache.tools.ant.NoBannerLogger;
   import org.apache.tools.ant.types.DataType;
   import org.apache.tools.ant.types.Reference;
   
  @@ -137,8 +139,18 @@
       }        
           
       public AntTagLibrary() {
  -        // need to spoof an Ant project
  +
           this.project = new Project();
  +
  +        BuildLogger logger = new NoBannerLogger();
  +
  +        logger.setMessageOutputLevel( org.apache.tools.ant.Project.MSG_INFO );
  +        logger.setOutputPrintStream( System.out );
  +        logger.setErrorPrintStream( System.err);
  +
  +        project.addBuildListener( logger );
  +        
  +        project.init();
       }
   
       public AntTagLibrary(Project project) {
  
  
  
  1.5       +1 -1      jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/ant/TaskPropertyTag.java
  
  Index: TaskPropertyTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/ant/TaskPropertyTag.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- TaskPropertyTag.java	5 Jun 2002 07:12:58 -0000	1.4
  +++ TaskPropertyTag.java	12 Jun 2002 06:07:29 -0000	1.5
  @@ -104,7 +104,7 @@
       // CompilableTag interface
       //------------------------------------------------------------------------- 
       public void compile() throws Exception {
  -        TaskTag tag = (TaskTag) findAncestorWithClass( TaskTag.class );
  +        TaskTag tag = (TaskTag) findAncestorWithClass( Task.class );
           if ( tag == null ) {
               throw new JellyException( "You should only use Ant DataType tags within an
Ant Task" );
           }        
  
  
  
  1.2       +5 -4      jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/werkz/WerkzTagLibrary.java
  
  Index: WerkzTagLibrary.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/werkz/WerkzTagLibrary.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- WerkzTagLibrary.java	11 Jun 2002 21:41:11 -0000	1.1
  +++ WerkzTagLibrary.java	12 Jun 2002 06:07:29 -0000	1.2
  @@ -84,9 +84,10 @@
       
       public WerkzTagLibrary() {
           registerTag("project", ProjectTag.class);
  -        registerTag("target", TargetTag.class);
  -        registerTag("preTarget", PreTargetTag.class);
  -        registerTag("postTarget", PostTargetTag.class);
  -        registerTag("callTarget", CallTargetTag.class);
  +        registerTag("goal", GoalTag.class);
  +        registerTag("preGoal", PreGoalTag.class);
  +        registerTag("postGoal", PostGoalTag.class);
  +        registerTag("attain", AttainTag.class);
  +        registerTag("attainGoal", AttainGoalTag.class);
       }
   }
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/werkz/AttainGoalTag.java
  
  Index: AttainGoalTag.java
  ===================================================================
  /*
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  
  package org.apache.commons.jelly.tags.werkz;
  
  import com.werken.werkz.Goal;
  import com.werken.werkz.Session;
  import com.werken.werkz.Project;
  
  import org.apache.commons.jelly.JellyException;
  import org.apache.commons.jelly.XMLOutput;
  
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogFactory;
  
  /** 
   * Attains one or more goals.
   *
   * @author <a href="mailto:bob@eng.werken.com">bob mcwhirter</a>
   * @version $Revision: 1.1 $
   */
  public class AttainGoalTag extends WerkzTagSupport {
  
      /** The Log to which logging calls will be made. */
      private Log log = LogFactory.getLog(AttainGoalTag.class);
      
      /** The goal name. */
      private String name;
      
      public AttainGoalTag() {
      }
  
      // Tag interface
      //------------------------------------------------------------------------- 
      
      /** 
       * Evaluate the body to register all the various goals and pre/post conditions
       * then run all the current targets
       */
      public void doTag(final XMLOutput output) throws Exception {
          
          AttainTag attainTag = (AttainTag) findAncestorWithClass( AttainTag.class );
          Session session = null;
  
          if ( attainTag == null ) {
              session = new Session();
          } else {
              session = attainTag.getSession();
          }
  
          ProjectTag projectTag = (ProjectTag) findAncestorWithClass( ProjectTag.class );
  
          Project project = projectTag.getProject();
  
          project.attainGoal( getName(),
                              session );
          
          // getBody().run(context, output);
      }
  
      
      // Properties
      //------------------------------------------------------------------------- 
      
      public void setName(String name) {
          this.name = name;
      }
  
      public String getName() {
          return this.name;
      }
  }
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/werkz/AttainTag.java
  
  Index: AttainTag.java
  ===================================================================
  /*
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  
  package org.apache.commons.jelly.tags.werkz;
  
  import com.werken.werkz.Goal;
  import com.werken.werkz.Session;
  
  import org.apache.commons.jelly.JellyException;
  import org.apache.commons.jelly.XMLOutput;
  
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogFactory;
  
  /** 
   * Attains one or more goals.
   *
   * @author <a href="mailto:bob@eng.werken.com">bob mcwhirter</a>
   * @version $Revision: 1.1 $
   */
  public class AttainTag extends WerkzTagSupport {
  
      /** The Log to which logging calls will be made. */
      private Log log = LogFactory.getLog(AttainTag.class);
      
      /** The goal session. */
      private Session session;
      
      public AttainTag() {
          log.debug( "ctor()" );
          this.session = new Session();
      }
  
      // Tag interface
      //------------------------------------------------------------------------- 
      
      /** 
       * Evaluate the body to register all the various goals and pre/post conditions
       * then run all the current targets
       */
      public void doTag(final XMLOutput output) throws Exception {
          this.session.clear();
          
          getBody().run(context, output);
      }
  
      
      // Properties
      //------------------------------------------------------------------------- 
      
      public Session getSession() {
          return this.session;
      }
  }
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/werkz/GoalTag.java
  
  Index: GoalTag.java
  ===================================================================
  /*
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  
  package org.apache.commons.jelly.tags.werkz;
  
  import com.werken.werkz.DefaultGoal;
  
  import java.util.Iterator;
  import java.util.List;
  
  import org.apache.commons.jelly.JellyException;
  import org.apache.commons.jelly.XMLOutput;
  
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogFactory;
  
  /** 
   * Implements a &lt;target&gt; tag which is similar to the Ant equivalent tag
   * but is based on the Werkz goal engine.
   *
   * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
   * @version $Revision: 1.1 $
   */
  public class GoalTag extends WerkzTagSupport {
  
      /** The Log to which logging calls will be made. */
      private Log log = LogFactory.getLog(GoalTag.class);
      
      /** the name of the target */
      private String name;
      
      public GoalTag() {
      }
  
  
      // Tag interface
      //------------------------------------------------------------------------- 
      
      /** 
       * Evaluate the body to register all the various goals and pre/post conditions
       * then run all the current targets
       */
      public void doTag(final XMLOutput output) throws Exception {
          
          log.debug("doTag(..):" + name);
  
          // lets register a new goal...        
  		DefaultGoal goal = new DefaultGoal(name) {
  			public void performAction() throws Exception {
  				// lets run the body
  				log.debug("Running target: " + name);
  				getBody().run(context, output);
  			}
              public boolean requiresAction() {
                  return true;
              }
  		};
          getProject().addGoal(goal);
      }
  
  
      
      // Properties
      //------------------------------------------------------------------------- 
      /**
       * @return the name of the target
       */
      public String getName() {
          return name;
      }
  
      /**
       * Sets the name of the target
       */
      public void setName(String name) {
          log.debug("setName(" + name + ")" );
          this.name = name;
      }
  }
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/werkz/PostGoalTag.java
  
  Index: PostGoalTag.java
  ===================================================================
  /*
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  
  package org.apache.commons.jelly.tags.werkz;
  
  import com.werken.werkz.Goal;
  import com.werken.werkz.PostGoalCallback;
  
  import org.apache.commons.jelly.JellyException;
  import org.apache.commons.jelly.XMLOutput;
  
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogFactory;
  
  /** 
   * Implements a &lt;postTarget&gt; tag which provides a callback 
   * which is evaluated after a target has executed.
   *
   * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
   * @version $Revision: 1.1 $
   */
  public class PostGoalTag extends CallbackTagSupport {
  
      public PostGoalTag() {
      }
  
  
      // Tag interface
      //------------------------------------------------------------------------- 
      
      /** 
       * Evaluate the body to register all the various goals and pre/post conditions
       * then run all the current targets
       */
      public void doTag(final XMLOutput output) throws Exception {
          
          getGoal(getName()).addPostGoalCallback(
              new PostGoalCallback() {
                  public void firePostGoal(Goal goal) throws Exception {
                      // lets run the body
                      log.info( "Running post target: " + getName() );
                      getBody().run( context, output);                                   
    
                  }                
              }
          );            
      }
  }
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/werkz/PreGoalTag.java
  
  Index: PreGoalTag.java
  ===================================================================
  /*
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  
  package org.apache.commons.jelly.tags.werkz;
  
  import com.werken.werkz.Goal;
  import com.werken.werkz.PreGoalCallback;
  
  import org.apache.commons.jelly.JellyException;
  import org.apache.commons.jelly.XMLOutput;
  
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogFactory;
  
  /** 
   * Implements a &lt;preTarget&gt; tag which provides a callback 
   * which is evaluated before a target.
   *
   * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
   * @version $Revision: 1.1 $
   */
  public class PreGoalTag extends CallbackTagSupport {
  
      public PreGoalTag() {
      }
  
  
      // Tag interface
      //------------------------------------------------------------------------- 
      
      /** 
       * Evaluate the body to register all the various goals and pre/post conditions
       * then run all the current targets
       */
      public void doTag(final XMLOutput output) throws Exception {
          
          getGoal(getName()).addPreGoalCallback(
              new PreGoalCallback() {
                  public void firePreGoal(Goal goal) throws Exception {
                      // lets run the body
                      log.info( "Running pre target: " + getName() );
                      getBody().run( context, output);               
                  }                
              }
          );            
      }
  }
  
  
  
  1.3       +13 -11    jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/werkz/example.jelly
  
  Index: example.jelly
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/werkz/example.jelly,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- example.jelly	11 Jun 2002 22:59:22 -0000	1.2
  +++ example.jelly	12 Jun 2002 06:07:29 -0000	1.3
  @@ -3,29 +3,31 @@
   <werkz:project xmlns:j="jelly:core" xmlns="jelly:ant" xmlns:werkz="jelly:werkz">
   
     <!-- the following could be in the mediator of Maven -->
  -  <werkz:target name="init">
  +  <werkz:goal name="init">
     	<echo message="Initializing the project!"/>
  -  </werkz:target>
  +  </werkz:goal>
     		
  -  <werkz:target name="compile">
  +  <werkz:goal name="compile">
     	<echo message="About to compile the project!"/>
  -  </werkz:target>
  +  </werkz:goal>
   
  -  <werkz:target name="test">
  +  <werkz:goal name="test">
     	<echo message="About to run the tests!"/>
  -  </werkz:target>
  +  </werkz:goal>
   
   
    <!-- define some callbacks in the projects build.jelly -->
  - <werkz:preTarget name="compile">
  + <werkz:preGoal name="compile">
    	<echo message="I am a callback: doing something before I compile"/> 	  		
  - </werkz:preTarget>
  + </werkz:preGoal>
   
   
     <!-- call all the targets made on the command line -->	
  -  <j:forEach var="arg" items="${args}" begin="1">
  -  	<werkz:callTarget name="${arg}"/>
  -  </j:forEach>
  +  <werkz:attain>
  +      <j:forEach var="arg" items="${args}" begin="1">
  +          <werkz:attainGoal name="${arg}"/>
  +      </j:forEach>
  +  </werkz:attain>
     	
   </werkz:project>
   
  
  
  

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


Mime
View raw message