commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject cvs commit: jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly JellyContext.java
Date Mon, 22 Jul 2002 14:34:09 GMT
jstrachan    2002/07/22 07:34:09

  Modified:    jelly/src/test/org/apache/commons/jelly/sql testSql.jelly
                        example.jelly example2.jelly
               jelly    project.properties maven.xml
               jelly/src/script makeTagDoc.jelly
               jelly/src/java/org/apache/commons/jelly/expression/jexl
                        JexlExpression.java
               jelly/src/java/org/apache/commons/jelly JellyContext.java
  Added:       jelly/src/test/org/apache/commons/jelly/sql example3.jelly
  Log:
  patched the SQL demos so that the demo:sql target now properly demonstrates the SQL tags
in action, without the user needing to know anything or mess around with properties, or have
a HSQLDB server running or anything.
  
  the demo:sql target now creates an in-memory HSQLDB database, creates a table, inserts some
data, then demonstrates generating some XML from the result set.
  
  Revision  Changes    Path
  1.3       +8 -4      jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/sql/testSql.jelly
  
  Index: testSql.jelly
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/sql/testSql.jelly,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- testSql.jelly	3 Jun 2002 05:14:30 -0000	1.2
  +++ testSql.jelly	22 Jul 2002 14:34:09 -0000	1.3
  @@ -1,15 +1,19 @@
   <?xml version="1.0"?>
  -
   <j:jelly xmlns:j="jelly:core" xmlns:sql="jelly:sql">
   
  -  <sql:setDataSource var="db" url="${databaseUrl}" driver="${databaseDriver}" user="${databaseUser}"/>
  +  <sql:setDataSource 
  +  	var="db"
  +    url="${databaseUrl}" 
  +    driver="${databaseDriver}" 
  +    user="${databaseUser}"
  +    password="${databasePassword}"/>
   
     <sql:query var="results" dataSource="${db}">
  -      select * from <j:expr value="${databaseTable}"/>
  +      select * from ${databaseTable}
     </sql:query>
   
     <dataSet>
  -    <size><j:expr value="${results.rowCount}"/></size>
  +    <size>${results.rowCount}</size>
     </dataSet>
   
   </j:jelly>
  
  
  
  1.3       +7 -3      jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/sql/example.jelly
  
  Index: example.jelly
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/sql/example.jelly,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- example.jelly	3 Jun 2002 05:14:30 -0000	1.2
  +++ example.jelly	22 Jul 2002 14:34:09 -0000	1.3
  @@ -2,10 +2,14 @@
   
   <j:jelly xmlns:j="jelly:core" xmlns:sql="jelly:sql">
   
  -  <sql:setDataSource url="${databaseUrl}" driver="${databaseDriver}" user="${databaseUser}"/>
  +  <sql:setDataSource 
  +    url="${databaseUrl}" 
  +    driver="${databaseDriver}" 
  +    user="${databaseUser}"
  +    password="${databasePassword}"/>
   
     <sql:query var="results">
  -      select * from <j:expr value="${databaseTable}"/>
  +      select * from ${databaseTable}
     </sql:query>
   
     <dataSet>
  @@ -13,7 +17,7 @@
       <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>
                               
  +          <field column="${columnName}">${row[i]}</field>                 
              
           </j:forEach>
         </row>
       </j:forEach>                  
  
  
  
  1.4       +9 -4      jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/sql/example2.jelly
  
  Index: example2.jelly
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/sql/example2.jelly,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- example2.jelly	3 Jun 2002 05:14:30 -0000	1.3
  +++ example2.jelly	22 Jul 2002 14:34:09 -0000	1.4
  @@ -2,22 +2,27 @@
   
   <j:jelly xmlns:j="jelly:core" xmlns:sql="jelly:sql">
   
  -  <sql:setDataSource var="db" url="${databaseUrl}" driver="${databaseDriver}" user="${databaseUser}"/>
  +  <sql:setDataSource 
  +  	var="db"
  +    url="${databaseUrl}" 
  +    driver="${databaseDriver}" 
  +    user="${databaseUser}"
  +    password="${databasePassword}"/>
   
     <sql:query var="results" dataSource="${db}">
  -      select * from <j:expr value="${databaseTable}"/>
  +      select * from ${databaseTable}
     </sql:query>
   
     <dataSet>
   
       <j:forEach var="columnName" items="${results.columnNames}" indexVar="i">
  -      <column><j:expr value="${columnName}"/></column>              
                 
  +      <column>${columnName}</column>                                
       </j:forEach>
   
       <j:forEach items="${results.rowsByIndex}" var="row">
         <row>
           <j:forEach var="field" items="${row}">
  -          <field><j:expr value="${field}"/></field>                 
              
  +          <field>${field}</field>                                
           </j:forEach>
         </row>
       </j:forEach>                  
  
  
  
  1.3       +63 -31    jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/sql/example3.jelly
  
  
  
  
  1.11      +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.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- project.properties	22 Jul 2002 07:16:52 -0000	1.10
  +++ project.properties	22 Jul 2002 14:34:09 -0000	1.11
  @@ -2,6 +2,7 @@
   # P R O J E C T  P R O P E R T I E S
   # -------------------------------------------------------------------
   
  +
   maven.compile.debug = on
   maven.compile.optimize = off
   maven.compile.deprecation = off
  
  
  
  1.19      +24 -4     jakarta-commons-sandbox/jelly/maven.xml
  
  Index: maven.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/maven.xml,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- maven.xml	22 Jul 2002 11:15:51 -0000	1.18
  +++ maven.xml	22 Jul 2002 14:34:09 -0000	1.19
  @@ -285,22 +285,42 @@
      </goal>
   
   
  -   <demo name="demo:sql" prereqs="jelly-task" 
  +   <goal name="demo:sql" prereqs="jelly-task" 
         description="Runs an SQL demo">
         
         <!-- Values used for testing -->
  -	  <property name="databaseUrl"             value="jdbc:hsqldb:hsql://localhost"/>
  +	  <property name="databaseUrl"             value="jdbc:hsqldb:target/hsql"/>
   	  <property name="databaseDriver"          value="org.hsqldb.jdbcDriver"/>
   	  <property name="databaseUser"            value="sa"/>
   	  <property name="databaseTable"           value="SYSTEM_TABLES"/>
   
   	<echo message="Running examples and outputting results to target directory"/>
  -	
  +
  +    <java classname="org.apache.commons.jelly.Jelly" fork="yes">
  +      <classpath refid="test.classpath"/>
  +      <sysproperty key="databaseUrl" value="${databaseUrl}"/>
  +      <sysproperty key="databaseDriver" value="${databaseDriver}"/>
  +      <sysproperty key="databaseUser" value="${databaseUser}"/>
  +      <sysproperty key="databaseTable" value="${databaseTable}"/>
  +      <arg value="src/test/org/apache/commons/jelly/sql/example3.jelly"/> 
  +    </java>
  +    
  +<!--	
   	<jelly file="src/test/org/apache/commons/jelly/sql/example.jelly" output="target/sqloutput.xml"/>
   	<jelly file="src/test/org/apache/commons/jelly/sql/example2.jelly" output="target/sqloutput2.xml"/>

   	<jelly file="src/test/org/apache/commons/jelly/sql/testSql.jelly" output="target/sqloutput3.xml"/>
	
  -   </demo>
  +-->	
  +   </goal>
      
  +  <goal name="demo:hsql" prereqs="jelly-task"
  +    description="Runs a HSQL server, which can be useful for performing SQL tests">
  +    <delete>
  +      <fileset dir="." includes="test.*"/>
  +    </delete>	
  +    <java classname="org.hsqldb.Server" fork="yes">
  +      <classpath refid="test.classpath"/>
  +    </java>
  +  </goal>
   	
   
     <goal name="demo:tagdef" prereqs="java:compile"
  
  
  
  1.6       +1 -1      jakarta-commons-sandbox/jelly/src/script/makeTagDoc.jelly
  
  Index: makeTagDoc.jelly
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/script/makeTagDoc.jelly,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- makeTagDoc.jelly	22 Jul 2002 11:15:51 -0000	1.5
  +++ makeTagDoc.jelly	22 Jul 2002 14:34:09 -0000	1.6
  @@ -21,7 +21,7 @@
     <jsl:template match="versiontag"/>
   
     <!-- let other text and elements pass through via default rules-->
  -  <jsl:template match="*">
  +  <jsl:template match="*" trim="false">
       <jsl:copy>
         <jsl:applyTemplates/>
       </jsl:copy>
  
  
  
  1.9       +6 -6      jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/expression/jexl/JexlExpression.java
  
  Index: JexlExpression.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/expression/jexl/JexlExpression.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- JexlExpression.java	15 Jul 2002 16:54:55 -0000	1.8
  +++ JexlExpression.java	22 Jul 2002 14:34:09 -0000	1.9
  @@ -141,7 +141,7 @@
       }
   
       public Object get(Object key) {
  -        return context.getVariable( (String) key );
  +        return context.findVariable( (String) key );
       }
   
       public void clear() {
  
  
  
  1.19      +8 -9      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.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- JellyContext.java	22 Jul 2002 14:05:29 -0000	1.18
  +++ JellyContext.java	22 Jul 2002 14:34:09 -0000	1.19
  @@ -205,15 +205,14 @@
           Object answer = variables.get(name);
           if ( answer == null && parent != null ) {
               answer = parent.findVariable(name);
  -            
  -            // ### this is a hack - remove this when we have support for pluggable Scopes
  -            if ( answer == null ) {
  -                try {
  -                    answer = System.getProperty(name);
  -                }
  -                catch (Throwable t) {
  -                    // ignore security exceptions
  -                }
  +        }
  +        // ### this is a hack - remove this when we have support for pluggable Scopes
  +        if ( answer == null ) {
  +            try {
  +                answer = System.getProperty(name);
  +            }
  +            catch (Throwable t) {
  +                // ignore security exceptions
               }
           }
           return answer;
  
  
  

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


Mime
View raw message