You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by js...@apache.org on 2002/06/11 23:41:12 UTC
cvs commit: jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/core ExprTag.java
jstrachan 2002/06/11 14:41:11
Modified: jelly build.xml project.xml
jelly/src/java/org/apache/commons/jelly jelly.properties
jelly/src/java/org/apache/commons/jelly/tags/core
ExprTag.java
Added: jelly/src/java/org/apache/commons/jelly/tags/werkz
ProjectTag.java TargetTag.java PreTargetTag.java
CallbackTagSupport.java PostTargetTag.java
package.html WerkzTagSupport.java
WerkzTagLibrary.java CallTargetTag.java
jelly/src/test/org/apache/commons/jelly/werkz example.jelly
Log:
Added first cut of the Werkz tag library which implements goal orientated processing, not unlike Ant's <target> tags except there's full support for callbacks in a nice way.
This could provide a nice mechanism for implementing flexible pre/post callbacks and introduce new dependency mechanisms in a Maven build from inside a project.
Its not quite working yet, the <target> never gets fired, though the pre-callbacks do.
Revision Changes Path
1.1 jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/werkz/ProjectTag.java
Index: ProjectTag.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.Werkz;
import java.util.Iterator;
import java.util.List;
import org.apache.commons.jelly.JellyContext;
import org.apache.commons.jelly.JellyException;
import org.apache.commons.jelly.TagSupport;
import org.apache.commons.jelly.XMLOutput;
/**
* The root tag of a Project definition.
*
* @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
* @version $Revision: 1.8 $
*/
public class ProjectTag extends TagSupport {
/** the project */
private Werkz project = new Werkz();
public ProjectTag() {
}
/**
* @return the project instance
*/
public Werkz getProject() {
return project;
}
// Tag interface
//-------------------------------------------------------------------------
/**
* Evaluate the body to register all the various goals and pre/post conditions
* then run all the current targets
*/
public void doTag(XMLOutput output) throws Exception {
project.clear();
context.setVariable( "org.apache.commons.jelly.werkz.Project", project );
getBody().run(context, output);
}
// Implementation methods
//-------------------------------------------------------------------------
}
1.1 jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/werkz/TargetTag.java
Index: TargetTag.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 com.werken.werkz.Werkz;
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 <target> 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.8 $
*/
public class TargetTag extends WerkzTagSupport {
/** The Log to which logging calls will be made. */
private Log log = LogFactory.getLog(TargetTag.class);
/** the name of the target */
private String name;
public TargetTag() {
}
// 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 {
// lets register a new goal...
getProject().addGoal(
new DefaultGoal(name) {
public void performAction() throws Exception {
System.out.println( "Running target: " + name );
// lets run the body
log.info( "Running target: " + name );
getBody().run( context, output);
}
}
);
}
// Properties
//-------------------------------------------------------------------------
/**
* @return the name of the target
*/
public String getName() {
return name;
}
/**
* Sets the name of the target
*/
public void setName(String name) {
this.name = name;
}
}
1.1 jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/werkz/PreTargetTag.java
Index: PreTargetTag.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 <preTarget> tag which provides a callback
* which is evaluated before a target.
*
* @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
* @version $Revision: 1.8 $
*/
public class PreTargetTag extends CallbackTagSupport {
public PreTargetTag() {
}
// 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 {
System.out.println( "Calling pre target: " + getName() );
// lets run the body
log.info( "Running pre target: " + getName() );
getBody().run( context, output);
System.out.println( "Called pre target: " + getName() );
}
}
);
}
}
1.1 jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/werkz/CallbackTagSupport.java
Index: CallbackTagSupport.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 org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* Abstract base class for all callback tags.
*
* @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
* @version $Revision: 1.8 $
*/
public abstract class CallbackTagSupport extends WerkzTagSupport {
/** The Log to which logging calls will be made. */
protected Log log = LogFactory.getLog(getClass());
/** the name of the target */
private String name;
public CallbackTagSupport() {
}
// Properties
//-------------------------------------------------------------------------
/**
* @return the name of the target
*/
public String getName() {
return name;
}
/**
* Sets the name of the target
*/
public void setName(String name) {
this.name = name;
}
}
1.1 jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/werkz/PostTargetTag.java
Index: PostTargetTag.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 <postTarget> 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.8 $
*/
public class PostTargetTag extends CallbackTagSupport {
public PostTargetTag() {
}
// 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 PreGoalCallback() {
public void firePreGoal(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/package.html
Index: package.html
===================================================================
<html>
<head>
</head>
<body>
<p>A tag library for defining targets (goals) and having pre/post dependencies which uses the
<a href="http://werkz.sourceforge.net/">Werkz</a> library for resolving goals and dependencies.
</p>
</body>
</html>
1.1 jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/werkz/WerkzTagSupport.java
Index: WerkzTagSupport.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.Werkz;
import org.apache.commons.jelly.JellyException;
import org.apache.commons.jelly.TagSupport;
/**
* The abstract base class for Werkz child tags
*
* @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
* @version $Revision: 1.8 $
*/
public abstract class WerkzTagSupport extends TagSupport {
public WerkzTagSupport() {
}
// Implementation methods
//-------------------------------------------------------------------------
/**
* @return the goal of the given name or
* throws a JellyExceptoin if the goal could not be found
*/
protected Goal getGoal(String name) throws JellyException {
Werkz project = getProject();
if ( project == null ) {
throw new JellyException( "Must use this tag inside a <maven:project> tag" );
}
Goal goal = project.getGoal(name);
if ( goal == null ) {
throw new JellyException( "No such target name: " + name );
}
return goal;
}
/**
* @return the goal manager instance
*/
protected Werkz getProject() {
ProjectTag tag = (ProjectTag) findAncestorWithClass(ProjectTag.class);
if ( tag != null) {
return tag.getProject();
}
return (Werkz) context.getVariable( "org.apache.commons.jelly.werkz.Project" );
}
}
1.1 jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/werkz/WerkzTagLibrary.java
Index: WerkzTagLibrary.java
===================================================================
/*
* $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/xml/XMLTagLibrary.java,v 1.6 2002/05/17 18:04:00 jstrachan Exp $
* $Revision: 1.6 $
* $Date: 2002/05/17 18:04:00 $
*
* ====================================================================
*
* 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: XMLTagLibrary.java,v 1.6 2002/05/17 18:04:00 jstrachan Exp $
*/
package org.apache.commons.jelly.tags.werkz;
import java.util.Iterator;
import java.util.List;
import org.apache.commons.jelly.JellyContext;
import org.apache.commons.jelly.JellyException;
import org.apache.commons.jelly.Script;
import org.apache.commons.jelly.TagLibrary;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/** Implements a bunch of tags that are useful for working with Werkz.
*
* @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
* @version $Revision: 1.6 $
*/
public class WerkzTagLibrary extends TagLibrary {
/** The Log to which logging calls will be made. */
private Log log = LogFactory.getLog(WerkzTagLibrary.class);
public WerkzTagLibrary() {
registerTag("project", ProjectTag.class);
registerTag("target", TargetTag.class);
registerTag("preTarget", PreTargetTag.class);
registerTag("postTarget", PostTargetTag.class);
registerTag("callTarget", CallTargetTag.class);
}
}
1.1 jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/werkz/CallTargetTag.java
Index: CallTargetTag.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 org.apache.commons.jelly.JellyException;
import org.apache.commons.jelly.XMLOutput;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* Calls a target to ensure that its built.
*
* @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
* @version $Revision: 1.8 $
*/
public class CallTargetTag extends WerkzTagSupport {
/** The Log to which logging calls will be made. */
private Log log = LogFactory.getLog(CallTargetTag.class);
/** the name of the target */
private String name;
public CallTargetTag() {
}
// 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( "Trying to invoke target: " + name );
// attain the goal and throw up any exception to be caught by parent tags
getGoal(name).attain();
}
// Properties
//-------------------------------------------------------------------------
/**
* @return the name of the target
*/
public String getName() {
return name;
}
/**
* Sets the name of the target
*/
public void setName(String name) {
this.name = name;
}
}
1.40 +10 -0 jakarta-commons-sandbox/jelly/build.xml
Index: build.xml
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/jelly/build.xml,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -r1.39 -r1.40
--- build.xml 8 Jun 2002 16:45:10 -0000 1.39
+++ build.xml 11 Jun 2002 21:41:11 -0000 1.40
@@ -324,6 +324,16 @@
</target>
+ <target name="demo.werkz" depends="compile"
+ description="Runs a Werkz sample">
+ <java classname="org.apache.commons.jelly.Jelly" fork="yes">
+ <classpath refid="test.classpath"/>
+ <arg value="src/test/org/apache/commons/jelly/werkz/example.jelly"/>
+ <arg value="compile"/>
+ <arg value="test"/>
+ </java>
+ </target>
+
<target name="demo.args" depends="compile"
description="Runs a demo of processing command line arguments">
1.12 +15 -0 jakarta-commons-sandbox/jelly/project.xml
Index: project.xml
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/jelly/project.xml,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- project.xml 7 Jun 2002 12:26:46 -0000 1.11
+++ project.xml 11 Jun 2002 21:41:11 -0000 1.12
@@ -125,8 +125,23 @@
<version>2.0</version>
<jar>jdbc2_0-stdext.jar</jar>
</dependency>
+ <dependency>
+ <name>werkz</name>
+ <type>required</type>
+ <version>1.0-dev</version>
+ <jar>werkz-1.0-dev.jar</jar>
+ </dependency>
+
<!-- runtime dependencies only required for testing and sample programs -->
+ <!-- for werkz -->
+ <dependency>
+ <name>log4j</name>
+ <type>required</type>
+ <version>1.1.3</version>
+ <jar>log4j-1.1.3.jar</jar>
+ </dependency>
+
<dependency>
<name>hsqldb</name>
<type>required</type>
1.1 jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/werkz/example.jelly
Index: example.jelly
===================================================================
<?xml version="1.0"?>
<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">
target: init
<echo message="Initializing the project!"/>
</werkz:target>
<werkz:target name="compile">
target: compile
<echo message="About to compile the project!"/>
</werkz:target>
<werkz:target name="test">
target: test
<echo message="About to run the tests!"/>
</werkz:target>
<!-- define some callbacks in the projects build.jelly -->
<werkz:preTarget name="compile">
<echo message="I'm a callback: doing something before I compile"/>
</werkz:preTarget>
<!-- call all the targets made on the command line -->
<j:forEach var="arg" items="${args}" begin="1">
<werkz:callTarget name="${arg}"/>
</j:forEach>
</werkz:project>
1.10 +1 -0 jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/jelly.properties
Index: jelly.properties
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/jelly.properties,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- jelly.properties 30 May 2002 08:11:55 -0000 1.9
+++ jelly.properties 11 Jun 2002 21:41:11 -0000 1.10
@@ -4,6 +4,7 @@
xml = org.apache.commons.jelly.tags.xml.XMLTagLibrary
sql = org.apache.commons.jelly.tags.sql.SqlTagLibrary
jsl = org.apache.commons.jelly.tags.jsl.JSLTagLibrary
+werkz = org.apache.commons.jelly.tags.werkz.WerkzTagLibrary
# optional taglibs
ojb = org.apache.commons.jelly.tags.ojb.OjbTagLibrary
1.9 +12 -6 jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/core/ExprTag.java
Index: ExprTag.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/core/ExprTag.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- ExprTag.java 17 May 2002 15:18:08 -0000 1.8
+++ ExprTag.java 11 Jun 2002 21:41:11 -0000 1.9
@@ -72,6 +72,7 @@
/** A tag which evaluates an expression
*
+ * @tag out
* @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
* @version $Revision$
*/
@@ -99,7 +100,12 @@
// Properties
//-------------------------------------------------------------------------
- /** Sets the XPath expression to evaluate. */
+
+ /**
+ * Sets the Jexl expression to evaluate.
+ *
+ * @required true
+ */
public void setValue(Expression value) {
this.value = value;
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>