You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-dev@db.apache.org by tf...@apache.org on 2013/08/15 04:28:21 UTC
svn commit: r1514134 - in /db/torque/torque4/trunk/torque-generator/src/main:
java/org/apache/torque/generator/configuration/outlet/
resources/org/apache/torque/generator/configuration/
Author: tfischer
Date: Thu Aug 15 02:28:20 2013
New Revision: 1514134
URL: http://svn.apache.org/r1514134
Log:
TORQUE-298 The name attribute should be optional for template-based outlets
Modified:
db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/outlet/CopyOutletSaxHandlerFactory.java
db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/outlet/GroovyOutletSaxHandler.java
db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/outlet/GroovyOutletSaxHandlerFactory.java
db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/outlet/JavaOutletSaxHandlerFactory.java
db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/outlet/OutletConfigurationXmlParser.java
db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/outlet/TypedOutletSaxHandlerFactory.java
db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/outlet/VelocityOutletSaxHandler.java
db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/outlet/VelocityOutletSaxHandlerFactory.java
db/torque/torque4/trunk/torque-generator/src/main/resources/org/apache/torque/generator/configuration/outlet.xsd
Modified: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/outlet/CopyOutletSaxHandlerFactory.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/outlet/CopyOutletSaxHandlerFactory.java?rev=1514134&r1=1514133&r2=1514134&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/outlet/CopyOutletSaxHandlerFactory.java (original)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/outlet/CopyOutletSaxHandlerFactory.java Thu Aug 15 02:28:20 2013
@@ -65,10 +65,11 @@ public class CopyOutletSaxHandlerFactory
/**
* Creates an outlet for a template with the given file name.
- * This implementaion throws a UnsupportedOperationException
+ * This implementation throws a UnsupportedOperationException
* as java outlets are not template based.
*
- * @param templateFileName the file name of the template.
+ * @param templatePath the path to the template,
+ * relative to the templates directory, not null.
* @param configurationProvider the configuration provider.
*
* @return always throws an Exception
@@ -76,7 +77,7 @@ public class CopyOutletSaxHandlerFactory
* @throws UnsupportedOperationException always.
*/
public Outlet createOutletForTemplate(
- final String templateFileName,
+ final String templatePath,
final ConfigurationProvider configurationProvider)
{
Modified: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/outlet/GroovyOutletSaxHandler.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/outlet/GroovyOutletSaxHandler.java?rev=1514134&r1=1514133&r2=1514134&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/outlet/GroovyOutletSaxHandler.java (original)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/outlet/GroovyOutletSaxHandler.java Thu Aug 15 02:28:20 2013
@@ -110,23 +110,32 @@ class GroovyOutletSaxHandler extends Out
final Attributes attributes)
throws SAXException
{
+ final String path = attributes.getValue(OUTLET_PATH_ATTRIBUTE);
+ if (path == null)
+ {
+ throw new SAXException("The attribute "
+ + OUTLET_PATH_ATTRIBUTE
+ + " must be set on the element "
+ + rawName
+ + " for Groovy Outlets");
+ }
+
if (outletName == null)
{
final String nameAttribute
= attributes.getValue(OUTLET_NAME_ATTRIBUTE);
- if (nameAttribute == null)
+ if (nameAttribute != null)
{
- throw new SAXException("The attribute "
- + OUTLET_NAME_ATTRIBUTE
- + " must be set on the element "
- + rawName
- + " for Groovy Outlets");
+ outletName = new QualifiedName(nameAttribute);
+ }
+ else
+ {
+ outletName = OutletConfigurationXmlParser
+ .getOutletNameForFilename(path);
}
- outletName = new QualifiedName(nameAttribute);
}
final String encoding = attributes.getValue(OUTLET_ENCODING_ATTRIBUTE);
- final String path = attributes.getValue(OUTLET_PATH_ATTRIBUTE);
final String template = attributes.getValue(OUTLET_TEMPLATE_ATTRIBUTE);
try
Modified: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/outlet/GroovyOutletSaxHandlerFactory.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/outlet/GroovyOutletSaxHandlerFactory.java?rev=1514134&r1=1514133&r2=1514134&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/outlet/GroovyOutletSaxHandlerFactory.java (original)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/outlet/GroovyOutletSaxHandlerFactory.java Thu Aug 15 02:28:20 2013
@@ -84,25 +84,27 @@ public class GroovyOutletSaxHandlerFacto
/**
* Creates an outlet for a template with the given file name.
*
- * @param templateFileName the file name of the template, not null.
+ * @param templatePath the path to the template,
+ * relative to the templates directory, not null.
* @param configurationProvider the configuration provider, not null.
*
* @return the outlet, not null.
*/
public Outlet createOutletForTemplate(
- final String templateFileName,
+ final String templatePath,
final ConfigurationProvider configurationProvider)
throws ConfigurationException
{
GroovyScriptOutlet result
= new GroovyScriptOutlet(
- OutletConfigurationXmlParser.getTemplateNameForFilename(
- templateFileName),
+ OutletConfigurationXmlParser.getOutletNameForFilename(
+ templatePath),
configurationProvider,
- templateFileName,
+ templatePath,
null);
return result;
}
+
/**
* Returns a GroovyOutletSaxHandler for reading the configuration of
* Groovy outlets. This implementation uses the provided name
Modified: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/outlet/JavaOutletSaxHandlerFactory.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/outlet/JavaOutletSaxHandlerFactory.java?rev=1514134&r1=1514133&r2=1514134&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/outlet/JavaOutletSaxHandlerFactory.java (original)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/outlet/JavaOutletSaxHandlerFactory.java Thu Aug 15 02:28:20 2013
@@ -65,10 +65,11 @@ public class JavaOutletSaxHandlerFactory
/**
* Creates an outlet for a template with the given file name.
- * This implementaion throws a UnsupportedOperationException
+ * This implementation throws a UnsupportedOperationException
* as java outlets are not template based.
*
- * @param templateFileName the file name of the template.
+ * @param templatePath the path to the template,
+ * relative to the templates directory, not null.
* @param configurationProvider the configuration provider.
*
* @return always throws an Exception
@@ -76,7 +77,7 @@ public class JavaOutletSaxHandlerFactory
* @throws UnsupportedOperationException always.
*/
public Outlet createOutletForTemplate(
- final String templateFileName,
+ final String templatePath,
final ConfigurationProvider configurationProvider)
{
Modified: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/outlet/OutletConfigurationXmlParser.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/outlet/OutletConfigurationXmlParser.java?rev=1514134&r1=1514133&r2=1514134&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/outlet/OutletConfigurationXmlParser.java (original)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/outlet/OutletConfigurationXmlParser.java Thu Aug 15 02:28:20 2013
@@ -292,15 +292,16 @@ public class OutletConfigurationXmlParse
}
/**
- * Creates a template name for a file name.
+ * Creates an outlet name from a file path to a template.
*
- * @param filename the file name, not null.
+ * @param path the path to the file, relative to the templates directory,
+ * not null.
*
- * @return the template name, not null.
+ * @return the outlet name, not null.
*/
- static QualifiedName getTemplateNameForFilename(final String filename)
+ static QualifiedName getOutletNameForFilename(final String path)
{
- String resultName = filename;
+ String resultName = path;
int dotIndex = resultName.lastIndexOf('.');
if (dotIndex != -1)
{
Modified: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/outlet/TypedOutletSaxHandlerFactory.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/outlet/TypedOutletSaxHandlerFactory.java?rev=1514134&r1=1514133&r2=1514134&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/outlet/TypedOutletSaxHandlerFactory.java (original)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/outlet/TypedOutletSaxHandlerFactory.java Thu Aug 15 02:28:20 2013
@@ -55,7 +55,8 @@ public interface TypedOutletSaxHandlerFa
/**
* Creates an outlet for a template with the given file name.
*
- * @param templateFileName the file name of the template, not null.
+ * @param templatePath the path to the template,
+ * relative to the templates directory, not null.
* @param configurationProvider the configuration provider, not null.
*
* @return the outlet, not null.
@@ -66,7 +67,7 @@ public interface TypedOutletSaxHandlerFa
* information alone.
*/
Outlet createOutletForTemplate(
- String templateFileName,
+ String templatePath,
ConfigurationProvider configurationProvider)
throws ConfigurationException;
Modified: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/outlet/VelocityOutletSaxHandler.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/outlet/VelocityOutletSaxHandler.java?rev=1514134&r1=1514133&r2=1514134&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/outlet/VelocityOutletSaxHandler.java (original)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/outlet/VelocityOutletSaxHandler.java Thu Aug 15 02:28:20 2013
@@ -58,10 +58,10 @@ class VelocityOutletSaxHandler extends O
* @throws SAXException if an error occurs during creation of the outlet.
*/
public VelocityOutletSaxHandler(
- QualifiedName outletName,
- ConfigurationProvider configurationProvider,
- UnitDescriptor unitDescriptor,
- ConfigurationHandlers configurationHandlers)
+ final QualifiedName outletName,
+ final ConfigurationProvider configurationProvider,
+ final UnitDescriptor unitDescriptor,
+ final ConfigurationHandlers configurationHandlers)
throws SAXException
{
super(outletName,
@@ -92,31 +92,41 @@ class VelocityOutletSaxHandler extends O
*
* @throws SAXException if an error occurs during creation.
*/
+ @Override
protected VelocityOutlet createOutlet(
QualifiedName outletName,
- String uri,
- String localName,
- String rawName,
- Attributes attributes)
+ final String uri,
+ final String localName,
+ final String rawName,
+ final Attributes attributes)
throws SAXException
{
+ final String path = attributes.getValue(OUTLET_PATH_ATTRIBUTE);
+ if (path == null)
+ {
+ throw new SAXException("The attribute "
+ + OUTLET_PATH_ATTRIBUTE
+ + " must be set on the element "
+ + rawName
+ + " for Velocity Outlets");
+ }
+
if (outletName == null)
{
- String nameAttribute
+ final String nameAttribute
= attributes.getValue(OUTLET_NAME_ATTRIBUTE);
- if (nameAttribute == null)
+ if (nameAttribute != null)
+ {
+ outletName = new QualifiedName(nameAttribute);
+ }
+ else
{
- throw new SAXException("The attribute "
- + OUTLET_NAME_ATTRIBUTE
- + " must be set on the element "
- + rawName
- + " for Velocity Outlets");
+ outletName = OutletConfigurationXmlParser
+ .getOutletNameForFilename(path);
}
- outletName = new QualifiedName(nameAttribute);
}
- String encoding = attributes.getValue(OUTLET_ENCODING_ATTRIBUTE);
- String path = attributes.getValue(OUTLET_PATH_ATTRIBUTE);
+ final String encoding = attributes.getValue(OUTLET_ENCODING_ATTRIBUTE);
try
{
Modified: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/outlet/VelocityOutletSaxHandlerFactory.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/outlet/VelocityOutletSaxHandlerFactory.java?rev=1514134&r1=1514133&r2=1514134&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/outlet/VelocityOutletSaxHandlerFactory.java (original)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/outlet/VelocityOutletSaxHandlerFactory.java Thu Aug 15 02:28:20 2013
@@ -84,22 +84,23 @@ public class VelocityOutletSaxHandlerFac
/**
* Creates an outlet for a template with the given file name.
*
- * @param templateFileName the file name of the template, not null.
+ * @param templatePath the path to the template,
+ * relative to the templates directory, not null.
* @param configurationProvider the configuration provider, not null.
*
* @return the outlet, not null.
*/
public Outlet createOutletForTemplate(
- final String templateFileName,
+ final String templatePath,
final ConfigurationProvider configurationProvider)
throws ConfigurationException
{
VelocityOutlet result
= new VelocityOutlet(
- OutletConfigurationXmlParser.getTemplateNameForFilename(
- templateFileName),
+ OutletConfigurationXmlParser.getOutletNameForFilename(
+ templatePath),
configurationProvider,
- templateFileName,
+ templatePath,
null);
return result;
}
Modified: db/torque/torque4/trunk/torque-generator/src/main/resources/org/apache/torque/generator/configuration/outlet.xsd
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/resources/org/apache/torque/generator/configuration/outlet.xsd?rev=1514134&r1=1514133&r2=1514134&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/resources/org/apache/torque/generator/configuration/outlet.xsd (original)
+++ db/torque/torque4/trunk/torque-generator/src/main/resources/org/apache/torque/generator/configuration/outlet.xsd Thu Aug 15 02:28:20 2013
@@ -46,8 +46,7 @@
<element name="mergepoint" type="configuration:mergepoint" minOccurs="0" maxOccurs="unbounded" />
</sequence>
<!--
- name is optional in filenameOutlets but required in normal outlets.
- However, this can not be forced here, so use is set to optional.
+ name can be optional, e.g. for filenameOutlets and for template outlets.
-->
<attribute name="name" type="string" use="optional"/>
</complexType>
---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org