jstrachan 02/05/22 11:13:41
Modified: betwixt build.xml .cvsignore
Added: betwixt LICENSE.txt project.properties project.xml
betwixt/xdocs overview.xml navigation.xml index.xml
Removed: betwixt/src/test/org/apache/commons/betwixt TestAll.java
Log:
Ported Betwixt to a Maven build. Some unit test cases still fail when run inside
Maven due to classpath problems; will patch those shortly.
Revision Changes Path
1.16 +151 -9 jakarta-commons-sandbox/betwixt/build.xml
Index: build.xml
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/betwixt/build.xml,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- build.xml 17 May 2002 15:24:11 -0000 1.15
+++ build.xml 22 May 2002 18:13:40 -0000 1.16
@@ -1,18 +1,160 @@
-<project name="Digester" default="compile" basedir=".">
+<!-- $Id: build.xml,v 1.16 2002/05/22 18:13:40 jstrachan Exp $ -->
-
-<!--
- "Digester" component of the Jakarta Commons Subproject
- $Id: build.xml,v 1.15 2002/05/17 15:24:11 jstrachan Exp $
--->
+<project name="betwixt" default="maven:jar" basedir=".">
<!-- ========== Initialize Properties ===================================== -->
+ <!-- Allow any user specific values to override the defaults -->
+ <property file="${user.home}/build.properties" />
+ <!-- Allow user defaults for this project -->
+ <property file="build.properties" />
+ <!-- Set default values for the build -->
+ <property file="project.properties" />
+
+<!-- maven:start -->
+
+<!-- ======================================================== -->
+<!-- D E L E G A T O R S -->
+<!-- ======================================================== -->
+
+<target name="maven:gump-descriptor">
+ <ant antfile="${maven.home}/plugins/core/build.xml" target="gump-descriptor"/>
+</target>
+
+<target name="maven:maven-update">
+ <ant antfile="${maven.home}/plugins/core/build.xml" target="maven-update"/>
+</target>
+
+<target name="maven:update-jars">
+ <ant antfile="${maven.home}/plugins/core/build.xml" target="update-jars"/>
+</target>
+
+<target name="maven:jar">
+ <ant antfile="${maven.home}/plugins/core/build.xml" target="jar"/>
+</target>
+
+<target name="maven:docs-quick">
+ <ant antfile="${maven.home}/plugins/docs/build.xml" target="docs-quick"/>
+</target>
+
+<target name="maven:run-singletest">
+ <ant antfile="${maven.home}/plugins/test/build.xml" target="run-singletest"/>
+</target>
+
+<target name="maven:compile">
+ <ant antfile="${maven.home}/plugins/core/build.xml" target="compile"/>
+</target>
+
+<target name="maven:fo">
+ <ant antfile="${maven.home}/plugins/docs/build.xml" target="fo"/>
+</target>
+
+<target name="maven:cvs-change-log">
+ <ant antfile="${maven.home}/plugins/docs/build.xml" target="cvs-change-log"/>
+</target>
+
+<target name="maven:war">
+ <ant antfile="${maven.home}/plugins/j2ee/build.xml" target="war"/>
+</target>
+
+<target name="maven:generate-reactor">
+ <ant antfile="${maven.home}/plugins/reactor/build.xml" target="generate-reactor"/>
+</target>
+
+<target name="maven:cross-ref">
+ <ant antfile="${maven.home}/plugins/docs/build.xml" target="cross-ref"/>
+</target>
+
+<target name="maven:deploy-site">
+ <ant antfile="${maven.home}/plugins/docs/build.xml" target="deploy-site"/>
+</target>
+
+<target name="maven:ear">
+ <ant antfile="${maven.home}/plugins/j2ee/build.xml" target="ear"/>
+</target>
+
+<target name="maven:install-jar">
+ <ant antfile="${maven.home}/plugins/core/build.xml" target="install-jar"/>
+</target>
+
+<target name="maven:task-list">
+ <ant antfile="${maven.home}/plugins/docs/build.xml" target="task-list"/>
+</target>
+
+<target name="maven:docs">
+ <ant antfile="${maven.home}/plugins/docs/build.xml" target="docs"/>
+</target>
+
+<target name="maven:site">
+ <ant antfile="${maven.home}/plugins/docs/build.xml" target="site"/>
+</target>
+
+<target name="maven:deploy-dist">
+ <ant antfile="${maven.home}/plugins/core/build.xml" target="deploy-dist"/>
+</target>
+
+<target name="maven:javadocs">
+ <ant antfile="${maven.home}/plugins/docs/build.xml" target="javadocs"/>
+</target>
+
+<target name="maven:announce">
+ <ant antfile="${maven.home}/plugins/core/build.xml" target="announce"/>
+</target>
+
+<target name="maven:check-source">
+ <ant antfile="${maven.home}/plugins/core/build.xml" target="check-source"/>
+</target>
+
+<target name="maven:dist">
+ <ant antfile="${maven.home}/plugins/core/build.xml" target="dist"/>
+</target>
+
+<target name="maven:dist-build">
+ <ant antfile="${maven.home}/plugins/core/build.xml" target="dist-build"/>
+</target>
+
+<target name="maven:metrics">
+ <ant antfile="${maven.home}/plugins/metrics/build.xml" target="metrics"/>
+</target>
+
+<target name="maven:clean">
+ <ant antfile="${maven.home}/plugins/core/build.xml" target="clean"/>
+</target>
+
+<target name="maven:env">
+ <ant antfile="${maven.home}/plugins/core/build.xml" target="env"/>
+</target>
+
+<target name="maven:test">
+ <ant antfile="${maven.home}/plugins/test/build.xml" target="test"/>
+</target>
+
+<target name="maven:pdf">
+ <ant antfile="${maven.home}/plugins/docs/build.xml" target="pdf"/>
+</target>
+
+<target name="maven:iutest">
+ <ant antfile="${maven.home}/plugins/iutest/build.xml" target="iutest"/>
+</target>
+
+<target name="maven:activity-log">
+ <ant antfile="${maven.home}/plugins/docs/build.xml" target="activity-log"/>
+</target>
+
+<target name="maven:verify-project">
+ <ant antfile="${maven.home}/plugins/core/build.xml" target="verify-project"/>
+</target>
+
+<target name="maven:validate-pom">
+ <ant antfile="${maven.home}/plugins/core/build.xml" target="validate-pom"/>
+</target>
+
+<target name="maven:validate-war">
+ <ant antfile="${maven.home}/plugins/j2ee/build.xml" target="validate-war"/>
+</target>
- <property file="build.properties"/> <!-- Component local -->
- <property file="../build.properties"/> <!-- Commons local -->
- <property file="${user.home}/build.properties"/> <!-- User local -->
+<!-- maven:end -->
<!-- ========== External Dependencies ===================================== -->
1.2 +4 -0 jakarta-commons-sandbox/betwixt/.cvsignore
Index: .cvsignore
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/betwixt/.cvsignore,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- .cvsignore 22 Aug 2001 12:25:01 -0000 1.1
+++ .cvsignore 22 May 2002 18:13:40 -0000 1.2
@@ -1,2 +1,6 @@
build.properties
dist
+target
+velocity.log
+.project
+
1.1 jakarta-commons-sandbox/betwixt/LICENSE.txt
Index: LICENSE.txt
===================================================================
/*
* $Header: /home/cvs/jakarta-commons/LICENSE,v 1.4 2002/04/11 13:24:02 dion Exp $
* $Revision: 1.4 $
* $Date: 2002/04/11 13:24:02 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999-2001 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 [EMAIL PROTECTED]
*
* 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/>.
*
*/
1.1 jakarta-commons-sandbox/betwixt/project.properties
Index: project.properties
===================================================================
# -------------------------------------------------------------------
# P R O J E C T P R O P E R T I E S
# -------------------------------------------------------------------
compile.debug = on
compile.optimize = off
compile.deprecation = off
maven.jarResources.basedir=${basedir}/src/java
# use Sun coding standards
maven.checkstyle.lcurly.type = eol
maven.checkstyle.lcurly.method = eol
maven.checkstyle.lcurly.other = eol
#maven.checkstyle.header.file = src/conf/checkstyle-LICENSE.txt
maven.checkstyle.header.ignore.line = 1,2,3,4,5,6
maven.checkstyle.const.pattern = ^[a-z][a-zA-Z0-9]*$
# disable these non-critical errors to highlight
# more important ones line missing javadoc
maven.checkstyle.max.line.len = 100
maven.checkstyle.ignore.whitespace = true
maven.checkstyle.ignore.public.in.interface = true
1.1 jakarta-commons-sandbox/betwixt/project.xml
Index: project.xml
===================================================================
<?xml version="1.0" encoding="UTF-8"?>
<project>
<version>2</version>
<name>commons-betwixt</name>
<id>commons-betwixt</id>
<currentVersion>1.0-dev</currentVersion>
<organization>
<name>Apache Software Foundation</name>
<url>http://www.apache.org</url>
</organization>
<inceptionYear>2002</inceptionYear>
<package>org.apache.commons.betwixt</package>
<shortDescription>Commons Betwixt</shortDescription>
<gumpRepositoryId>jakarta</gumpRepositoryId>
<description>Commons Betwixt: mapping beans to XML</description>
<url>http://jakarta.apache.org/commons/sandbox/betwixt.html</url>
<cvsWebUrl>http://cvs.apache.org/viewcvs/jakarta-commons-sandbox/betwixt/</cvsWebUrl>
<cvsModule>jakarta-commons-sandbox/betwixt</cvsModule>
<issueTrackingUrl>http://nagoya.apache.org/</issueTrackingUrl>
<siteAddress>jakarta.apache.org</siteAddress>
<siteDirectory>/www/jakarta.apache.org/commons/sandbox/betwixt/</siteDirectory>
<mailingLists>
<mailingList>
<name>Commons Dev List</name>
<subscribe>[EMAIL PROTECTED]</subscribe>
<unsubscribe>[EMAIL PROTECTED]</unsubscribe>
<archive>http://nagoya.apache.org/eyebrowse/SummarizeList?[EMAIL PROTECTED]</archive>
</mailingList>
</mailingLists>
<developers>
<developer>
<name>James Strachan</name>
<id>jstrachan</id>
<email>[EMAIL PROTECTED]</email>
<organization>SpiritSoft, Inc.</organization>
</developer>
<developer>
<name>Robert Burrell Donkin</name>
<id>robertdonkin</id>
<email>[EMAIL PROTECTED]</email>
<organization></organization>
</developer>
</developers>
<dependencies>
<dependency>
<name>commons-logging</name>
<type>required</type>
<version>1.0</version>
<jar>commons-logging-1.0.jar</jar>
</dependency>
<dependency>
<name>commons-beanutils</name>
<type>required</type>
<version>1.2</version>
<jar>commons-beanutils-1.2.jar</jar>
</dependency>
<dependency>
<name>commons-collections</name>
<type>required</type>
<version>2.0</version>
<jar>commons-collections-2.0.jar</jar>
</dependency>
<dependency>
<name>commons-digester</name>
<type>required</type>
<version>1.2</version>
<jar>commons-digester-1.2.jar</jar>
</dependency>
<!-- runtime dependencies only required for testing and sample programs -->
<!--
<dependency>
<name>xercesImpl</name>
<type>required</type>
<version>2.0.0</version>
<jar>xercesImpl-2.0.0.jar</jar>
</dependency>
<dependency>
<name>xmlParseAPIs</name>
<type>required</type>
<version>2.0.0</version>
<jar>xmlParserAPIs-2.0.0.jar</jar>
</dependency>
-->
</dependencies>
<build>
<sourceDirectories>
<sourceDirectory>src/java</sourceDirectory>
</sourceDirectories>
<unitTestSourceDirectory>src/test</unitTestSourceDirectory>
<aspectSourceDirectories></aspectSourceDirectories>
<unitTestPatterns>
<unitTestPattern>include = **/Test*.java</unitTestPattern>
</unitTestPatterns>
<jarResources>
<jarResource>include = **/*.properties, **/*.xml</jarResource>
</jarResources>
<jars></jars>
<nagEmailAddress>[EMAIL PROTECTED]</nagEmailAddress>
</build>
</project>
1.1 jakarta-commons-sandbox/betwixt/xdocs/overview.xml
Index: overview.xml
===================================================================
<?xml version="1.0"?>
<document>
<properties>
<title>Betwixt Overview</title>
<author email="[EMAIL PROTECTED]">James Strachan</author>
</properties>
<body>
<section name="Getting Started">
<p>Probably the best way to get started is to look at some examples. The best
example to start with is the Ant target "demo.rss" which runs the
RSSBeanWriter
sample program in the src/test directory. Once you've got the Jakarta Commons
build system working, by installing Ant and creating your own build.properties
to point to the required JARs type the following at a command line</p>
<pre>ant demo-rss</pre>
<p>This uses the Commons Digester RSSDigester example to parse an RSS document,
create a Channel bean and then write it out again as XML using the default
XMLIntrospector and the BeanWriter. You should see the XML come out from the
Channel bean which looks similar to a real RSS document.</p>
<p>The next example to look at is</p>
<pre>ant demo-rss2</pre>
<p>This is similar to the above but uses a BeanReader to parse the RSS file. So
this is Betwixt defaulting the Digester rules required to parse the XML document.
Then the BeanWriter is used to output the beans that get created.</p>
</section>
<section name="Mapping beans to XML">
<p>There are various ways of mapping beans to an XML structure. For example
consider a simple bean</p>
<pre>public class CustomerBean {
public String getName();
public Order[] getOrders();
public String[] getEmailAddresses();
}</pre>
<p>This could be mapped to XML as these various ways</p>
<section name="Example 1">
<p>This example uses attributes for primitive types.</p>
<pre><CustomerBean name="James">
<order id="1">...</order>
<order id="2">...</order>
<emailAddress>[EMAIL PROTECTED]</emailAddress>
</CustomerBean></pre>
</section>
<section name="Example 2">
<p>This example uses elements for all properties and wraps collections in an
extra element (which can be quite common in XML schemas). Also note that some
element names have been changed.</p>
<pre><customer>
<name>James</name>
<orders>
<order id="1">...</order>
<order id="2">...</order>
</orders>
<email-addresses>
<email-address>[EMAIL PROTECTED]</email-address>
</email-addresses>
</customer> </pre>
<p>Betwixt aims to provide a diversity of possible mappings such that the
developer can choose, if they wish, how their beans appear as XML to support
whatever XML encoding scheme that is desired. If no particular mapping is
provided then Betwixt will create a default mapping for you. Also the
customization mechanism allows you to just override the parts you want to and
let Betwixt default the rest. So if you just want to rename a property in XML
for a certain type, thats all you need to do. No need to hand-code what Betwixt
can deduce for itself. </p>
</section>
</section>
<section name="Customizing the mapping of a bean to XML">
<p>The XMLIntrospector will look for files of the form <i>className.betwixt</i>
on the classpath using the same ClassLoader used to load the given class and use
that document to specify the mapping to XML. If this file does not exist
then the default introspection rules are used.</p>
<p>The simplest possible file may just set the name of the element. e.g.</p>
<pre><?xml version="1.0" encoding="UTF-8" ?>
<info>
<element name="channel"/>
<addDefaults/>
</info></pre>
<p>The above means to use the name 'channel' for the outer most element for the
given type. The <addDefaults> means to add the defaults from the introspector.
This allows you to just rename a few properties then let the introspector do the
rest. There is also a <hide> element which allows one or more properties to be
hidden. Also note that the <element> and <attribute> tags can be
nested to any
kind of depth allowing whatever XML structure you wish. This can be useful if
you wish to wrap collections in some arbitrary collection tags or to group
properties of a bean together in some XML structure. e.g.</p>
<pre><?xml version="1.0" encoding="UTF-8" ?>
<info primitiveTypes="attribute">
<element name="channel"/>
<element name="customerList">
<element name="customer" property="customers"/>
</element>
<element name="foo">
<attribute name="qqq" property="ppp"/>
<element name="bar" property="xyz"/>
<hide property="something"/>
<addDefaults/>
</element>
</info>
</pre>
<p>The primitiveTypes attribute in the <info> element is optional and can be
used to specify whether primitive java types (strings, numbers, dates etc) are
specified as attributes or elements by default.</p>
<p>Finally static text can be specified using a value attribute inside an
<element> or <attribute> tag. e.g. to add constant attributes such
as a version label to the
generated XML...</p>
<pre><?xml version="1.0" encoding="UTF-8" ?>
<info primitiveTypes="element">
<element name="rss"/>
<attribute name="version" value="0.91"/>
<element name="channel"/>
<addDefaults/>
</element>
</info>
</pre>
</section>
<section name="Bean naming conventions">
<p>The Java Beans specification contains various naming conventions that should
be used when writing beans that will allow the beans introspector to
automatically guess the properties in a bean and their getters & setter methods
etc. Betwixt will use these same naming conventions to deduce how to make the
beans appear as XML. There are some other naming conventions that you can use to
make your beans easier to output as XML or parse.</p>
</section>
<section name="Using adder methods for composite properties">
<p>This naming convention is used to indicate the singular type of some composite
property.</p>
<p>To use: create an add method to match the getter method for 'composite
properties'.</p>
<pre>public class SomeBean {
public <CollectionType> getFoo*();
public void addFoo(<SingularType> foo);
}</pre>
<p>Where CollectionType can be an array, a Collection, Enumeration, Iterator,
Map. The [SinglularType] refers to the type of an item in the collection. The
name of the getter property starts with 'Foo'. So 'Foo' is the singular name,
the plural collection name could be Foos, FooArray, FooList, FooIterator or some
other encoding, though the plural name should start with the singular name for
auto-detection to work properly.</p>
<section name="Examples">
<p>In the RSS example from Digester there's a bean which matches this pattern.</p>
<pre>
public class Channel
public Item[] getItems();
public void addItem(Item item);
}
</pre>
<p>This means that the following bean does not match this naming convention,
since the plural property name does not start with the singular name..</p>
<pre>public class Foo {
public Collection getPeople();
public void addPerson(Person person);
}</pre>
<p>Though these two beans do match</p>
<pre>public class Foo {
public Collection getPersonCollection();
public void addPerson(Person person);
}
public class Foo {
public Iterator getPersonIterator();
public void addPerson(Person person);
}
</pre>
<p>The following are other valid examples of <i>composite-getter</i> methods and
their matching <i>adder</i> methods.</p>
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse"
bordercolor="#111111" width="100%">
<tr>
<td width="50%" align="center"><b>Composite getter method</b></td>
<td width="50%" align="center"><b>Adder method</b></td>
</tr>
<tr>
<td width="50%" align="center">getChildren()</td>
<td width="50%" align="center">addChild()</td>
</tr>
<tr>
<td width="50%" align="center">getPersonList()</td>
<td width="50%" align="center">addPerson()</td>
</tr>
<tr>
<td width="50%" align="center">getItems()</td>
<td width="50%" align="center">addItem()</td>
</tr>
<tr>
<td width="50%" align="center">getChannels()</td>
<td width="50%" align="center">addChannel()</td>
</tr>
<tr>
<td width="50%" align="center">getSheep()</td>
<td width="50%" align="center">addSheep()</td>
</tr>
</table>
</section>
</section>
</body>
</document>
1.1 jakarta-commons-sandbox/betwixt/xdocs/navigation.xml
Index: navigation.xml
===================================================================
<?xml version="1.0" encoding="ISO-8859-1"?>
<project name="Jelly">
<title>Betwixt</title>
<organizationLogo href="/images/jakarta-logo-blue.gif">Jakarta</organizationLogo>
<body>
<menu name="Betwixt">
<item name="Overview" href="/index.html"/>
<item name="Detail" href="/overview.html"/>
</menu>
</body>
</project>
1.1 jakarta-commons-sandbox/betwixt/xdocs/index.xml
Index: index.xml
===================================================================
<?xml version="1.0"?>
<document>
<properties>
<title>Betixt: turning beans into XML</title>
<author email="[EMAIL PROTECTED]">James Strachan</author>
</properties>
<body>
<section name="Betwixt : turning beans into XML">
<p>
The Betwixt library provides an XML introspection mechanism
for mapping beans to XML in a flexible way. It is implemented using an
XMLIntrospector and XMLBeanInfo classes which are similar to the standard
Introspector and BeanInfo from the Java Beans specification.</p>
<p>
Betwixt provides a way of turning beans into XML as well as automatically
generating digester rules in a way that can be customized on a per type
manner in the same way that the BeanInfo mechanism can be used to customize
the default introspection on a java object.</p>
</section>
</body>
</document>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>