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/05/21 18:53:27 UTC
cvs commit: jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly JellyContext.java
jstrachan 02/05/21 09:53:27
Modified: jelly build.xml project.properties project.xml
build-old.xml
jelly/src/test/org/apache/commons/jelly example3.jelly
example2.jelly
jelly/src/java/org/apache/commons/jelly/tags/sql
DataSourceWrapper.java QueryTag.java
jelly/src/java/org/apache/commons/jelly/task JellyTask.java
jelly/xdocs navigation.xml
jelly/src/java/org/apache/commons/jelly JellyContext.java
Added: jelly .build.properties
jelly/src/test/org/apache/commons/jelly
show_ant_properties.jelly
jelly/src/test/org/apache/commons/jelly/sql example3.jelly
Log:
Ported the old build system back into the Maven build so that common sample programs can be ran as Ant targets such as
ant demo.hw
for the hello world script or
ant demo.ant
for the Ant based demo.
Revision Changes Path
1.23 +97 -34 jakarta-commons-sandbox/jelly/build.xml
Index: build.xml
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/jelly/build.xml,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- build.xml 21 May 2002 11:13:57 -0000 1.22
+++ build.xml 21 May 2002 16:53:26 -0000 1.23
@@ -11,6 +11,28 @@
<property file="build.properties" />
<!-- Set default values for the build -->
<property file="project.properties" />
+
+ <!-- the default build location -->
+ <property name="maven.build.dest" value="target/classes"/>
+
+ <path id="test.classpath">
+ <pathelement path="${maven.build.dest}"/>
+ <pathelement location="${lib.repo}/commons-logging-1.0.jar"/>
+ <pathelement location="${lib.repo}/commons-beanutils-20020520.jar"/>
+ <pathelement location="${lib.repo}/commons-collections-2.0.jar"/>
+ <pathelement location="${lib.repo}/commons-digester-1.2.jar"/>
+ <pathelement location="${lib.repo}/commons-jexl-1.0-dev.jar"/>
+ <pathelement location="${lib.repo}/dom4j-1.4-dev.jar"/>
+ <pathelement location="${lib.repo}/hsqldb.jar"/>
+ <pathelement location="${lib.repo}/velocity-1.4-dev.jar"/>
+ <pathelement location="/jpackages/jaxp-1.1/jaxp.jar"/>
+ <pathelement location="/jpackages/jaxp-1.1/crimson.jar"/>
+<!--
+ <pathelement location="${lib.repo}/xmlParserAPIs-2.0.0.jar"/>
+ <pathelement location="${lib.repo}/xercesImpl-2.0.0.jar"/>
+-->
+ <pathelement location="${lib.repo}/jdbc2_0-stdext.jar"/>
+ </path>
<!-- maven:start -->
@@ -46,6 +68,10 @@
<ant antfile="${maven.home}/plugins/core/build.xml" target="compile"/>
</target>
+ <target name="maven:jar-resources">
+ <ant antfile="${maven.home}/plugins/core/build.xml" target="jar-resources"/>
+ </target>
+
<target name="maven:fo">
<ant antfile="${maven.home}/plugins/docs/build.xml" target="fo"/>
</target>
@@ -166,23 +192,16 @@
<target name="site" depends="maven:site"/>
<target name="test" depends="maven:test"/>
-
-<!-- ========== Sample Program Targets ==================================== -->
-<!--
+ <target name="compile" depends="maven:compile, maven:jar-resources">
+ <taskdef
+ name="jelly"
+ classname="org.apache.commons.jelly.task.JellyTask">
+ <classpath refid="test.classpath"/>
+ </taskdef>
+ </target>
- try port this to use the new Maven dependency classpath....
-
- <target name="demo.all" depends="compile"
- description="Runs all the demo scripts inside one single script">
- <java classname="org.apache.commons.jelly.Jelly" fork="yes">
- <classpath refid="test.classpath"/>
- <arg value="src/test/org/apache/commons/jelly/run_all.jelly"/>
- <arg value="one"/>
- <arg value="two"/>
- <arg value="three"/>
- </java>
- </target>
+<!-- ========== Sample Program Targets ==================================== -->
<target name="demo.hw" depends="compile"
description="Runs the Hello World demo">
@@ -192,11 +211,60 @@
</java>
</target>
+ <target name="demo.ant" depends="compile"
+ description="Runs demo which displays Ant properties">
+
+ <jelly file="src/test/org/apache/commons/jelly/show_ant_properties.jelly" output="target/ant.html"/>
+
+ </target>
+
+
+ <target name="demo.sql" depends="compile"
+ description="Runs an SQL demo">
+
+ <!-- Values used for testing -->
+ <property name="databaseUrl" value="jdbc:hsqldb:hsql://localhost"/>
+ <property name="databaseDriver" value="org.hsqldb.jdbcDriver"/>
+ <property name="databaseUser" value="sa"/>
+ <property name="databaseTable" value="SYSTEM_TABLES"/>
+
+ <echo message="Running example 3"/>
+
+<!--
+ <java classname="org.apache.commons.jelly.Jelly" fork="yes">
+ <classpath refid="test.classpath"/>
+ <arg value="src/test/org/apache/commons/jelly/sql/example3.jelly"/>
+ <sysproperty key="org.apache.commons.logging.simplelog.defaultlog" value="debug"/>
+ </java>
+-->
+
+ <taskdef
+ name="jelly"
+ classname="org.apache.commons.jelly.task.JellyTask">
+ <classpath refid="test.classpath"/>
+ </taskdef>
+
+ <echo message="Running example"/>
+
+ <jelly file="src/test/org/apache/commons/jelly/sql/example3.jelly" output="target/sqloutput.xml"/>
+ <jelly file="src/test/org/apache/commons/jelly/sql/example.jelly" output="target/sqloutput.xml"/>
+<!--
+ <jelly file="src/test/org/apache/commons/jelly/sql/example.jelly" output="${maven.build.dest}/sqloutput.xml"/>
+ <jelly file="src/test/org/apache/commons/jelly/sql/example2.jelly" output="${maven.build.dest}/sqloutput2.xml"/>
+ <jelly file="src/test/org/apache/commons/jelly/sql/testSql.jelly" output="${maven.build.dest}/sqloutput3.xml"/>
+-->
+ </target>
+
+
+<!--
<target name="demo.1" depends="compile"
description="Runs demo #1">
<java classname="org.apache.commons.jelly.Jelly" fork="yes">
<classpath refid="test.classpath"/>
- <arg value="src/test/org/apache/commons/jelly/example2.jelly"/>
+ <arg value="src/test/org/apache/commons/jelly/testing123.jelly"/>
+ <arg value="one"/>
+ <arg value="two"/>
+ <arg value="three"/>
</java>
</target>
@@ -204,10 +272,7 @@
description="Runs demo #2">
<java classname="org.apache.commons.jelly.Jelly" fork="yes">
<classpath refid="test.classpath"/>
- <arg value="src/test/org/apache/commons/jelly/testing123.jelly"/>
- <arg value="one"/>
- <arg value="two"/>
- <arg value="three"/>
+ <arg value="src/test/org/apache/commons/jelly/example2.jelly"/>
</java>
</target>
@@ -230,6 +295,17 @@
</java>
</target>
+ <target name="demo.all" depends="compile"
+ description="Runs all the demo scripts inside one single script">
+ <java classname="org.apache.commons.jelly.Jelly" fork="yes">
+ <classpath refid="test.classpath"/>
+ <arg value="src/test/org/apache/commons/jelly/run_all.jelly"/>
+ <arg value="one"/>
+ <arg value="two"/>
+ <arg value="three"/>
+ </java>
+ </target>
+
<target name="demo.pnuts" depends="compile, checkPNuts"
description="Runs a pnuts demo which displays system properties">
<java classname="org.apache.commons.jelly.Jelly" fork="yes">
@@ -245,19 +321,6 @@
<arg value="src/test/org/apache/commons/jelly/javascript/example.jelly"/>
</java>
</target>
-
-
- <target name="demo.sql" depends="compile"
- description="Runs an SQL demo">
- <taskdef
- name="jelly"
- classname="org.apache.commons.jelly.task.JellyTask">
- <classpath refid="test.classpath"/>
- </taskdef>
-
- <jelly file="src/test/org/apache/commons/jelly/sql/example.jelly" output="${build.home}/sqloutput.xml"/>
- <jelly file="src/test/org/apache/commons/jelly/sql/example2.jelly" output="${build.home}/sqloutput2.xml"/>
- <jelly file="src/test/org/apache/commons/jelly/sql/testSql.jelly" output="${build.home}/sqloutput3.xml"/>
- </target>
-->
+
</project>
1.3 +1 -0 jakarta-commons-sandbox/jelly/project.properties
Index: project.properties
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/jelly/project.properties,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- project.properties 21 May 2002 12:04:18 -0000 1.2
+++ project.properties 21 May 2002 16:53:26 -0000 1.3
@@ -25,3 +25,4 @@
maven.checkstyle.ignore.whitespace = true
maven.checkstyle.ignore.public.in.interface = true
+
1.3 +8 -0 jakarta-commons-sandbox/jelly/project.xml
Index: project.xml
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/jelly/project.xml,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- project.xml 21 May 2002 11:13:57 -0000 1.2
+++ project.xml 21 May 2002 16:53:26 -0000 1.3
@@ -104,6 +104,14 @@
<jar>jdbc2_0-stdext.jar</jar>
</dependency>
+<!-- runtime dependencies only required for testing and sample programs -->
+ <dependency>
+ <name>hsqldb</name>
+ <type>required</type>
+ <version>1.7.0</version>
+ <jar>hsqldb-1.7.0.jar</jar>
+ </dependency>
+
</dependencies>
<build>
1.2 +10 -2 jakarta-commons-sandbox/jelly/build-old.xml
Index: build-old.xml
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/jelly/build-old.xml,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- build-old.xml 21 May 2002 08:01:31 -0000 1.1
+++ build-old.xml 21 May 2002 16:53:26 -0000 1.2
@@ -137,12 +137,10 @@
<!-- ========== Test Execution Defaults =================================== -->
-
<!-- Construct unit test classpath -->
<path id="test.classpath">
<pathelement location="${build.home}/classes"/>
<pathelement location="${build.home}/tests"/>
- <pathelement location="${build.home}/classes"/>
<pathelement location="${jaxp.jaxp.jar}"/>
<pathelement location="${jaxp.parser.jar}"/>
<pathelement location="${dom4j.jar}"/>
@@ -487,6 +485,16 @@
classname="org.apache.commons.jelly.task.JellyTask">
<classpath refid="test.classpath"/>
</taskdef>
+
+ <echo message="JAXP ${jaxp.jaxp.jar} and parser ${jaxp.parser.jar}"/>
+ <echo message="${commons-logging.jar}"/>
+ <echo message="${commons-beanutils.jar}"/>
+ <echo message="${commons-collections.jar}"/>
+ <echo message="${commons-digester.jar}"/>
+ <echo message="${dom4j.jar}"/>
+ <echo message="${jexl.jar}"/>
+ <echo message="${velocity-dep.jar}"/>
+ <echo message="${database.jar}"/>
<jelly file="src/test/org/apache/commons/jelly/sql/example.jelly" output="${build.home}/sqloutput.xml"/>
<jelly file="src/test/org/apache/commons/jelly/sql/example2.jelly" output="${build.home}/sqloutput2.xml"/>
1.1 jakarta-commons-sandbox/jelly/.build.properties
Index: .build.properties
===================================================================
# junit.jar - JUnit 3.2+ Classpath
junit.jar=/java/junit/junit.jar
# jakarta-commons-collections.jar
commons-collections.jar=/jakarta/lib.repo/commons-collections-2.0.jar
commons-logging.jar=/jakarta/lib.repo/commons-logging-1.0.jar
commons-digester.jar=/jakarta/lib.repo/commons-digester-1.2.jar
commons-beanutils.jar=/jakarta/lib.repo/commons-beanutils-20020520.jar
jexl.jar=/jakarta/lib.repo/commons-jexl-1.0-dev.jar
velocity-dep.jar=/jakarta/lib.repo/velocity-1.4-dev.jar
dom4j.jar=/jakarta/lib.repo/dom4j-1.4-dev.jar
database.jar=/jakarta/lib.repo/hsqldb-1.7.0.jar
1.4 +12 -18 jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/example3.jelly
Index: example3.jelly
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/example3.jelly,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- example3.jelly 25 Apr 2002 16:35:55 -0000 1.3
+++ example3.jelly 21 May 2002 16:53:26 -0000 1.4
@@ -1,20 +1,14 @@
-<?xml version="1.0"?>
-
-<jelly xmlns="jelly:core">
- <!-- a really silly way to do this but -->
- <!-- this should test the choose/when/otherwise tags -->
- <forEach var="iter" items="System.getProperties()">
- <choose>
- <when test='iter.key.equals( "java.home" )'>
- Java Home = <expr value="iter.value"/>
- </when>
- <when test='iter.key.equals( "java.version" )'>
- Java Version = <expr value="iter.value"/>
- </when>
- <otherwise>
- <expr value="iter.key"/> = <expr value="iter.value"/>
- </otherwise>
- </choose>
- </forEach>
+<?xml version="1.0"?>
<jelly xmlns="jelly:core">
+ <!-- a really silly way to do this but -->
<!-- this should test the choose/when/otherwise tags -->
<forEach var="iter" items="System.getProperties()">
<choose>
<when test='iter.key.equals( "java.home" )'>
+ Java Home = <expr value="iter.value"/>
+ </when>
+ <when test='iter.key.equals( "java.version" )'>
+ Java Version = <expr value="iter.value"/>
+ </when>
+ <otherwise>
+ <expr value="iter.key"/> = <expr value="iter.value"/>
+ </otherwise>
+ </choose>
+ </forEach>
</jelly>
1.4 +25 -27 jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/example2.jelly
Index: example2.jelly
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/example2.jelly,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- example2.jelly 25 Apr 2002 16:35:55 -0000 1.3
+++ example2.jelly 21 May 2002 16:53:26 -0000 1.4
@@ -1,33 +1,31 @@
<?xml version="1.0"?>
-
<j:jelly xmlns:j="jelly:core" xmlns:x="jelly:xml">
- <x:parse var="doc">
- <web-app>
- <servlet>
- <servlet-name>snoop</servlet-name>
- <servlet-class>SnoopServlet</servlet-class>
- </servlet>
- <servlet>
- <servlet-name>file</servlet-name>
- <servlet-class>ViewFile</servlet-class>
- <init-param>
- <param-name>initial</param-name>
- <param-value>1000</param-value>
- <description>
- The initial value for the counter <!-- optional -->
- </description>
- </init-param>
- </servlet>
- <servlet-mapping>
- <servlet-name>snoop</servlet-name>
- <url-pattern>/foo/snoop</url-pattern>
- </servlet-mapping>
- </web-app>
+ <x:parse var="doc">
<web-app>
+ <servlet>
+ <servlet-name>snoop</servlet-name>
+ <servlet-class>SnoopServlet</servlet-class>
+ </servlet>
+ <servlet>
+ <servlet-name>file</servlet-name>
+ <servlet-class>ViewFile</servlet-class>
+ <init-param>
+ <param-name>initial</param-name>
+ <param-value>1000</param-value>
+ <description>
+ The initial value for the counter <!-- optional -->
+ </description>
+ </init-param>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>snoop</servlet-name>
+ <url-pattern>/foo/snoop</url-pattern>
+ </servlet-mapping>
+ </web-app>
</x:parse>
- <x:set var="count" select="count($doc//servlet)"/>
- <x:forEach var="s" select="$doc//servlet">
- name: <x:expr select="$s/servlet-name"/>
- class: <x:expr select="$s/servlet-class"/>
+ <x:set var="count" select="count($doc//servlet)"/>
+ <x:forEach var="s" select="$doc//servlet">
+ name: <x:expr select="$s/servlet-name"/>
+ class: <x:expr select="$s/servlet-class"/>
</x:forEach>
There are <x:expr select="$count"/> servlet(s)
</j:jelly>
1.1 jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/show_ant_properties.jelly
Index: show_ant_properties.jelly
===================================================================
<?xml version="1.0"?>
<j:jelly xmlns:j="jelly:core">
<html>
<body>
<h1>Ant properties</h1>
<p>The project name is <b><j:expr value="${project.name}"/></b>
</p>
<table>
<tr>
<th>Targets</th>
</tr>
<j:forEach var="iter" items="${project.targets}">
<tr>
<td><j:expr value="${iter.key}"/></td>
</tr>
</j:forEach>
</table>
<table>
<tr>
<th>Property Name</th>
<th>Property Value</th>
</tr>
<j:forEach var="iter" items="${project.getProperties()}">
<tr>
<td><j:expr value="${iter.key}"/></td>
<td><j:expr value="${iter.value}"/></td>
</tr>
</j:forEach>
</table>
</body>
</html>
</j:jelly>
1.4 +4 -0 jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/sql/DataSourceWrapper.java
Index: DataSourceWrapper.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/sql/DataSourceWrapper.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- DataSourceWrapper.java 17 May 2002 15:18:09 -0000 1.3
+++ DataSourceWrapper.java 21 May 2002 16:53:26 -0000 1.4
@@ -125,6 +125,10 @@
conn = DriverManager.getConnection(jdbcURL);
}
+ if (log.isDebugEnabled()) {
+ log.debug(
+ "Created connection: " + conn );
+ }
return conn;
}
1.6 +10 -0 jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/sql/QueryTag.java
Index: QueryTag.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/sql/QueryTag.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- QueryTag.java 20 May 2002 12:43:15 -0000 1.5
+++ QueryTag.java 21 May 2002 16:53:26 -0000 1.6
@@ -219,6 +219,8 @@
Result result = null;
String sqlStatement = null;
+ log.info( "About to lookup connection" );
+
try {
conn = getConnection();
@@ -251,9 +253,17 @@
*/
PreparedStatement ps = conn.prepareStatement(sqlStatement);
setParameters(ps, parameters);
+
+ log.info( "About to execute query: " + sqlStatement );
+
ResultSet rs = ps.executeQuery();
+
+ log.info( "About to create result set" );
+
result = new ResultImpl(rs, startRow, maxRows);
context.setVariable(var, result);
+
+ log.info( "Created results and defined variable: " + var );
}
catch (SQLException e) {
throw new JellyException(sqlStatement + ": " + e.getMessage(), e);
1.4 +3 -1 jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/task/JellyTask.java
Index: JellyTask.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/task/JellyTask.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- JellyTask.java 17 May 2002 15:18:15 -0000 1.3
+++ JellyTask.java 21 May 2002 16:53:26 -0000 1.4
@@ -75,7 +75,9 @@
}
Script script = compileScript();
- script.run( getJellyContext(), getXMLOutput() );
+ JellyContext context = getJellyContext();
+ context.setVariable( "project", project );
+ script.run( context, getXMLOutput() );
getXMLOutput().close();
}
catch (Exception e) {
1.2 +3 -2 jakarta-commons-sandbox/jelly/xdocs/navigation.xml
Index: navigation.xml
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/jelly/xdocs/navigation.xml,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- navigation.xml 21 May 2002 08:01:31 -0000 1.1
+++ navigation.xml 21 May 2002 16:53:26 -0000 1.2
@@ -5,8 +5,9 @@
<organizationLogo href="/images/jakarta-logo-blue.gif">Jakarta</organizationLogo>
<body>
- <menu name="Documentation">
- <item name="Overview" href="/overview.html"/>
+ <menu name="Jelly">
+ <item name="Overview" href="/index.html"/>
+ <item name="Detail" href="/overview.html"/>
</menu>
</body>
</project>
1.1 jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/sql/example3.jelly
Index: example3.jelly
===================================================================
<?xml version="1.0"?>
<j:jelly xmlns:j="jelly:core" xmlns:sql="jelly:sql">
<dataSet>
about to create a datase connection....
<sql:setDataSource url="jdbc:hsqldb:hsql://localhost" driver="org.hsqldb.jdbcDriver" user="sa"/>
created database connection, now doing query....
<sql:query var="results">
select * from SYSTEM_TABLES
</sql:query>
now iterating over results
<!--
<j:forEach items="${results.rowsByIndex}" var="row">
<row>
<j:forEach var="columnName" items="${results.columnNames}" indexVar="i">
<field column="${columnName}"><j:expr value="${row[i]}"/></field>
</j:forEach>
</row>
</j:forEach>
-->
</dataSet>
</j:jelly>
1.6 +1 -2 jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/JellyContext.java
Index: JellyContext.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/JellyContext.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- JellyContext.java 17 May 2002 15:18:12 -0000 1.5
+++ JellyContext.java 21 May 2002 16:53:26 -0000 1.6
@@ -115,8 +115,7 @@
}
public JellyContext(URL rootContext) {
- this.rootContext = rootContext;
- this.currentJellyContext = rootContext;
+ this( rootContext, rootContext );
}
public JellyContext(URL rootContext, URL currentJellyContext) {
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>