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/10/16 20:17:59 UTC
cvs commit: jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly suite.jelly
jstrachan 2002/10/16 11:17:59
Modified: jelly/src/test/org/apache/commons/jelly/define
beanSample.jelly
jelly/src/test/org/apache/commons/jelly suite.jelly
Added: jelly/src/java/org/apache/commons/jelly/tags/bean
package.html BeanPropertyTag.java BeandefTag.java
BeanTagLibrary.java
jelly/src/test/org/apache/commons/jelly/bean Order.java
TestJelly.java MyTagLibrary.java suite.jelly
Product.java Customer.java
Removed: jelly/src/test/org/apache/commons/jelly/define Customer.java
Log:
Added a simple little Jelly library which binds beans to tags. It works similarly to Ant with nested properties so provides a simple way to turn XML into beans.
While on the surface this may seem over the top when Digester and Betwixt (which is layered on top of Digester) do this perfectly well, using Jelly allows more complex directives like
* including other files
* using configurable properties or dynamic values in configuration files. So dynamic expressions can be used to hook-up objects or dynamically turn bits of the config on or off based on runtime properrties
* the same mechanism can be used inside things like workflow, unit testing, JellySwing etc
This library could be used to hack together an implementation of Ceki's Joran example for log4j
http://marc.theaimsgroup.com/?l=jakarta-commons-dev&m=103462608122650&w=2
Though it'd need 1 or to extra little tags to implement the appender ref and to collect the appenders together into a Map etc.
Hopefully some of the similar code in the define:bean and define:jellybean libraries could maybe be rationalised a little.
Revision Changes Path
1.1 jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/bean/package.html
Index: package.html
===================================================================
<html>
<head>
</head>
<body>
<p>
A tag library for mapping tags to beans using a similar approach to Ant.
</p>
</body>
</html>
1.1 jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/bean/BeanPropertyTag.java
Index: BeanPropertyTag.java
===================================================================
/*
* $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/taglibs/beanshell/src/java/org/apache/commons/jelly/tags/beanshell/BeanShellExpressionFactory.java,v 1.1 2002/05/21 07:58:55 jstrachan Exp $
* $Revision: 1.1 $
* $Date: 2002/05/21 07:58:55 $
*
* ====================================================================
*
* 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: BeanShellExpressionFactory.java,v 1.1 2002/05/21 07:58:55 jstrachan Exp $
*/
package org.apache.commons.jelly.tags.bean;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.beanutils.MethodUtils;
import org.apache.commons.jelly.JellyException;
import org.apache.commons.jelly.MissingAttributeException;
import org.apache.commons.jelly.TagSupport;
import org.apache.commons.jelly.XMLOutput;
import org.apache.commons.jelly.impl.BeanSource;
import org.apache.commons.jelly.tags.core.UseBeanTag;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* Creates a nested property via calling a beans createFoo() method then
* either calling the setFoo(value) or addFoo(value) methods in a similar way
* to how Ant tags construct themselves.
*
* @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
* @version $Revision: 1.1 $
*/
public class BeanPropertyTag extends UseBeanTag {
/** empty arguments constant */
private static final Object[] EMPTY_ARGS = {};
/** empty argument types constant */
private static final Class[] EMPTY_ARG_TYPES = {};
/** The Log to which logging calls will be made. */
private static final Log log = LogFactory.getLog(BeanPropertyTag.class);
/** the name of the property to create */
private String propertyName;
/** the name of the create method */
private String createMethodName;
/** the name of the adder method */
private String addMethodName;
public BeanPropertyTag(String propertyName) {
super(Object.class);
this.propertyName = propertyName;
int length = propertyName.length();
if (length > 0) {
createMethodName = "create"
+ propertyName.substring(0,1).toUpperCase()
+ propertyName.substring(1);
addMethodName = "add"
+ propertyName.substring(0,1).toUpperCase()
+ propertyName.substring(1);
}
}
/**
* Creates a new instance, try finding a parent property.
*/
protected Object newInstance(Class theClass, Map attributes, XMLOutput output) throws Exception {
Object parentObject = getParentObject();
if (parentObject != null) {
// now lets try call the create method...
Class parentClass = parentObject.getClass();
Method method = findCreateMethod(parentClass);
if (method != null) {
try {
return method.invoke(parentObject, EMPTY_ARGS);
}
catch (Exception e) {
throw new JellyException( "failed to invoke method: " + method + " on bean: " + parentObject + " reason: " + e, e );
}
}
}
else {
throw new JellyException( "The " + propertyName + " tag must be nested within a tag which maps to a bean property" );
}
return null;
}
/**
* By default this will export the bean using the given variable if it is defined.
* This Strategy method allows derived tags to process the beans in different ways
* such as to register this bean with its parent tag etc.
*/
protected void processBean(String var, Object bean) throws Exception {
if (var != null) {
context.setVariable(var, bean);
}
// now lets try set the parent property via calling the adder or the setter method
Object parentObject = getParentObject();
if (parentObject != null && bean != null) {
// lets see if there's a setter method...
Method method = findAddMethod(parentObject.getClass(), bean.getClass());
if (method != null) {
Object[] args = { bean };
try {
method.invoke(parentObject, args);
}
catch (Exception e) {
throw new JellyException( "failed to invoke method: " + method + " on bean: " + parentObject + " reason: " + e, e );
}
}
else {
BeanUtils.setProperty(parentObject, propertyName, bean);
}
}
}
/**
* Finds the Method to create a new property object
*/
protected Method findCreateMethod(Class theClass) {
if (createMethodName == null) {
return null;
}
return MethodUtils.getAccessibleMethod(
theClass, createMethodName, EMPTY_ARG_TYPES
);
}
/**
* Finds the Method to add the new bean
*/
protected Method findAddMethod(Class beanClass, Class valueClass) {
if (addMethodName == null) {
return null;
}
Class[] argTypes = { valueClass };
return MethodUtils.getAccessibleMethod(
beanClass, addMethodName, argTypes
);
}
/**
* @return the parent bean object
*/
protected Object getParentObject() throws Exception {
BeanSource tag = (BeanSource) findAncestorWithClass(BeanSource.class);
if (tag != null) {
return tag.getBean();
}
return null;
}
}
1.1 jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/bean/BeandefTag.java
Index: BeandefTag.java
===================================================================
/*
* $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/taglibs/beanshell/src/java/org/apache/commons/jelly/tags/beanshell/BeanShellExpressionFactory.java,v 1.1 2002/05/21 07:58:55 jstrachan Exp $
* $Revision: 1.1 $
* $Date: 2002/05/21 07:58:55 $
*
* ====================================================================
*
* 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: BeanShellExpressionFactory.java,v 1.1 2002/05/21 07:58:55 jstrachan Exp $
*/
package org.apache.commons.jelly.tags.bean;
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.TagSupport;
import org.apache.commons.jelly.XMLOutput;
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..
*
* @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
* @version $Revision: 1.1 $
*/
public class BeandefTag extends TagSupport {
/** The Log to which logging calls will be made. */
private static final Log log = LogFactory.getLog(BeandefTag.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 library in which to define this new bean tag */
private BeanTagLibrary library;
public BeandefTag(BeanTagLibrary library) {
this.library = library;
}
// 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);
}
}
}
// @todo should we allow the variable name to be specified?
library.registerBean(name, theClass);
}
// 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 setClass(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;
}
}
1.1 jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/bean/BeanTagLibrary.java
Index: BeanTagLibrary.java
===================================================================
/*
* $Header: $
* $Revision: 1.0 $
* $Date: $
*
* ====================================================================
*
* 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: $
*/
package org.apache.commons.jelly.tags.bean;
import java.util.Hashtable;
import java.util.Map;
import org.apache.commons.jelly.Tag;
import org.apache.commons.jelly.TagLibrary;
import org.apache.commons.jelly.impl.TagFactory;
import org.apache.commons.jelly.impl.TagScript;
import org.apache.commons.jelly.tags.core.UseBeanTag;
import org.xml.sax.Attributes;
/** Describes the Taglib. This class could be generated by XDoclet
*
* @author Theo Niemeijer
* @version $Revision: 1.14 $
*/
public class BeanTagLibrary extends TagLibrary {
/** Synchronized map of tag names to bean classes */
private Map beanTypes = new Hashtable();
public BeanTagLibrary() {
registerTagFactory(
"beandef",
new TagFactory() {
public Tag createTag(String name, Attributes attributes) throws Exception {
return new BeandefTag(BeanTagLibrary.this);
}
}
);
}
/**
* Allows tags to register new bean types
*/
public void registerBean(String name, Class type) {
beanTypes.put(name, type);
}
// TagLibrary interface
//-------------------------------------------------------------------------
public TagScript createTagScript(
final String name, final Attributes attributes
) throws Exception {
// check for standard tags first
TagScript answer = super.createTagScript(name, attributes);
if (answer != null) {
return answer;
}
// lets try a dynamic tag
return new TagScript( createTagFactory(name, attributes) );
}
// Implementation methods
//-------------------------------------------------------------------------
/**
* Factory method to create a TagFactory for a given tag attribute and attributes
*/
protected TagFactory createTagFactory(String name, Attributes attributes) throws Exception {
return new TagFactory() {
public Tag createTag(String name, Attributes attributes) throws Exception {
return createBeanTag(name, attributes);
}
};
}
protected Tag createBeanTag(String name, Attributes attributes) throws Exception {
// is the name bound to a specific class
Class beanType = getBeanType(name, attributes);
if (beanType != null) {
return new UseBeanTag(beanType);
}
// its a property tag
return new BeanPropertyTag(name);
}
protected Class getBeanType(String name, Attributes attributes) {
return (Class) beanTypes.get(name);
}
}
1.1 jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/bean/Order.java
Index: Order.java
===================================================================
/*
* $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/TestCoreTags.java,v 1.8 2002/05/28 07:20:06 jstrachan Exp $
* $Revision: 1.8 $
* $Date: 2002/05/28 07:20:06 $
*
* ====================================================================
*
* 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: TestCoreTags.java,v 1.8 2002/05/28 07:20:06 jstrachan Exp $
*/
package org.apache.commons.jelly.bean;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* A sample bean that we can construct via Jelly tags
*
* @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
* @version $Revision: 1.8 $
*/
public class Order {
/** The Log to which logging calls will be made. */
private static final Log log = LogFactory.getLog(Order.class);
private Product product;
private int amount;
private double price;
public Order() {
}
public String toString() {
return "Order[amount=" + amount + ";price=" + price + ";product=" + product + "]";
}
/**
* Factory method to create a new Product
*/
public Product createProduct() {
return new Product();
}
/**
* Returns the amount.
* @return int
*/
public int getAmount() {
return amount;
}
/**
* Returns the price.
* @return double
*/
public double getPrice() {
return price;
}
/**
* Sets the amount.
* @param amount The amount to set
*/
public void setAmount(int amount) {
this.amount = amount;
}
/**
* Sets the price.
* @param price The price to set
*/
public void setPrice(double price) {
this.price = price;
}
/**
* Returns the product.
* @return Product
*/
public Product getProduct() {
return product;
}
/**
* Sets the product.
* @param product The product to set
*/
public void setProduct(Product product) {
this.product = product;
}
}
1.1 jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/bean/TestJelly.java
Index: TestJelly.java
===================================================================
/*
* $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/core/JellyTestSuite.java,v 1.8 2002/07/06 13:53:39 dion Exp $
* $Revision: 1.8 $
* $Date: 2002/07/06 13:53:39 $
*
* ====================================================================
*
* 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: JellyTestSuite.java,v 1.8 2002/07/06 13:53:39 dion Exp $
*/
package org.apache.commons.jelly.bean;
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.8 $
*/
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/src/test/org/apache/commons/jelly/bean/MyTagLibrary.java
Index: MyTagLibrary.java
===================================================================
/*
* $Header: $
* $Revision: 1.0 $
* $Date: $
*
* ====================================================================
*
* 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: $
*/
package org.apache.commons.jelly.bean;
import org.apache.commons.jelly.tags.bean.BeanTagLibrary;
/**
* Describes the Taglib.
* This could be created via Jelly script, or could load the mapping of
* tag names to bean classes from properties file etc but is implemented in Java
* code for simplicity
*
* @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
* @version $Revision: 1.8 $
*/
public class MyTagLibrary extends BeanTagLibrary {
public MyTagLibrary() {
registerBean( "customer", Customer.class );
}
}
1.1 jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/bean/suite.jelly
Index: suite.jelly
===================================================================
<?xml version="1.0"?>
<test:suite
xmlns:j="jelly:core"
xmlns="jelly:org.apache.commons.jelly.bean.MyTagLibrary"
xmlns:test="jelly:junit"
xmlns:log="jelly:log">
<test:case name="simpleBean">
<customer var="c1" name="James" location="London" >
<order amount="100" price="2.99">
<product id="p1" name="Beer"/>
</order>
<order amount="200" price="4.99">
<product id="p2" name="Pizza"/>
</order>
</customer>
<log:info>Created a customer with name: ${c1.name} and location: ${c1.location}</log:info>
<log:info>Customer has orders ${c1.orders}</log:info>
<test:assertEquals expected="James" actual="${c1.name}"/>
<test:assertEquals expected="London" actual="${c1.location}"/>
<test:assertTrue test="${size(c1.orders) == 2}"/>
<test:assertTrue test="${c1.orders[0].amount == 100}"/>
<test:assertTrue test="${c1.orders[0].price == 2.99}"/>
<test:assertTrue test="${c1.orders[1].amount == 200}"/>
<test:assertTrue test="${c1.orders[1].price == 4.99}"/>
<test:assertTrue test="${c1.orders[0].product != null}"/>
<test:assertTrue test="${c1.orders[1].product != null}"/>
<test:assertEquals expected="p1" actual="${c1.orders[0].product.id}"/>
<test:assertEquals expected="Beer" actual="${c1.orders[0].product.name}"/>
<test:assertEquals expected="p2" actual="${c1.orders[1].product.id}"/>
<test:assertEquals expected="Pizza" actual="${c1.orders[1].product.name}"/>
</test:case>
</test:suite>
1.1 jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/bean/Product.java
Index: Product.java
===================================================================
/*
* $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/TestCoreTags.java,v 1.8 2002/05/28 07:20:06 jstrachan Exp $
* $Revision: 1.8 $
* $Date: 2002/05/28 07:20:06 $
*
* ====================================================================
*
* 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: TestCoreTags.java,v 1.8 2002/05/28 07:20:06 jstrachan Exp $
*/
package org.apache.commons.jelly.bean;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* A sample bean that we can construct via Jelly tags
*
* @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
* @version $Revision: 1.8 $
*/
public class Product {
/** The Log to which logging calls will be made. */
private static final Log log = LogFactory.getLog(Product.class);
private String id;
private String name;
public Product() {
}
public String toString() {
return "Product[id=" + id + ";name=" + name + "]";
}
// Properties
//-------------------------------------------------------------------------
/**
* Returns the id.
* @return String
*/
public String getId() {
return id;
}
/**
* Returns the name.
* @return String
*/
public String getName() {
return name;
}
/**
* Sets the id.
* @param id The id to set
*/
public void setId(String id) {
this.id = id;
}
/**
* Sets the name.
* @param name The name to set
*/
public void setName(String name) {
this.name = name;
}
}
1.1 jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/bean/Customer.java
Index: Customer.java
===================================================================
/*
* $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/TestCoreTags.java,v 1.8 2002/05/28 07:20:06 jstrachan Exp $
* $Revision: 1.8 $
* $Date: 2002/05/28 07:20:06 $
*
* ====================================================================
*
* 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: TestCoreTags.java,v 1.8 2002/05/28 07:20:06 jstrachan Exp $
*/
package org.apache.commons.jelly.bean;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* A sample bean that we can construct via Jelly tags
*
* @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
* @version $Revision: 1.8 $
*/
public class Customer {
/** The Log to which logging calls will be made. */
private static final Log log = LogFactory.getLog(Customer.class);
private String name;
private String city;
private String location;
private List orders = new ArrayList();
public Customer() {
}
public String toString() {
return super.toString() + "[name=" + name + ";city=" + city + "]";
}
/**
* Creates a new Order object
*/
public Order createOrder() {
return new Order();
}
public List getOrders() {
return orders;
}
public void addOrder(Order order) {
orders.add(order);
}
public void removeOrder(Order order) {
orders.remove(order);
}
/**
* Returns the city.
* @return String
*/
public String getCity() {
return city;
}
/**
* Returns the location.
* @return String
*/
public String getLocation() {
return location;
}
/**
* Returns the name.
* @return String
*/
public String getName() {
return name;
}
/**
* Sets the city.
* @param city The city to set
*/
public void setCity(String city) {
this.city = city;
}
/**
* Sets the location.
* @param location The location to set
*/
public void setLocation(String location) {
this.location = location;
}
/**
* Sets the name.
* @param name The name to set
*/
public void setName(String name) {
this.name = name;
}
}
1.2 +1 -1 jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/define/beanSample.jelly
Index: beanSample.jelly
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/define/beanSample.jelly,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- beanSample.jelly 17 Jul 2002 17:38:16 -0000 1.1
+++ beanSample.jelly 16 Oct 2002 18:17:58 -0000 1.2
@@ -18,7 +18,7 @@
|| we'll specify some required attributes and some default values
-->
- <define:bean name="customer" className="org.apache.commons.jelly.define.Customer">
+ <define:bean name="customer" className="org.apache.commons.jelly.bean.Customer">
<define:attribute name="name" required="true"/>
<define:attribute name="location" defaultValue="UK"/>
</define:bean>
1.8 +4 -4 jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/suite.jelly
Index: suite.jelly
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/suite.jelly,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- suite.jelly 12 Oct 2002 12:27:52 -0000 1.7
+++ suite.jelly 16 Oct 2002 18:17:58 -0000 1.8
@@ -93,7 +93,7 @@
</test:case>
<test:case name="testNewAndSetProperties">
- <j:new className="org.apache.commons.jelly.define.Customer" var="customer"/>
+ <j:new className="org.apache.commons.jelly.bean.Customer" var="customer"/>
<j:setProperties object="${customer}" name="James" city="London" />
<log:info>Created a new bean: ${customer}</log:info>
@@ -109,12 +109,12 @@
actual="${customer.city}"/>
<test:assertEquals
- expected="org.apache.commons.jelly.define.Customer"
+ expected="org.apache.commons.jelly.bean.Customer"
actual="${customer.class.name}"/>
</test:case>
<test:case name="testUseBean">
- <j:useBean var="customer" class="org.apache.commons.jelly.define.Customer" name="James" city="London" />
+ <j:useBean var="customer" class="org.apache.commons.jelly.bean.Customer" name="James" city="London" />
<log:info>Created a new bean: ${customer}</log:info>
@@ -129,7 +129,7 @@
actual="${customer.city}"/>
<test:assertEquals
- expected="org.apache.commons.jelly.define.Customer"
+ expected="org.apache.commons.jelly.bean.Customer"
actual="${customer.class.name}"/>
</test:case>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: cvs commit: jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly suite.jelly
Posted by James Strachan <ja...@yahoo.co.uk>.
From: "Ceki Gülcü" <ce...@qos.ch>
> Couple of hours ago, I committed changes to DOMConfigurator that
> enable it to deal with any nested tag that is specific to a given
> appender type. It was easier than I initially thought. The code is not
> trivial but not that complicated either.
>
> While the new DOMConfigurator can deal with arbitrary nested tags, it
> cannot deal with new top level tags. At this stage, that does not seem
> to be a severe limitation. With the capability to handle arbitrary
> nested tags, 80+ percent of log4j's needs are met.
>
> Adding support for arbitrary tags *anywhere* within the document will
> entail radical changes which do not seem warranted at this stage.
>
> Your recent commit increases my interest in jelly, but since the
> aforementioned DOMConfigurator changes let us avoid hitting the brick
> wall, we'll stay the course.
>
> Given its stringent reliability requirements, log4j is a special
> case.
No worries; I wanted a simple way to create graphs of beans from inside a
Jelly script anyways. Its very handy in many situations so I wasn't doing
this just for log4j. Plus I think log4j is a special case; there are
possible bootstrapping problems. Jelly uses commons-logging which can use
log4j, so if Jelly/Digester were used to initialize log4j there could be
some tricky bootstrap issues to figure out.
> However, in most other projects it is hard to justify
> an XML processing tool other than jelly. In my humble opinion, the
> missing ingredient is a tutorial consisting of 3 or 4 really simple
> examples and some handholding. Is it possible that such a tutorial
> exists but I've missed it?
You're absolutely right. Much more documentation and tutorials is required.
Once a couple of loose ends are tied up its gonna be my main focus.
James
-------
http://radio.weblogs.com/0112098/
__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: cvs commit:
jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly
suite.jelly
Posted by Ceki Gülcü <ce...@qos.ch>.
Couple of hours ago, I committed changes to DOMConfigurator that
enable it to deal with any nested tag that is specific to a given
appender type. It was easier than I initially thought. The code is not
trivial but not that complicated either.
While the new DOMConfigurator can deal with arbitrary nested tags, it
cannot deal with new top level tags. At this stage, that does not seem
to be a severe limitation. With the capability to handle arbitrary
nested tags, 80+ percent of log4j's needs are met.
Adding support for arbitrary tags *anywhere* within the document will
entail radical changes which do not seem warranted at this stage.
Your recent commit increases my interest in jelly, but since the
aforementioned DOMConfigurator changes let us avoid hitting the brick
wall, we'll stay the course.
Given its stringent reliability requirements, log4j is a special
case. However, in most other projects it is hard to justify
an XML processing tool other than jelly. In my humble opinion, the
missing ingredient is a tutorial consisting of 3 or 4 really simple
examples and some handholding. Is it possible that such a tutorial
exists but I've missed it?
At 18:17 16.10.2002 +0000, jstrachan@apache.org wrote:
>jstrachan 2002/10/16 11:17:59
>
> Modified: jelly/src/test/org/apache/commons/jelly/define
> beanSample.jelly
> jelly/src/test/org/apache/commons/jelly suite.jelly
> Added: jelly/src/java/org/apache/commons/jelly/tags/bean
> package.html BeanPropertyTag.java BeandefTag.java
> BeanTagLibrary.java
> jelly/src/test/org/apache/commons/jelly/bean Order.java
> TestJelly.java MyTagLibrary.java suite.jelly
> Product.java Customer.java
> Removed: jelly/src/test/org/apache/commons/jelly/define Customer.java
> Log:
> Added a simple little Jelly library which binds beans to tags. It works
> similarly to Ant with nested properties so provides a simple way to turn
> XML into beans.
> While on the surface this may seem over the top when Digester and
> Betwixt (which is layered on top of Digester) do this perfectly well,
> using Jelly allows more complex directives like
>
> * including other files
> * using configurable properties or dynamic values in configuration
> files. So dynamic expressions can be used to hook-up objects or
> dynamically turn bits of the config on or off based on runtime properrties
> * the same mechanism can be used inside things like workflow, unit
> testing, JellySwing etc
>
> This library could be used to hack together an implementation of Ceki's
> Joran example for log4j
>
> http://marc.theaimsgroup.com/?l=jakarta-commons-dev&m=103462608122650&w=2
>
> Though it'd need 1 or to extra little tags to implement the appender
> ref and to collect the appenders together into a Map etc.
>
> Hopefully some of the similar code in the define:bean and
> define:jellybean libraries could maybe be rationalised a little.
>
>
> Revision Changes Path
> 1.1
> jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/bean/package.html
>
> Index: package.html
> ===================================================================
> <html>
> <head>
> </head>
> <body>
>
> <p>
> A tag library for mapping tags to beans using a similar approach
> to Ant.
> </p>
>
> </body>
> </html>
>
>
--
Ceki
TCP implementations will follow a general principle of robustness: be
conservative in what you do, be liberal in what you accept from
others. -- Jon Postel, RFC 793
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>