velocity-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cbris...@apache.org
Subject svn commit: r1871468 - in /velocity/engine/trunk: ./ velocity-engine-examples/ velocity-engine-examples/src/assembly/ velocity-engine-examples/src/etc/ velocity-engine-examples/src/etc/app_example1/ velocity-engine-examples/src/etc/app_example2/ veloci...
Date Sat, 14 Dec 2019 12:20:11 GMT
Author: cbrisson
Date: Sat Dec 14 12:20:11 2019
New Revision: 1871468

URL: http://svn.apache.org/viewvc?rev=1871468&view=rev
Log:
[engine] Refresh examples packaging

Added:
    velocity/engine/trunk/velocity-engine-examples/README.md
    velocity/engine/trunk/velocity-engine-examples/src/assembly/
    velocity/engine/trunk/velocity-engine-examples/src/assembly/examples.xml
    velocity/engine/trunk/velocity-engine-examples/src/etc/build.sh
    velocity/engine/trunk/velocity-engine-examples/src/etc/dbcontexttest.sh
      - copied, changed from r1871467, velocity/engine/trunk/velocity-engine-examples/src/etc/context_example/dbcontexttest.sh
    velocity/engine/trunk/velocity-engine-examples/src/etc/example1.sh
      - copied, changed from r1871467, velocity/engine/trunk/velocity-engine-examples/src/etc/app_example1/example.sh
    velocity/engine/trunk/velocity-engine-examples/src/etc/example2.sh
      - copied, changed from r1871467, velocity/engine/trunk/velocity-engine-examples/src/etc/app_example2/example2.sh
    velocity/engine/trunk/velocity-engine-examples/src/etc/xmlapp_example.sh
      - copied, changed from r1871467, velocity/engine/trunk/velocity-engine-examples/src/etc/xmlapp_example/xmlapp_example.sh
    velocity/engine/trunk/velocity-engine-examples/src/main/resources/example1.vm
      - copied unchanged from r1871467, velocity/engine/trunk/velocity-engine-examples/src/main/resources/example.vm
Removed:
    velocity/engine/trunk/velocity-engine-examples/src/etc/README.txt
    velocity/engine/trunk/velocity-engine-examples/src/etc/app_example1/
    velocity/engine/trunk/velocity-engine-examples/src/etc/app_example2/
    velocity/engine/trunk/velocity-engine-examples/src/etc/context_example/
    velocity/engine/trunk/velocity-engine-examples/src/etc/event_example/
    velocity/engine/trunk/velocity-engine-examples/src/etc/xmlapp_example/
    velocity/engine/trunk/velocity-engine-examples/src/main/resources/example.vm
Modified:
    velocity/engine/trunk/pom.xml
    velocity/engine/trunk/velocity-engine-examples/pom.xml
    velocity/engine/trunk/velocity-engine-examples/src/main/java/org/apache/velocity/example/DBContext.java
    velocity/engine/trunk/velocity-engine-examples/src/main/java/org/apache/velocity/example/EventExample.java
    velocity/engine/trunk/velocity-engine-examples/src/main/java/org/apache/velocity/example/Example2.java
    velocity/engine/trunk/velocity-engine-examples/src/main/resources/velocity.properties

Modified: velocity/engine/trunk/pom.xml
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/pom.xml?rev=1871468&r1=1871467&r2=1871468&view=diff
==============================================================================
--- velocity/engine/trunk/pom.xml (original)
+++ velocity/engine/trunk/pom.xml Sat Dec 14 12:20:11 2019
@@ -127,6 +127,11 @@
                     <artifactId>extra-enforcer-rules</artifactId>
                     <version>1.2</version>
                 </plugin>
+                <plugin>
+                    <groupId>org.apache.maven.plugins</groupId>
+                    <artifactId>maven-assembly-plugin</artifactId>
+                    <version>3.2.0</version>
+                </plugin>
             </plugins>
         </pluginManagement>
         <plugins>

Added: velocity/engine/trunk/velocity-engine-examples/README.md
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-examples/README.md?rev=1871468&view=auto
==============================================================================
--- velocity/engine/trunk/velocity-engine-examples/README.md (added)
+++ velocity/engine/trunk/velocity-engine-examples/README.md Sat Dec 14 12:20:11 2019
@@ -0,0 +1,83 @@
+# Welcome to Velocity!
+
+This package contains a few examples to help get you started.
+
+As always, the if you have any questions :
+
+1. Make sure you followed any directions :-) (did you build
+   everything?)
+
+2. Review documentation included in this package, or online at
+   [https://velocity.apache.org/](https://velocity.apache.org/)
+
+3. Ask on the [velocity-user list](https://velocity.apache.org/contact.html#user). 
+   This is a great source of support information.  To join, read the
+   [contact page](https://velocity.apache.org/contact.html) and then follow the links to
join the lists.
+
+## Building from sources
+
+To build these examples from Velocity sources, please refer to the [Velocity build page](https://velocity.apache.org/engine/${project.version}/build.html).
The build will generate the zip archive target/${project.build.finalName}-pkg.zip containing
all the examples.
+
+The archive contains a `build.sh` script which you can use to re-build the examples after
tweaking the sources in the `src` directory.
+
+## Running the examples
+
+Once you have downloaded or sucessfully built the ${project.build.finalName}-pkg.zip downloaded
package, unzip it in the location of your choice and change to the ${project.build.finalName}
directory.
+
+Note for Windows users: the shell scripts used to running the examples are meant for linux
or BSD, but can easily be adapted as batch files. all they do is build the classpath from
the jars in the lib/ directory, then invoke Java on the main class with the adequate arguments.
+
+Finally, note that more examples of using Velocity can be found in the velocity-tools subject.
 Of special note is the VelocityViewServlet, a quick and easy way to build a web application
that uses Velocity.
+
+   https://velocity.apache.org/tools/
+
+# Velocity Examples
+
+## Application Example #1
+
+This simple example shows how to use the Velocity Template Engine
+in a standalone program.  It should be pre-compiled for you. Run it using the example
+template provided (`example.vm`):
+
+    ./example1.sh
+
+## Application Example #2
+
+Another simple example showing how to use Velocity in a standalone
+program.  This examples uses the org.apache.velocity.util.Velocity application utility
+class, which provides a few convenient methods for application programmers.  It also
+should be precompiled for you.  To run:
+
+    ./example2.sh
+
+## Context Example
+
+This is a demonstration of 2 different context implementations:
+
+- a context implementation that uses a database as the storage. You will need to copy the
appropriate JDBC driver jar file in the lib/ directory, and to adapt the JDBC driver and credentials
accordingly in the `src/org/apache/velocity/example/DBContextTest.java` file.
+
+- a context implementation that uses a `TreeMap` for storage.  Very simple.
+
+To run:
+
+    ./dbcontexttest.sh
+
+## Xml App example
+
+This is simple example that demonstrates direct access of XML data via
+Velocity templates, as well as Velocimacro recursion. To run:
+
+    ./xmlapp_example.sh
+
+## Event Example
+
+This is a simple yet more advanced example, and shows how to use the event handling
+features of Velocity.  This is an advanced topic, so if you are just
+starting with Velocity, you can come back to it later. To run:
+
+    ./event_example.sh
+
+___
+
+Thanks for using Velocity!
+
+>the Velocity team

Modified: velocity/engine/trunk/velocity-engine-examples/pom.xml
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-examples/pom.xml?rev=1871468&r1=1871467&r2=1871468&view=diff
==============================================================================
--- velocity/engine/trunk/velocity-engine-examples/pom.xml (original)
+++ velocity/engine/trunk/velocity-engine-examples/pom.xml Sat Dec 14 12:20:11 2019
@@ -1,22 +1,22 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
 
-    Licensed to the Apache Software Foundation (ASF) under one
-    or more contributor license agreements.  See the NOTICE file
-    distributed with this work for additional information
-    regarding copyright ownership.  The ASF licenses this file
-    to you under the Apache License, Version 2.0 (the
-    "License"); you may not use this file except in compliance
-    with the License.  You may obtain a copy of the License at
-
-      http://www.apache.org/licenses/LICENSE-2.0
-
-    Unless required by applicable law or agreed to in writing,
-    software distributed under the License is distributed on an
-    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-    KIND, either express or implied.  See the License for the
-    specific language governing permissions and limitations
-    under the License.
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
 
 -->
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
@@ -26,7 +26,7 @@
         <artifactId>velocity-engine-parent</artifactId>
         <version>2.2-SNAPSHOT</version>
     </parent>
-
+    
     <artifactId>velocity-engine-examples</artifactId>
     <name>Apache Velocity Engine - Examples</name>
     <description>Very simple examples to use Velocity</description>
@@ -37,7 +37,48 @@
                 <groupId>org.apache.felix</groupId>
                 <artifactId>maven-bundle-plugin</artifactId>
             </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-dependency-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <phase>prepare-package</phase>
+                        <goals>
+                            <goal>copy-dependencies</goal>
+                        </goals>
+                        <configuration>
+                            <outputDirectory>${project.build.directory}/lib</outputDirectory>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-resources-plugin</artifactId>
+                <configuration>
+                    <outputDirectory>${project.build.directory}/examples</outputDirectory>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-assembly-plugin</artifactId>
+                <configuration>
+                    <descriptors>
+                        <descriptor>src/assembly/examples.xml</descriptor>
+                    </descriptors>
+                </configuration>
+            </plugin>
         </plugins>
+        <resources>
+            <resource>
+                <directory>src/main/resources</directory>
+                <filtering>true</filtering>
+            </resource>
+            <resource>
+                <directory>src/etc</directory>
+                <filtering>true</filtering>
+            </resource>
+        </resources>
     </build>
 
     <dependencies>
@@ -51,5 +92,11 @@
             <artifactId>jdom</artifactId>
             <version>1.1.3</version>
         </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-simple</artifactId>
+            <version>${slf4j.version}</version>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
 </project>

Added: velocity/engine/trunk/velocity-engine-examples/src/assembly/examples.xml
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-examples/src/assembly/examples.xml?rev=1871468&view=auto
==============================================================================
--- velocity/engine/trunk/velocity-engine-examples/src/assembly/examples.xml (added)
+++ velocity/engine/trunk/velocity-engine-examples/src/assembly/examples.xml Sat Dec 14 12:20:11
2019
@@ -0,0 +1,62 @@
+<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0 http://maven.apache.org/xsd/assembly-2.0.0.xsd">
+    <id>pkg</id>
+    <baseDirectory>${project.build.directory}</baseDirectory>
+    <includeBaseDirectory>false</includeBaseDirectory>
+    <formats>
+        <format>zip</format>
+    </formats>
+    <fileSets>
+        <!-- copy dependencies to lib/ -->
+        <fileSet>
+            <directory>${project.build.directory}</directory>
+            <outputDirectory>${project.build.finalName}</outputDirectory>
+            <includes>
+                <include>lib/*.jar</include>
+            </includes>
+        </fileSet>
+        <!-- copy self jar to lib/ -->
+        <fileSet>
+            <directory>${project.build.directory}</directory>
+            <outputDirectory>${project.build.finalName}/lib</outputDirectory>
+            <includes>
+                <include>${project.build.finalName}.jar</include>
+            </includes>
+        </fileSet>
+        <!-- copy examples resources -->
+        <fileSet>
+            <directory>${project.build.directory}/examples</directory>
+            <outputDirectory>${project.build.finalName}</outputDirectory>
+            <includes>
+                <include>*.vm</include>
+                <include>*.xml</include>
+                <include>*.properties</include>
+            </includes>
+        </fileSet>
+        <!-- copy examples scripts -->
+        <fileSet>
+            <directory>${project.build.directory}/examples</directory>
+            <outputDirectory>${project.build.finalName}</outputDirectory>
+            <fileMode>0755</fileMode>
+            <includes>
+                <include>*.sh</include>
+            </includes>
+        </fileSet>
+        <!-- copy readme file -->
+        <fileSet>
+            <directory>${project.basedir}</directory>
+            <outputDirectory>${project.build.finalName}</outputDirectory>
+            <includes>
+                <include>README.md</include>
+            </includes>
+        </fileSet>
+        <!-- copy sources -->
+        <fileSet>
+            <directory>${project.basedir}/src/main/java</directory>
+            <outputDirectory>${project.build.finalName}/src</outputDirectory>
+            <includes>
+                <include>**/*.java</include>
+            </includes>
+        </fileSet>
+    </fileSets>
+</assembly>

Added: velocity/engine/trunk/velocity-engine-examples/src/etc/build.sh
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-examples/src/etc/build.sh?rev=1871468&view=auto
==============================================================================
--- velocity/engine/trunk/velocity-engine-examples/src/etc/build.sh (added)
+++ velocity/engine/trunk/velocity-engine-examples/src/etc/build.sh Sat Dec 14 12:20:11 2019
@@ -0,0 +1,40 @@
+#!/bin/sh
+
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+echo "Building examples..."
+
+echo rm lib/${project.build.finalName}.jar
+rm lib/${project.build.finalName}.jar
+
+_VELCP=.
+for i in lib/*.jar
+do
+    _VELCP="$_VELCP:$i"
+done
+
+# convert the unix path to windows
+if [ "$OSTYPE" = "cygwin32" ] || [ "$OSTYPE" = "cygwin" ] ; then
+    _VELCP=`cygpath --path --windows "$_VELCP"`
+fi
+
+echo "Using classpath $_VELCP"
+
+find src -name "*.java" > sources.txt
+mkdir classes
+javac -cp $_VELCP -d classes @sources.txt && jar cf lib/${project.build.finalName}.jar
-C classes . && echo "Build successful."

Copied: velocity/engine/trunk/velocity-engine-examples/src/etc/dbcontexttest.sh (from r1871467,
velocity/engine/trunk/velocity-engine-examples/src/etc/context_example/dbcontexttest.sh)
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-examples/src/etc/dbcontexttest.sh?p2=velocity/engine/trunk/velocity-engine-examples/src/etc/dbcontexttest.sh&p1=velocity/engine/trunk/velocity-engine-examples/src/etc/context_example/dbcontexttest.sh&r1=1871467&r2=1871468&rev=1871468&view=diff
==============================================================================
--- velocity/engine/trunk/velocity-engine-examples/src/etc/context_example/dbcontexttest.sh
(original)
+++ velocity/engine/trunk/velocity-engine-examples/src/etc/dbcontexttest.sh Sat Dec 14 12:20:11
2019
@@ -1,4 +1,4 @@
-# !/bin/sh
+#!/bin/sh
 
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
@@ -17,30 +17,24 @@
 # specific language governing permissions and limitations
 # under the License.
 
-echo "DBContextTest : please ensure MySQL is set up and jdbc drivers are in classpath. See
DBContextTest.java for clues"
+echo "DBContextTest : please ensure your DB engine is set up and jdbc drivers are in classpath.
See DBContextTest.java for clues."
 echo "This is an unsupported demo."
 
-_VELCP=.
+echo "Running DBContextTest with input file 'dbtest.vm'"
 
-for i in ../lib/*.jar
+_VELCP=.
+for i in lib/*.jar
 do
-    _VELCP=$_VELCP:"$i"
+    _VELCP="$_VELCP:$i"
 done
 
-for i in ../*.jar
-do
-    _VELCP=$_VELCP:"$i"
-done
+# convert the unix path to windows
+if [ "$OSTYPE" = "cygwin32" ] || [ "$OSTYPE" = "cygwin" ] ; then
+    _VELCP=`cygpath --path --windows "$_VELCP"`
+fi
 
-for i in ../../lib/*.jar
-do
-    _VELCP=$_VELCP:"$i"
-done
+echo "Using classpath $_VELCP"
 
-for i in ../../*.jar
-do
-    _VELCP=$_VELCP:"$i"
-done
 
 java -cp $_VELCP org.apache.velocity.example.DBContextTest dbtest.vm
 

Copied: velocity/engine/trunk/velocity-engine-examples/src/etc/example1.sh (from r1871467,
velocity/engine/trunk/velocity-engine-examples/src/etc/app_example1/example.sh)
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-examples/src/etc/example1.sh?p2=velocity/engine/trunk/velocity-engine-examples/src/etc/example1.sh&p1=velocity/engine/trunk/velocity-engine-examples/src/etc/app_example1/example.sh&r1=1871467&r2=1871468&rev=1871468&view=diff
==============================================================================
--- velocity/engine/trunk/velocity-engine-examples/src/etc/app_example1/example.sh (original)
+++ velocity/engine/trunk/velocity-engine-examples/src/etc/example1.sh Sat Dec 14 12:20:11
2019
@@ -1,4 +1,4 @@
-# !/bin/sh
+#!/bin/sh
 
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
@@ -17,28 +17,12 @@
 # specific language governing permissions and limitations
 # under the License.
 
-echo "Running Example with input file 'example.vm'"
+echo "Running Example with input file 'example1.vm'"
 
 _VELCP=.
-
-for i in ../lib/*.jar
-do
-    _VELCP=$_VELCP:"$i"
-done
-
-for i in ../*.jar
+for i in lib/*.jar
 do
-    _VELCP=$_VELCP:"$i"
-done
-
-for i in ../../lib/*.jar
-do
-    _VELCP=$_VELCP:"$i"
-done
-
-for i in ../../*.jar
-do
-    _VELCP=$_VELCP:"$i"
+    _VELCP="$_VELCP:$i"
 done
 
 # convert the unix path to windows
@@ -46,5 +30,7 @@ if [ "$OSTYPE" = "cygwin32" ] || [ "$OST
     _VELCP=`cygpath --path --windows "$_VELCP"`
 fi
 
-java -cp $_VELCP org.apache.velocity.example.Example example.vm
+echo "Using classpath $_VELCP"
+
+java -cp $_VELCP org.apache.velocity.example.Example example1.vm
 

Copied: velocity/engine/trunk/velocity-engine-examples/src/etc/example2.sh (from r1871467,
velocity/engine/trunk/velocity-engine-examples/src/etc/app_example2/example2.sh)
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-examples/src/etc/example2.sh?p2=velocity/engine/trunk/velocity-engine-examples/src/etc/example2.sh&p1=velocity/engine/trunk/velocity-engine-examples/src/etc/app_example2/example2.sh&r1=1871467&r2=1871468&rev=1871468&view=diff
==============================================================================
--- velocity/engine/trunk/velocity-engine-examples/src/etc/app_example2/example2.sh (original)
+++ velocity/engine/trunk/velocity-engine-examples/src/etc/example2.sh Sat Dec 14 12:20:11
2019
@@ -1,4 +1,4 @@
-# !/bin/sh
+#!/bin/sh
 
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
@@ -17,26 +17,12 @@
 # specific language governing permissions and limitations
 # under the License.
 
-_VELCP=.
-
-for i in ../lib/*.jar
-do
-    _VELCP=$_VELCP:"$i"
-done
-
-for i in ../*.jar
-do
-    _VELCP=$_VELCP:"$i"
-done
-
-for i in ../../lib/*.jar
-do
-    _VELCP=$_VELCP:"$i"
-done
+echo "Running Example2"
 
-for i in ../../*.jar
+_VELCP=.
+for i in lib/*.jar
 do
-    _VELCP=$_VELCP:"$i"
+    _VELCP="$_VELCP:$i"
 done
 
 # convert the unix path to windows
@@ -44,5 +30,7 @@ if [ "$OSTYPE" = "cygwin32" ] || [ "$OST
     _VELCP=`cygpath --path --windows "$_VELCP"`
 fi
 
+echo "Using classpath $_VELCP"
+
 java -cp $_VELCP org.apache.velocity.example.Example2
 

Copied: velocity/engine/trunk/velocity-engine-examples/src/etc/xmlapp_example.sh (from r1871467,
velocity/engine/trunk/velocity-engine-examples/src/etc/xmlapp_example/xmlapp_example.sh)
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-examples/src/etc/xmlapp_example.sh?p2=velocity/engine/trunk/velocity-engine-examples/src/etc/xmlapp_example.sh&p1=velocity/engine/trunk/velocity-engine-examples/src/etc/xmlapp_example/xmlapp_example.sh&r1=1871467&r2=1871468&rev=1871468&view=diff
==============================================================================
--- velocity/engine/trunk/velocity-engine-examples/src/etc/xmlapp_example/xmlapp_example.sh
(original)
+++ velocity/engine/trunk/velocity-engine-examples/src/etc/xmlapp_example.sh Sat Dec 14 12:20:11
2019
@@ -1,4 +1,4 @@
-# !/bin/sh
+#!/bin/sh
 
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
@@ -17,26 +17,12 @@
 # specific language governing permissions and limitations
 # under the License.
 
-_VELCP=.
-
-for i in ../lib/*.jar
-do
-    _VELCP=$_VELCP:"$i"
-done
-
-for i in ../*.jar
-do
-    _VELCP=$_VELCP:"$i"
-done
+echo "Running XMLTest with input file 'xml.vm'"
 
-for i in ../../lib/*.jar
-do
-    _VELCP=$_VELCP:"$i"
-done
-
-for i in ../../*.jar
+_VELCP=.
+for i in lib/*.jar
 do
-    _VELCP=$_VELCP:"$i"
+    _VELCP="$_VELCP:$i"
 done
 
 # convert the unix path to windows
@@ -44,5 +30,6 @@ if [ "$OSTYPE" = "cygwin32" ] || [ "$OST
     _VELCP=`cygpath --path --windows "$_VELCP"`
 fi
 
-java -cp $_VELCP org.apache.velocity.example.XMLTest xml.vm
+echo "Using classpath $_VELCP"
 
+java -cp $_VELCP org.apache.velocity.example.XMLTest xml.vm

Modified: velocity/engine/trunk/velocity-engine-examples/src/main/java/org/apache/velocity/example/DBContext.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-examples/src/main/java/org/apache/velocity/example/DBContext.java?rev=1871468&r1=1871467&r2=1871468&view=diff
==============================================================================
--- velocity/engine/trunk/velocity-engine-examples/src/main/java/org/apache/velocity/example/DBContext.java
(original)
+++ velocity/engine/trunk/velocity-engine-examples/src/main/java/org/apache/velocity/example/DBContext.java
Sat Dec 14 12:20:11 2019
@@ -27,6 +27,7 @@ import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
 import java.sql.Connection;
 import java.sql.DriverManager;
+import java.sql.PreparedStatement;
 import java.sql.ResultSet;
 import java.sql.Statement;
 
@@ -73,31 +74,29 @@ public class DBContext extends AbstractC
     {
         try
         {
-            String data = null;
-
-            String sql = "SELECT k, val FROM contextstore WHERE k ='"+key+"'";
-
+            String sql = "SELECT val FROM contextstore WHERE k ='"+key+"'";
             Statement s = conn.createStatement();
-
             ResultSet rs = s.executeQuery( sql );
 
+            Object o = null;
+            ObjectInputStream in = null;
+
             if(rs.next())
-               data = rs.getString("val");
+            {
+                in = new ObjectInputStream(  rs.getBinaryStream(1) );
+                o =  in.readObject();
+                in.close();
+            }
 
             rs.close();
             s.close();
 
-            ObjectInputStream in = new ObjectInputStream(  new ByteArrayInputStream( data.getBytes()
));
-
-            Object o =  in.readObject();
-
-            in.close();
-
             return o;
         }
         catch(Exception e)
         {
             System.out.println("internalGet() : " + e );
+            e.printStackTrace();
         }
 
         return null;
@@ -113,21 +112,23 @@ public class DBContext extends AbstractC
     {
         try
         {
+            Statement s = conn.createStatement();
+            s.executeUpdate( "DELETE FROM contextstore WHERE k = '" + key + "'" );
+            s.close();
+
             ByteArrayOutputStream baos = new ByteArrayOutputStream();
             ObjectOutputStream out = new ObjectOutputStream( baos );
-
             out.writeObject( value );
-            String data = baos.toString();
-
+            byte buf[] = baos.toByteArray();
             out.close();
             baos.close();
 
-            Statement s = conn.createStatement();
-
-            s.executeUpdate( "DELETE FROM contextstore WHERE k = '" + key + "'" );
-            s.executeUpdate( "INSERT INTO contextstore (k,val) values ('"+key+"','" + data
+ "')" );
+            ByteArrayInputStream bais = new ByteArrayInputStream(buf);
+            PreparedStatement ps = conn.prepareStatement( "INSERT INTO contextstore (k,val)
values ('"+key+"', ?)");
+            ps.setBinaryStream(1, bais, buf.length);
+            ps.executeUpdate();
+            ps.close();
 
-            s.close();
         }
         catch(Exception e)
         {
@@ -172,8 +173,8 @@ public class DBContext extends AbstractC
     {
         try
         {
-            Class.forName("org.gjt.mm.mysql.Driver").newInstance();
-            conn = DriverManager.getConnection("jdbc:mysql://localhost/test?user=root");
+            Class.forName("com.mysql.cj.jdbc.Driver");
+            conn = DriverManager.getConnection("jdbc:mysql://localhost/test?user=YOUR_DB_USER&password=YOUR_DB_PASSWORD");
         }
         catch (Exception e)
         {

Modified: velocity/engine/trunk/velocity-engine-examples/src/main/java/org/apache/velocity/example/EventExample.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-examples/src/main/java/org/apache/velocity/example/EventExample.java?rev=1871468&r1=1871467&r2=1871468&view=diff
==============================================================================
--- velocity/engine/trunk/velocity-engine-examples/src/main/java/org/apache/velocity/example/EventExample.java
(original)
+++ velocity/engine/trunk/velocity-engine-examples/src/main/java/org/apache/velocity/example/EventExample.java
Sat Dec 14 12:20:11 2019
@@ -21,6 +21,7 @@ package org.apache.velocity.example;
 import org.apache.velocity.VelocityContext;
 import org.apache.velocity.app.Velocity;
 import org.apache.velocity.app.event.EventCartridge;
+import org.apache.velocity.app.event.InvalidReferenceEventHandler;
 import org.apache.velocity.app.event.MethodExceptionEventHandler;
 import org.apache.velocity.app.event.ReferenceInsertionEventHandler;
 import org.apache.velocity.context.Context;
@@ -38,14 +39,14 @@ import java.io.StringWriter;
  *   This class is a simple demonstration of how the event handling
  *   features of the Velocity Servlet Engine are used.  It uses a
  *   custom logger as well to check the log message stream
- *   when testing the NullSetEventHandler
+ *   when testing the InvalidReferenceEventHandler.
  *
  * @author <a href="mailto:geirm@optonline.net">Geir Magnusson Jr.</a>
  * @version $Id$
  */
 
 public class EventExample extends MarkerIgnoringBase
-    implements ReferenceInsertionEventHandler, MethodExceptionEventHandler
+    implements ReferenceInsertionEventHandler, MethodExceptionEventHandler, InvalidReferenceEventHandler
 {
     private boolean logOutput = false;
     private boolean exceptionSwitch = false;
@@ -139,7 +140,7 @@ public class EventExample extends Marker
             s = "#set($settest = $NotAReference)";
             w = new StringWriter();
 
-            System.out.println("NullSetEventHandler test : " );
+            System.out.println("invalidSetMethod test : " );
             System.out.print("      There should be nothing between >");
             Velocity.evaluate( context, w, "mystring", s );
             System.out.println("< the brackets.");
@@ -153,7 +154,7 @@ public class EventExample extends Marker
             s = "#set($logthis = $NotAReference)";
             w = new StringWriter();
 
-            System.out.println("NullSetEventHandler test : " );
+            System.out.println("invalidSetMethod test : " );
             System.out.print("     There should be a log message between >");
             Velocity.evaluate( context, w, "mystring", s );
             System.out.println("< the brackets.");
@@ -269,16 +270,35 @@ public class EventExample extends Marker
     }
 
     /**
+     */
+
+    public Object invalidGetMethod(Context context, String reference, Object object, String
property, Info info)
+    {
+        /* NOP */
+        return null;
+    }
+
+    public Object invalidMethod(Context context, String reference, Object object, String
method, Info info)
+    {
+        /* NOP */
+        return null;
+    }
+
+    /**
      *  Event handler for when the right hand side of
      *  a #set() directive is null, which results in
      *  a log message.  This method gives the application
      *  a chance to 'vote' on msg generation
      */
-    public boolean shouldLogOnNullSet( String lhs, String rhs )
+    public boolean invalidSetMethod(Context context, String leftreference, String rightreference,
Info info)
     {
-        return !lhs.equals("$settest");
+        if (leftreference.equals("logthis"))
+        {
+            System.out.print("Setting reference " + leftreference + " to null");
+        }
+        return false;
     }
-
+    
     public Object methodException( Context context, Class claz, String method, Exception
e, Info info )   {
         /*
          *  only do processing if the switch is on

Modified: velocity/engine/trunk/velocity-engine-examples/src/main/java/org/apache/velocity/example/Example2.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-examples/src/main/java/org/apache/velocity/example/Example2.java?rev=1871468&r1=1871467&r2=1871468&view=diff
==============================================================================
--- velocity/engine/trunk/velocity-engine-examples/src/main/java/org/apache/velocity/example/Example2.java
(original)
+++ velocity/engine/trunk/velocity-engine-examples/src/main/java/org/apache/velocity/example/Example2.java
Sat Dec 14 12:20:11 2019
@@ -58,7 +58,7 @@ public class Example2
         VelocityContext context = new VelocityContext();
 
         context.put("name", "Velocity");
-        context.put("project", "Jakarta");
+        context.put("project", "Engine");
 
         /* lets render a template */
 

Modified: velocity/engine/trunk/velocity-engine-examples/src/main/resources/velocity.properties
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-examples/src/main/resources/velocity.properties?rev=1871468&r1=1871467&r2=1871468&view=diff
==============================================================================
--- velocity/engine/trunk/velocity-engine-examples/src/main/resources/velocity.properties
(original)
+++ velocity/engine/trunk/velocity-engine-examples/src/main/resources/velocity.properties
Sat Dec 14 12:20:11 2019
@@ -14,4 +14,7 @@
 # KIND, either express or implied.  See the License for the
 # specific language governing permissions and limitations
 # under the License.
-runtime.log = velocity_example.log
+
+# Here you can configure Velocity behavior,
+# see http://velocity.apache.org/engine/${project.version}/configuration.html#configuring-velocity
+runtime.log.name = velocity



Mime
View raw message