You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tiles.apache.org by ap...@apache.org on 2010/02/10 11:05:07 UTC
svn commit: r908426 - in /tiles/sandbox/trunk/tiles-autotag:
tiles-autotag-core/src/main/java/org/apache/tiles/autotag/core/
tiles-autotag-core/src/main/java/org/apache/tiles/autotag/model/
tiles-autotag-jsp/ tiles-autotag-jsp/src/main/java/org/ tiles-...
Author: apetrelli
Date: Wed Feb 10 10:05:06 2010
New Revision: 908426
URL: http://svn.apache.org/viewvc?rev=908426&view=rev
Log:
TILESSB-22
Added creation of TLD.
TILESSB-21
Added more code to the core to allow an easier code generation.
Added:
tiles/sandbox/trunk/tiles-autotag/tiles-autotag-jsp/src/main/java/org/
tiles/sandbox/trunk/tiles-autotag/tiles-autotag-jsp/src/main/java/org/apache/
tiles/sandbox/trunk/tiles-autotag/tiles-autotag-jsp/src/main/java/org/apache/tiles/
tiles/sandbox/trunk/tiles-autotag/tiles-autotag-jsp/src/main/java/org/apache/tiles/autotag/
tiles/sandbox/trunk/tiles-autotag/tiles-autotag-jsp/src/main/java/org/apache/tiles/autotag/jsp/
tiles/sandbox/trunk/tiles-autotag/tiles-autotag-jsp/src/main/java/org/apache/tiles/autotag/jsp/TLDGenerator.java (with props)
tiles/sandbox/trunk/tiles-autotag/tiles-autotag-jsp/src/main/resources/org/
tiles/sandbox/trunk/tiles-autotag/tiles-autotag-jsp/src/main/resources/org/apache/
tiles/sandbox/trunk/tiles-autotag/tiles-autotag-jsp/src/main/resources/org/apache/tiles/
tiles/sandbox/trunk/tiles-autotag/tiles-autotag-jsp/src/main/resources/org/apache/tiles/autotag/
tiles/sandbox/trunk/tiles-autotag/tiles-autotag-jsp/src/main/resources/org/apache/tiles/autotag/jsp/
tiles/sandbox/trunk/tiles-autotag/tiles-autotag-jsp/src/main/resources/org/apache/tiles/autotag/jsp/tld.vm
tiles/sandbox/trunk/tiles-autotag/tiles-autotag-jsp/src/main/resources/org/apache/tiles/autotag/jsp/velocity.properties (with props)
tiles/sandbox/trunk/tiles-autotag/tiles-autotag-jsp/src/test/java/org/
tiles/sandbox/trunk/tiles-autotag/tiles-autotag-jsp/src/test/java/org/apache/
tiles/sandbox/trunk/tiles-autotag/tiles-autotag-jsp/src/test/java/org/apache/tiles/
tiles/sandbox/trunk/tiles-autotag/tiles-autotag-jsp/src/test/java/org/apache/tiles/autotag/
tiles/sandbox/trunk/tiles-autotag/tiles-autotag-jsp/src/test/java/org/apache/tiles/autotag/jsp/
tiles/sandbox/trunk/tiles-autotag/tiles-autotag-jsp/src/test/java/org/apache/tiles/autotag/jsp/TLDGeneratorTest.java (with props)
tiles/sandbox/trunk/tiles-autotag/tiles-autotag-jsp/src/test/resources/tldtest-jsp.tld (with props)
Modified:
tiles/sandbox/trunk/tiles-autotag/tiles-autotag-core/src/main/java/org/apache/tiles/autotag/core/QDoxTemplateSuiteFactory.java
tiles/sandbox/trunk/tiles-autotag/tiles-autotag-core/src/main/java/org/apache/tiles/autotag/model/TemplateClass.java
tiles/sandbox/trunk/tiles-autotag/tiles-autotag-core/src/main/java/org/apache/tiles/autotag/model/TemplateParameter.java
tiles/sandbox/trunk/tiles-autotag/tiles-autotag-core/src/main/java/org/apache/tiles/autotag/model/TemplateSuite.java
tiles/sandbox/trunk/tiles-autotag/tiles-autotag-jsp/pom.xml
Modified: tiles/sandbox/trunk/tiles-autotag/tiles-autotag-core/src/main/java/org/apache/tiles/autotag/core/QDoxTemplateSuiteFactory.java
URL: http://svn.apache.org/viewvc/tiles/sandbox/trunk/tiles-autotag/tiles-autotag-core/src/main/java/org/apache/tiles/autotag/core/QDoxTemplateSuiteFactory.java?rev=908426&r1=908425&r2=908426&view=diff
==============================================================================
--- tiles/sandbox/trunk/tiles-autotag/tiles-autotag-core/src/main/java/org/apache/tiles/autotag/core/QDoxTemplateSuiteFactory.java (original)
+++ tiles/sandbox/trunk/tiles-autotag/tiles-autotag-core/src/main/java/org/apache/tiles/autotag/core/QDoxTemplateSuiteFactory.java Wed Feb 10 10:05:06 2010
@@ -22,31 +22,35 @@
public class QDoxTemplateSuiteFactory implements TemplateSuiteFactory {
+ private static final String TEMPLATE_SUFFIX = "Template";
+
private JavaDocBuilder builder;
private String suiteName;
private String suiteDocumentation;
- public QDoxTemplateSuiteFactory(File...sourceFiles) {
+ public QDoxTemplateSuiteFactory(File... sourceFiles) {
builder = new JavaDocBuilder();
try {
for (File file : sourceFiles) {
builder.addSource(file);
}
} catch (IOException e) {
- throw new ClassParseException("I/O Exception when adding source files", e);
+ throw new ClassParseException(
+ "I/O Exception when adding source files", e);
}
}
public QDoxTemplateSuiteFactory(URL... urls) {
builder = new JavaDocBuilder();
try {
- for (URL url: urls) {
+ for (URL url : urls) {
builder.addSource(url);
}
} catch (IOException e) {
- throw new ClassParseException("I/O Exception when adding source files", e);
+ throw new ClassParseException(
+ "I/O Exception when adding source files", e);
}
}
@@ -62,32 +66,52 @@
public TemplateSuite createTemplateSuite() {
List<TemplateClass> classes = new ArrayList<TemplateClass>();
for (JavaClass clazz : builder.getClasses()) {
- TemplateMethod startMethod = null;
- TemplateMethod endMethod = null;
- TemplateMethod executeMethod = null;
- for (JavaMethod method : clazz.getMethods()) {
- if (isFeasible(method)) {
- if ("start".equals(method.getName())) {
- TemplateMethod templateMethod = createMethod(method);
- startMethod = templateMethod;
- } else if ("end".equals(method.getName())) {
- endMethod = createMethod(method);
- } else if ("execute".equals(method.getName())) {
- executeMethod = createMethod(method);
+ String tagClassPrefix = getTagClassPrefix(clazz);
+ if (tagClassPrefix != null) {
+ String tagName = tagClassPrefix.substring(0, 1).toLowerCase()
+ + tagClassPrefix.substring(1);
+ TemplateMethod startMethod = null;
+ TemplateMethod endMethod = null;
+ TemplateMethod executeMethod = null;
+ for (JavaMethod method : clazz.getMethods()) {
+ if (isFeasible(method)) {
+ if ("start".equals(method.getName())) {
+ TemplateMethod templateMethod = createMethod(method);
+ startMethod = templateMethod;
+ } else if ("end".equals(method.getName())) {
+ endMethod = createMethod(method);
+ } else if ("execute".equals(method.getName())) {
+ executeMethod = createMethod(method);
+ }
}
}
- }
- if ((startMethod != null && endMethod != null)
- || executeMethod != null) {
- TemplateClass templateClass = new TemplateClass(
- clazz.getFullyQualifiedName(), startMethod, endMethod, executeMethod);
- templateClass.setDocumentation(clazz.getComment());
- classes.add(templateClass);
+ if ((startMethod != null && endMethod != null)
+ || executeMethod != null) {
+ TemplateClass templateClass = new TemplateClass(clazz
+ .getFullyQualifiedName(), tagName, tagClassPrefix,
+ startMethod, endMethod, executeMethod);
+ templateClass.setDocumentation(clazz.getComment());
+ classes.add(templateClass);
+ }
}
}
return new TemplateSuite(suiteName, suiteDocumentation, classes);
}
+ private String getTagClassPrefix(JavaClass clazz) {
+ String tagName;
+ String simpleClassName = clazz.getName();
+ if (simpleClassName.endsWith(TEMPLATE_SUFFIX)
+ && simpleClassName.length() > TEMPLATE_SUFFIX.length()) {
+ tagName = simpleClassName.substring(0, 1).toLowerCase()
+ + simpleClassName.substring(1, simpleClassName.length()
+ - TEMPLATE_SUFFIX.length());
+ } else {
+ tagName = null;
+ }
+ return tagName;
+ }
+
private TemplateMethod createMethod(JavaMethod method) {
List<TemplateParameter> params = new ArrayList<TemplateParameter>();
for (JavaParameter parameter : method.getParameters()) {
Modified: tiles/sandbox/trunk/tiles-autotag/tiles-autotag-core/src/main/java/org/apache/tiles/autotag/model/TemplateClass.java
URL: http://svn.apache.org/viewvc/tiles/sandbox/trunk/tiles-autotag/tiles-autotag-core/src/main/java/org/apache/tiles/autotag/model/TemplateClass.java?rev=908426&r1=908425&r2=908426&view=diff
==============================================================================
--- tiles/sandbox/trunk/tiles-autotag/tiles-autotag-core/src/main/java/org/apache/tiles/autotag/model/TemplateClass.java (original)
+++ tiles/sandbox/trunk/tiles-autotag/tiles-autotag-core/src/main/java/org/apache/tiles/autotag/model/TemplateClass.java Wed Feb 10 10:05:06 2010
@@ -1,9 +1,17 @@
package org.apache.tiles.autotag.model;
+import java.util.Collection;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
public class TemplateClass {
private String name;
+ private String tagName;
+
+ private String tagClassPrefix;
+
private String documentation;
private TemplateMethod startMethod;
@@ -13,13 +21,15 @@
private TemplateMethod executeMethod;
public TemplateClass(String name) {
- this(name, null, null, null);
+ this(name, null, null, null, null, null);
}
- public TemplateClass(String name,
+ public TemplateClass(String name, String tagName, String tagClassPrefix,
TemplateMethod startMethod, TemplateMethod endMethod,
TemplateMethod executeMethod) {
this.name = name;
+ this.tagName = tagName;
+ this.tagClassPrefix = tagClassPrefix;
this.startMethod = startMethod;
this.endMethod = endMethod;
this.executeMethod = executeMethod;
@@ -29,6 +39,14 @@
return name;
}
+ public String getTagName() {
+ return tagName;
+ }
+
+ public String getTagClassPrefix() {
+ return tagClassPrefix;
+ }
+
public String getDocumentation() {
return documentation;
}
@@ -49,6 +67,29 @@
return executeMethod;
}
+ public Collection<TemplateParameter> getParameters() {
+ Map<String, TemplateParameter> params = new LinkedHashMap<String, TemplateParameter>();
+ fillRegularParameters(params, startMethod);
+ fillRegularParameters(params, endMethod);
+ fillRegularParameters(params, executeMethod);
+ return params.values();
+ }
+
+ private void fillRegularParameters(Map<String, TemplateParameter> params,
+ TemplateMethod method) {
+ if (method != null) {
+ for (TemplateParameter param: method.getParameters()) {
+ if (!param.isRequest() && !param.isBody()) {
+ params.put(param.getName(), param);
+ }
+ }
+ }
+ }
+
+ public boolean hasBody() {
+ return (startMethod != null && endMethod != null);
+ }
+
@Override
public String toString() {
return "TemplateClass\n[documentation=" + documentation + ",\nendMethod="
Modified: tiles/sandbox/trunk/tiles-autotag/tiles-autotag-core/src/main/java/org/apache/tiles/autotag/model/TemplateParameter.java
URL: http://svn.apache.org/viewvc/tiles/sandbox/trunk/tiles-autotag/tiles-autotag-core/src/main/java/org/apache/tiles/autotag/model/TemplateParameter.java?rev=908426&r1=908425&r2=908426&view=diff
==============================================================================
--- tiles/sandbox/trunk/tiles-autotag/tiles-autotag-core/src/main/java/org/apache/tiles/autotag/model/TemplateParameter.java (original)
+++ tiles/sandbox/trunk/tiles-autotag/tiles-autotag-core/src/main/java/org/apache/tiles/autotag/model/TemplateParameter.java Wed Feb 10 10:05:06 2010
@@ -1,5 +1,7 @@
package org.apache.tiles.autotag.model;
+import org.apache.tiles.request.Request;
+
public class TemplateParameter {
private String name;
@@ -44,6 +46,10 @@
return body;
}
+ public boolean isRequest() {
+ return Request.class.getName().equals(type);
+ }
+
@Override
public String toString() {
return "TemplateParameter\n[body=" + body + ",\ndocumentation="
Modified: tiles/sandbox/trunk/tiles-autotag/tiles-autotag-core/src/main/java/org/apache/tiles/autotag/model/TemplateSuite.java
URL: http://svn.apache.org/viewvc/tiles/sandbox/trunk/tiles-autotag/tiles-autotag-core/src/main/java/org/apache/tiles/autotag/model/TemplateSuite.java?rev=908426&r1=908425&r2=908426&view=diff
==============================================================================
--- tiles/sandbox/trunk/tiles-autotag/tiles-autotag-core/src/main/java/org/apache/tiles/autotag/model/TemplateSuite.java (original)
+++ tiles/sandbox/trunk/tiles-autotag/tiles-autotag-core/src/main/java/org/apache/tiles/autotag/model/TemplateSuite.java Wed Feb 10 10:05:06 2010
@@ -1,6 +1,7 @@
package org.apache.tiles.autotag.model;
import java.util.Collection;
+import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
@@ -10,6 +11,8 @@
private String documentation;
+ private Map<String, String> customVariables;
+
Map<String, TemplateClass> templateClasses;
public TemplateSuite(String name, String documentation) {
@@ -20,6 +23,7 @@
Iterable<? extends TemplateClass> classes) {
this.name = name;
this.documentation = documentation;
+ customVariables = new HashMap<String, String>();
templateClasses = new LinkedHashMap<String, TemplateClass>();
if (classes != null) {
for (TemplateClass templateClass : classes) {
@@ -54,4 +58,7 @@
+ name + ", templateClasses=\n" + templateClasses + "]";
}
+ public Map<String, String> getCustomVariables() {
+ return customVariables;
+ }
}
Modified: tiles/sandbox/trunk/tiles-autotag/tiles-autotag-jsp/pom.xml
URL: http://svn.apache.org/viewvc/tiles/sandbox/trunk/tiles-autotag/tiles-autotag-jsp/pom.xml?rev=908426&r1=908425&r2=908426&view=diff
==============================================================================
--- tiles/sandbox/trunk/tiles-autotag/tiles-autotag-jsp/pom.xml (original)
+++ tiles/sandbox/trunk/tiles-autotag/tiles-autotag-jsp/pom.xml Wed Feb 10 10:05:06 2010
@@ -17,5 +17,27 @@
<version>1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
+ <dependency>
+ <groupId>org.apache.tiles</groupId>
+ <artifactId>tiles-autotag-core</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.velocity</groupId>
+ <artifactId>velocity</artifactId>
+ <version>1.6.3</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.7</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <version>1.4</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
\ No newline at end of file
Added: tiles/sandbox/trunk/tiles-autotag/tiles-autotag-jsp/src/main/java/org/apache/tiles/autotag/jsp/TLDGenerator.java
URL: http://svn.apache.org/viewvc/tiles/sandbox/trunk/tiles-autotag/tiles-autotag-jsp/src/main/java/org/apache/tiles/autotag/jsp/TLDGenerator.java?rev=908426&view=auto
==============================================================================
--- tiles/sandbox/trunk/tiles-autotag/tiles-autotag-jsp/src/main/java/org/apache/tiles/autotag/jsp/TLDGenerator.java (added)
+++ tiles/sandbox/trunk/tiles-autotag/tiles-autotag-jsp/src/main/java/org/apache/tiles/autotag/jsp/TLDGenerator.java Wed Feb 10 10:05:06 2010
@@ -0,0 +1,46 @@
+package org.apache.tiles.autotag.jsp;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.Writer;
+
+import org.apache.tiles.autotag.core.AutotagRuntimeException;
+import org.apache.tiles.autotag.generate.TemplateSuiteGenerator;
+import org.apache.tiles.autotag.model.TemplateSuite;
+import org.apache.velocity.Template;
+import org.apache.velocity.VelocityContext;
+import org.apache.velocity.app.Velocity;
+import org.apache.velocity.exception.ParseErrorException;
+import org.apache.velocity.exception.ResourceNotFoundException;
+
+public class TLDGenerator implements TemplateSuiteGenerator {
+
+ @Override
+ public void generate(File directory, String packageName, TemplateSuite suite) {
+ File dir = new File(directory, "META-INF/tld/");
+ dir.mkdirs();
+ File tldFile = new File(dir, suite.getName() + "-jsp.tld");
+ VelocityContext context = new VelocityContext();
+ context.put("packageName", packageName);
+ context.put("suite", suite);
+ try {
+ tldFile.createNewFile();
+ Template template = Velocity.getTemplate("/org/apache/tiles/autotag/jsp/tld.vm");
+ Writer writer = new FileWriter(tldFile);
+ try {
+ template.merge(context, writer);
+ } finally {
+ writer.close();
+ }
+ } catch (ResourceNotFoundException e) {
+ throw new AutotagRuntimeException("Cannot get tld.vm resource", e);
+ } catch (ParseErrorException e) {
+ throw new AutotagRuntimeException("The tld.vm resource is not parseable", e);
+ } catch (RuntimeException e) {
+ throw e;
+ } catch (Exception e) {
+ throw new AutotagRuntimeException("Another generic exception while parsing tld.vm", e);
+ }
+ }
+
+}
Propchange: tiles/sandbox/trunk/tiles-autotag/tiles-autotag-jsp/src/main/java/org/apache/tiles/autotag/jsp/TLDGenerator.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: tiles/sandbox/trunk/tiles-autotag/tiles-autotag-jsp/src/main/java/org/apache/tiles/autotag/jsp/TLDGenerator.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: tiles/sandbox/trunk/tiles-autotag/tiles-autotag-jsp/src/main/resources/org/apache/tiles/autotag/jsp/tld.vm
URL: http://svn.apache.org/viewvc/tiles/sandbox/trunk/tiles-autotag/tiles-autotag-jsp/src/main/resources/org/apache/tiles/autotag/jsp/tld.vm?rev=908426&view=auto
==============================================================================
--- tiles/sandbox/trunk/tiles-autotag/tiles-autotag-jsp/src/main/resources/org/apache/tiles/autotag/jsp/tld.vm (added)
+++ tiles/sandbox/trunk/tiles-autotag/tiles-autotag-jsp/src/main/resources/org/apache/tiles/autotag/jsp/tld.vm Wed Feb 10 10:05:06 2010
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>
+#*
+ * $Id: tiles-jsp.tld 836180 2009-11-14 14:00:02Z apetrelli $
+ *
+ * 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.
+ *#
+<taglib
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-jsptaglibrary_2_1.xsd"
+ xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ version="2.1">
+ <description>
+ <![CDATA[
+ ${suite.documentation}
+ ]]>
+ </description>
+ <tlib-version>1.2</tlib-version>
+ <short-name>${suite.name}</short-name>
+ <uri>${suite.customVariables.taglibURI}</uri>
+#foreach($clazz in ${suite.getTemplateClasses()})
+ <tag>
+ <description>
+ <![CDATA[
+ ${clazz.documentation}
+ ]]>
+ </description>
+ <name>${clazz.tagName}</name>
+ <tag-class>${packageName}.${clazz.tagClassPrefix}</tag-class>
+ <body-content>#if(${clazz.hasBody()})scriptless#{else}empty#end</body-content>
+#foreach($parameter in ${clazz.parameters})
+ <attribute>
+ <description>
+ <![CDATA[
+ ${parameter.documentation}
+ ]]>
+ </description>
+ <name>${parameter.name}</name>
+ <required>${parameter.required}</required>
+ <rtexprvalue>true</rtexprvalue>
+ </attribute>
+#end
+ </tag>
+#end
+</taglib>
+
Added: tiles/sandbox/trunk/tiles-autotag/tiles-autotag-jsp/src/main/resources/org/apache/tiles/autotag/jsp/velocity.properties
URL: http://svn.apache.org/viewvc/tiles/sandbox/trunk/tiles-autotag/tiles-autotag-jsp/src/main/resources/org/apache/tiles/autotag/jsp/velocity.properties?rev=908426&view=auto
==============================================================================
--- tiles/sandbox/trunk/tiles-autotag/tiles-autotag-jsp/src/main/resources/org/apache/tiles/autotag/jsp/velocity.properties (added)
+++ tiles/sandbox/trunk/tiles-autotag/tiles-autotag-jsp/src/main/resources/org/apache/tiles/autotag/jsp/velocity.properties Wed Feb 10 10:05:06 2010
@@ -0,0 +1,115 @@
+# 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.
+
+# ----------------------------------------------------------------------------
+# These are the default properties for the
+# Velocity Runtime. These values are used when
+# Runtime.init() is called, and when Runtime.init(properties)
+# fails to find the specificed properties file.
+# ----------------------------------------------------------------------------
+
+
+# ----------------------------------------------------------------------------
+# R U N T I M E L O G
+# ----------------------------------------------------------------------------
+# Velocity uses the Servlet APIs logging facilites.
+
+# ----------------------------------------------------------------------------
+# This controls if Runtime.error(), info() and warn() messages include the
+# whole stack trace. The last property controls whether invalid references
+# are logged.
+# ----------------------------------------------------------------------------
+
+runtime.log.invalid.reference = true
+
+
+# ----------------------------------------------------------------------------
+# T E M P L A T E E N C O D I N G
+# ----------------------------------------------------------------------------
+
+input.encoding=ISO-8859-1
+output.encoding=ISO-8859-1
+
+
+# ----------------------------------------------------------------------------
+# F O R E A C H P R O P E R T I E S
+# ----------------------------------------------------------------------------
+# These properties control how the counter is accessed in the #foreach
+# directive. By default the reference $velocityCount will be available
+# in the body of the #foreach directive. The default starting value
+# for this reference is 1.
+# ----------------------------------------------------------------------------
+
+directive.foreach.counter.name = velocityCount
+directive.foreach.counter.initial.value = 1
+
+
+# ----------------------------------------------------------------------------
+# I N C L U D E P R O P E R T I E S
+# ----------------------------------------------------------------------------
+# These are the properties that governed the way #include'd content
+# is governed.
+# ----------------------------------------------------------------------------
+
+directive.include.output.errormsg.start = <!-- include error :
+directive.include.output.errormsg.end = see error log -->
+
+
+# ----------------------------------------------------------------------------
+# P A R S E P R O P E R T I E S
+# ----------------------------------------------------------------------------
+
+directive.parse.max.depth = 10
+
+
+# ----------------------------------------------------------------------------
+# VELOCIMACRO PROPERTIES
+# ----------------------------------------------------------------------------
+# global : name of default global library. It is expected to be in the regular
+# template path. You may remove it (either the file or this property) if
+# you wish with no harm.
+# ----------------------------------------------------------------------------
+# dev-changes by Marino
+resource.loader=class, string
+
+class.resource.loader.class=org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
+
+velocimacro.library.autoreload = false
+
+velocimacro.permissions.allow.inline = true
+velocimacro.permissions.allow.inline.to.replace.global = false
+velocimacro.permissions.allow.inline.local.scope = false
+
+velocimacro.context.localscope = false
+
+# ----------------------------------------------------------------------------
+# INTERPOLATION
+# ----------------------------------------------------------------------------
+# turn off and on interpolation of references and directives in string
+# literals. ON by default :)
+# ----------------------------------------------------------------------------
+runtime.interpolate.string.literals = true
+
+
+# ----------------------------------------------------------------------------
+# RESOURCE MANAGEMENT
+# ----------------------------------------------------------------------------
+# Allows alternative ResourceManager and ResourceCache implementations
+# to be plugged in.
+# ----------------------------------------------------------------------------
+resource.manager.class = org.apache.velocity.runtime.resource.ResourceManagerImpl
+resource.manager.cache.class = org.apache.velocity.runtime.resource.ResourceCacheImpl
Propchange: tiles/sandbox/trunk/tiles-autotag/tiles-autotag-jsp/src/main/resources/org/apache/tiles/autotag/jsp/velocity.properties
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: tiles/sandbox/trunk/tiles-autotag/tiles-autotag-jsp/src/main/resources/org/apache/tiles/autotag/jsp/velocity.properties
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: tiles/sandbox/trunk/tiles-autotag/tiles-autotag-jsp/src/test/java/org/apache/tiles/autotag/jsp/TLDGeneratorTest.java
URL: http://svn.apache.org/viewvc/tiles/sandbox/trunk/tiles-autotag/tiles-autotag-jsp/src/test/java/org/apache/tiles/autotag/jsp/TLDGeneratorTest.java?rev=908426&view=auto
==============================================================================
--- tiles/sandbox/trunk/tiles-autotag/tiles-autotag-jsp/src/test/java/org/apache/tiles/autotag/jsp/TLDGeneratorTest.java (added)
+++ tiles/sandbox/trunk/tiles-autotag/tiles-autotag-jsp/src/test/java/org/apache/tiles/autotag/jsp/TLDGeneratorTest.java Wed Feb 10 10:05:06 2010
@@ -0,0 +1,92 @@
+/**
+ *
+ */
+package org.apache.tiles.autotag.jsp;
+
+import static org.junit.Assert.*;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.IOUtils;
+import org.apache.tiles.autotag.model.TemplateClass;
+import org.apache.tiles.autotag.model.TemplateMethod;
+import org.apache.tiles.autotag.model.TemplateParameter;
+import org.apache.tiles.autotag.model.TemplateSuite;
+import org.apache.tiles.request.Request;
+import org.apache.velocity.app.Velocity;
+import org.junit.Test;
+
+/**
+ * Tests {@link TLDGenerator}.
+ *
+ * @version $Rev$ $Date$
+ */
+public class TLDGeneratorTest {
+
+ /**
+ * Test method for {@link org.apache.tiles.autotag.jsp.TLDGenerator#generate(java.io.File, java.lang.String, org.apache.tiles.autotag.model.TemplateSuite)}.
+ * @throws Exception If something goes wrong.
+ */
+ @Test
+ public void testGenerate() throws Exception {
+ TLDGenerator generator = new TLDGenerator();
+ File file = File.createTempFile("autotag", null);
+ file.delete();
+ file.mkdir();
+ file.deleteOnExit();
+ TemplateSuite suite = new TemplateSuite("tldtest", "Test for TLD docs.");
+ suite.getCustomVariables().put("taglibURI", "http://www.initrode.net/tags/test");
+ List<TemplateParameter> params = new ArrayList<TemplateParameter>();
+ TemplateParameter param = new TemplateParameter("one", "java.lang.String", true, false);
+ param.setDocumentation("Parameter one.");
+ params.add(param);
+ param = new TemplateParameter("two", "int", false, false);
+ param.setDocumentation("Parameter two.");
+ params.add(param);
+ param = new TemplateParameter("request", Request.class.getName(), false, false);
+ param.setDocumentation("The request.");
+ params.add(param);
+ TemplateMethod startMethod = new TemplateMethod("start", params);
+
+ params = new ArrayList<TemplateParameter>();
+ param = new TemplateParameter("one", "java.lang.String", true, false);
+ param.setDocumentation("Parameter one.");
+ params.add(param);
+ param = new TemplateParameter("three", "long", false, false);
+ param.setDocumentation("Parameter three.");
+ params.add(param);
+ param = new TemplateParameter("request", Request.class.getName(), false, false);
+ param.setDocumentation("The request.");
+ params.add(param);
+ TemplateMethod endMethod = new TemplateMethod("end", params);
+
+ TemplateClass clazz = new TemplateClass("org.apache.tiles.autotag.template.DoStuffTemplate",
+ "doStuff", "DoStuff", startMethod, endMethod, null);
+ clazz.setDocumentation("Documentation of the DoStuff class");
+
+ suite.addTemplateClass(clazz);
+
+ Properties props = new Properties();
+ InputStream propsStream = getClass().getResourceAsStream("/org/apache/tiles/autotag/jsp/velocity.properties");
+ props.load(propsStream);
+ propsStream.close();
+ Velocity.init(props);
+
+ generator.generate(file, "org.apache.tiles.autotag.jsp.test", suite);
+
+ InputStream expected = getClass().getResourceAsStream("/tldtest-jsp.tld");
+ File effectiveFile = new File(file, "META-INF/tld/tldtest-jsp.tld");
+ assertTrue(effectiveFile.exists());
+ InputStream effective = new FileInputStream(effectiveFile);
+ IOUtils.contentEquals(effective, expected);
+
+ FileUtils.deleteDirectory(file);
+ }
+
+}
Propchange: tiles/sandbox/trunk/tiles-autotag/tiles-autotag-jsp/src/test/java/org/apache/tiles/autotag/jsp/TLDGeneratorTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: tiles/sandbox/trunk/tiles-autotag/tiles-autotag-jsp/src/test/java/org/apache/tiles/autotag/jsp/TLDGeneratorTest.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added: tiles/sandbox/trunk/tiles-autotag/tiles-autotag-jsp/src/test/resources/tldtest-jsp.tld
URL: http://svn.apache.org/viewvc/tiles/sandbox/trunk/tiles-autotag/tiles-autotag-jsp/src/test/resources/tldtest-jsp.tld?rev=908426&view=auto
==============================================================================
--- tiles/sandbox/trunk/tiles-autotag/tiles-autotag-jsp/src/test/resources/tldtest-jsp.tld (added)
+++ tiles/sandbox/trunk/tiles-autotag/tiles-autotag-jsp/src/test/resources/tldtest-jsp.tld Wed Feb 10 10:05:06 2010
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<taglib
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-jsptaglibrary_2_1.xsd"
+ xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ version="2.1">
+ <description>
+ <![CDATA[
+ Test for TLD docs.
+ ]]>
+ </description>
+ <tlib-version>1.2</tlib-version>
+ <short-name>tldtest</short-name>
+ <uri>http://www.initrode.net/tags/test</uri>
+ <tag>
+ <description>
+ <![CDATA[
+ Documentation of the DoStuff class
+ ]]>
+ </description>
+ <name>doStuff</name>
+ <tag-class>org.apache.tiles.autotag.jsp.test.DoStuff</tag-class>
+ <body-content>scriptless</body-content>
+ <attribute>
+ <description>
+ <![CDATA[
+ Parameter one.
+ ]]>
+ </description>
+ <name>one</name>
+ <required>true</required>
+ <rtexprvalue>true</rtexprvalue>
+ </attribute>
+ <attribute>
+ <description>
+ <![CDATA[
+ Parameter two.
+ ]]>
+ </description>
+ <name>two</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ </attribute>
+ <attribute>
+ <description>
+ <![CDATA[
+ Parameter three.
+ ]]>
+ </description>
+ <name>three</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ </attribute>
+ </tag>
+</taglib>
+
Propchange: tiles/sandbox/trunk/tiles-autotag/tiles-autotag-jsp/src/test/resources/tldtest-jsp.tld
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: tiles/sandbox/trunk/tiles-autotag/tiles-autotag-jsp/src/test/resources/tldtest-jsp.tld
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL