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 2010/02/16 18:16:02 UTC

svn commit: r910600 [2/29] - in /db/torque/torque4/trunk: maven-torque-gf-plugin/ maven-torque-gf-plugin/src/ maven-torque-gf-plugin/src/main/ maven-torque-gf-plugin/src/main/java/ maven-torque-gf-plugin/src/main/java/org/ maven-torque-gf-plugin/src/ma...

Added: db/torque/torque4/trunk/maven-torque-gf-plugin/src/main/java/org/apache/torque/gf/maven/TorqueGfMojo.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/maven-torque-gf-plugin/src/main/java/org/apache/torque/gf/maven/TorqueGfMojo.java?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/maven-torque-gf-plugin/src/main/java/org/apache/torque/gf/maven/TorqueGfMojo.java (added)
+++ db/torque/torque4/trunk/maven-torque-gf-plugin/src/main/java/org/apache/torque/gf/maven/TorqueGfMojo.java Tue Feb 16 17:15:43 2010
@@ -0,0 +1,392 @@
+package org.apache.torque.gf.maven;
+
+/*
+ * 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.
+ */
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.Mojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.project.MavenProject;
+import org.apache.torque.gf.configuration.UnitDescriptor;
+import org.apache.torque.gf.configuration.UnitDescriptor.Packaging;
+import org.apache.torque.gf.configuration.controller.Loglevel;
+import org.apache.torque.gf.configuration.option.MapOptionsConfiguration;
+import org.apache.torque.gf.configuration.option.OptionsConfiguration;
+import org.apache.torque.gf.configuration.paths.CustomProjectPaths;
+import org.apache.torque.gf.configuration.paths.DefaultTorqueGfPaths;
+import org.apache.torque.gf.configuration.paths.Maven2DirectoryProjectPaths;
+import org.apache.torque.gf.configuration.paths.Maven2JarProjectPaths;
+import org.apache.torque.gf.configuration.paths.ProjectPaths;
+import org.apache.torque.gf.control.Controller;
+
+/**
+ * Executes a unit of generation within torque-gf.
+ *
+ * $Id: $
+ *
+ * @goal generate
+ */
+public class TorqueGfMojo extends AbstractMojo implements Mojo
+{
+    /**
+     * The packaging type of the generation unit, either "directory" , "jar"
+     * or "classpath".
+     *
+     * @parameter expression="directory"
+     * @required
+     */
+    private String packaging;
+
+    /**
+     * The root directory of the project.
+     * Has no effect if packaging is "classpath".
+     *
+     * @parameter expression="${basedir}"
+     * @required
+     */
+    private File projectRootDir;
+
+    /**
+     * The configuration directory of the generation unit.
+     * Has no effect if packaging is "classpath".
+     *
+     * @parameter
+     */
+    private File configDir;
+
+    /**
+     * The configuration package of the generation unit.
+     * Has only effect if packaging is "classpath".
+     *
+     * @parameter
+     */
+    private String configPackage;
+
+    /**
+     * The directory where the source files reside.
+     *
+     * @parameter
+     */
+    private File sourceDir;
+
+    /**
+     * The target directory for files which are generated each time anew.
+     *
+     * @parameter expression="${project.build.directory}/generated-sources"
+     */
+    private File newFileTargetDir;
+
+    /**
+     * The target directory for files which are not generated each time anew.
+     *
+     * @parameter expression="${basedir}/src/main/generated-sources"
+     */
+    private File modifiedFileTargetDir;
+
+    /**
+     * The filename of the jar file of the generation unit.
+     * Has only effect if packaging is "jar".
+     *
+     * @parameter
+     */
+    private String jarFile;
+
+    /**
+     * Whether the generated files in newFileTargetDir should be treated
+     * as compileable sources.
+     *
+     * @parameter expression="true"
+     */
+    private boolean compileNewFileTargetDir;
+
+    /**
+     * Whether the generated files in modifiedFileTargetDir should be treated
+     * as compileable sources.
+     *
+     * @parameter expression="true"
+     */
+    private boolean compileModifiedFileTargetDir;
+
+    /**
+     * The config directory of the project overriding the settings.
+     * Then, the settings of this directory are used as "child"
+     * and the "normal" settings are used as "parent".
+     *
+     * @parameter
+     */
+    private File overrideConfigDir;
+
+    /**
+     * The Loglevel to use in the generation process. Must be one of
+     * trace, debug, info, warn or error.
+     *
+     * @parameter
+     */
+    private String loglevel;
+
+    /**
+     * Additional options which can be added to the generation process.
+     * This overrides any existing options.
+     *
+     * @parameter
+     */
+    private Map<String, String> options;
+
+    /**
+     * The Maven project this plugin runs in.
+     *
+     * @parameter expression="${project}"
+     * @required
+     * @readonly
+     */
+    private MavenProject project;
+
+    public void execute() throws MojoExecutionException
+    {
+        Controller controller = new Controller();
+        List<UnitDescriptor> unitDescriptors = new ArrayList<UnitDescriptor>();
+
+        UnitDescriptor.Packaging packaging;
+        if ("jar".equals(this.packaging))
+        {
+            packaging = UnitDescriptor.Packaging.JAR;
+        }
+        else if ("directory".equals(this.packaging))
+        {
+            packaging = UnitDescriptor.Packaging.DIRECTORY;
+        }
+        else if ("classpath".equals(this.packaging))
+        {
+            packaging = UnitDescriptor.Packaging.CLASSPATH;
+        }
+        else
+        {
+            throw new IllegalArgumentException(
+                    "Unknown packaging " + this.packaging
+                        + ", must be either jar or directory");
+        }
+        getLog().debug("Packaging is " + packaging);
+
+        ProjectPaths defaultProjectPaths;
+        if (UnitDescriptor.Packaging.JAR == packaging)
+        {
+            defaultProjectPaths
+                    = new Maven2JarProjectPaths(projectRootDir, jarFile);
+        }
+        else if (UnitDescriptor.Packaging.DIRECTORY == packaging)
+        {
+            defaultProjectPaths
+                    = new Maven2DirectoryProjectPaths(projectRootDir);
+        }
+        else if (UnitDescriptor.Packaging.CLASSPATH == packaging)
+        {
+            defaultProjectPaths
+                    = new Maven2DirectoryProjectPaths(projectRootDir);
+        }
+        else
+        {
+             throw new IllegalStateException("Unknown packaging" + packaging);
+        }
+
+        CustomProjectPaths projectPaths
+                = new CustomProjectPaths(defaultProjectPaths);
+
+        if (UnitDescriptor.Packaging.CLASSPATH == packaging)
+        {
+            if (configPackage == null)
+            {
+                throw new MojoExecutionException(
+                    "configPackage must be set for packaging =\"classpath\"");
+            }
+            projectPaths.setConfigurationPackage(configPackage);
+            projectPaths.setConfigurationDir(null);
+        }
+        else
+        {
+            if (configDir != null)
+            {
+                projectPaths.setConfigurationDir(configDir);
+                getLog().debug("Setting config dir to " + configDir.toString());
+            }
+        }
+
+        if (sourceDir != null)
+        {
+            projectPaths.setSourceDir(sourceDir);
+            getLog().debug("Setting source dir to " + sourceDir.toString());
+        }
+
+        if (newFileTargetDir != null)
+        {
+            projectPaths.setNewFileTargetDir(newFileTargetDir);
+            getLog().debug("Setting newFileTargetDir to "
+                    + newFileTargetDir.toString());
+        }
+        if (modifiedFileTargetDir != null)
+        {
+            projectPaths.setModifiedFileTargetDir(modifiedFileTargetDir);
+            getLog().debug("Setting modifiedFileTargetDir to "
+                    + modifiedFileTargetDir.toString());
+        }
+        getLog().debug("ProjectPaths = " + projectPaths);
+
+        OptionsConfiguration optionConfiguration = null;
+        if (options != null)
+        {
+            optionConfiguration = new MapOptionsConfiguration(options);
+        }
+        Loglevel convertedLoglevel = null;
+        if (this.loglevel != null)
+        {
+            convertedLoglevel = Loglevel.getByKey(loglevel);
+        }
+        UnitDescriptor unitDescriptor = new UnitDescriptor(
+                packaging,
+                projectPaths,
+                new DefaultTorqueGfPaths(),
+                null,
+                optionConfiguration,
+                convertedLoglevel);
+        getLog().debug("unit descriptor created");
+        if (overrideConfigDir != null)
+        {
+            CustomProjectPaths childProjectPaths
+                = new CustomProjectPaths(projectPaths);
+            childProjectPaths.setConfigurationDir(overrideConfigDir);
+            unitDescriptor = new UnitDescriptor(
+                    Packaging.DIRECTORY,
+                    childProjectPaths,
+                    new DefaultTorqueGfPaths(),
+                    unitDescriptor,
+                    optionConfiguration,
+                    convertedLoglevel);
+            getLog().debug("child unit descriptor created");
+        }
+        unitDescriptors.add(unitDescriptor);
+        try
+        {
+            getLog().debug("about to run controller");
+            controller.run(unitDescriptors);
+            getLog().info("Generation successful");
+        }
+        catch (Exception e)
+        {
+            getLog().error(e);
+            throw new MojoExecutionException(e.getMessage());
+        }
+
+        if (compileNewFileTargetDir
+                && projectPaths.getNewFileTargetPath().exists())
+        {
+            getLog().debug("Adding newFileTargetDir "
+                    + projectPaths.getNewFileTargetPath()
+                    + " as CompileSourceRoot");
+
+            project.addCompileSourceRoot(
+                    projectPaths.getNewFileTargetPath().toString());
+        }
+
+        if (compileModifiedFileTargetDir
+                && projectPaths.getModifiedFileTargetPath().exists())
+        {
+            getLog().debug("Adding modifiedFileTargetDir "
+                    + projectPaths.getModifiedFileTargetPath()
+                    + " as CompileSourceRoot");
+
+            project.addCompileSourceRoot(
+                    projectPaths.getModifiedFileTargetPath().toString());
+        }
+    }
+
+    /**
+     * Sets the packaging.
+     *
+     * @param packaging the packaging, either "jar" or "directory"
+     */
+    public void setPackaging(String packaging)
+    {
+        this.packaging = packaging;
+    }
+
+    /**
+     * Sets the root directory of the project.
+     *
+     * @param projectRootDir the project root Directory.
+     */
+    public void setProjectRootDir(File projectRootDir)
+    {
+        this.projectRootDir = projectRootDir;
+    }
+
+    public void setConfigDir(File configDir)
+    {
+        this.configDir = configDir;
+    }
+
+    public void setConfigPackage(String configPackage)
+    {
+        this.configPackage = configPackage;
+    }
+
+    /**
+     * Sets the target directory for files which are generated each time anew.
+     *
+     * @param targetDir the target directory, or null to use the default.
+     */
+    public void setNewFileTargetDir(File targetDir)
+    {
+        this.newFileTargetDir = targetDir;
+    }
+
+    /**
+     * Sets the target directory for files which are not generated
+     * each time anew.
+     *
+     * @param targetDir the target directory, or null to use the default.
+     */
+    public void setModifiedFileTargetDir(File targetDir)
+    {
+        this.modifiedFileTargetDir = targetDir;
+    }
+
+    /**
+     * The path to the jar file to use.
+     *
+     * @param jarFile the jar file, or null.
+     */
+    public void setJarFile(String jarFile)
+    {
+        this.jarFile = jarFile;
+    }
+
+    /**
+     * Sets the maven project this mojo runs in.
+     *
+     * @param project the maven project this mojo runs in.
+     */
+    public void setProject(MavenProject project)
+    {
+        this.project = project;
+    }
+}

Added: db/torque/torque4/trunk/maven-torque-gf-plugin/src/site/site.xml
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/maven-torque-gf-plugin/src/site/site.xml?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/maven-torque-gf-plugin/src/site/site.xml (added)
+++ db/torque/torque4/trunk/maven-torque-gf-plugin/src/site/site.xml Tue Feb 16 17:15:43 2010
@@ -0,0 +1,35 @@
+<?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.
+-->
+<project name="Maven-Torque-gf-plugin">
+  <bannerLeft>
+    <name>The apache db project</name>
+    <href>http://db.apache.org</href>
+  </bannerLeft>
+  <bannerRight>
+    <name>maven-torque-gf-plugin</name>
+    <href>http://db.apache.org/torque</href>
+  </bannerRight>
+  <body>
+    <menu name="Documentation">
+      <item name="Introduction" href="index.html"/>
+    </menu>
+    <menu ref="reports"/>
+  </body>
+</project>
\ No newline at end of file

Added: db/torque/torque4/trunk/maven-torque-gf-plugin/src/site/xdoc/index.xml
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/maven-torque-gf-plugin/src/site/xdoc/index.xml?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/maven-torque-gf-plugin/src/site/xdoc/index.xml (added)
+++ db/torque/torque4/trunk/maven-torque-gf-plugin/src/site/xdoc/index.xml Tue Feb 16 17:15:43 2010
@@ -0,0 +1,76 @@
+<?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.
+-->
+<document>
+
+ <properties>
+  <title>Maven 2 Torque-gf Plugin</title>
+ </properties>
+
+ <body>
+  <section name="Introduction">
+    <p>
+      The maven 2 torque-gf plugin provides the maven 2 integration of the
+      torque-gf Code generation Framework.
+    </p>
+    <p>
+      The only goal this plugin offers is the "generate" goal, which
+      starts the torque-gf generation process. 
+      A basic configuration for using pre-defined templates would be
+    </p>
+    <source><![CDATA[
+      <plugin>
+        <groupId>org.apache.torque</groupId>
+        <artifactId>maven-torque-gf-plugin</artifactId>
+        <version>0.2-SNAPSHOT</version>
+        <executions>
+          <execution>
+            <id>generate-sources</id>
+            <phase>generate-sources</phase>
+            <goals>
+              <goal>generate</goal>
+            </goals>
+            <configuration>
+              <packaging>classpath</packaging>
+              <configPackage>${templates-config-package}</configPackage>
+              ...
+            </configuration>
+          </execution>
+        </executions>
+        <dependencies>
+          <dependency>
+            <groupId>${templates-group-id}</groupId>
+            <artifactId>${templates-artifact-id}</artifactId>
+            <version>${templates-version}</version>
+          </dependency>
+        </dependencies>
+      </plugin>
+     ]]></source>   
+    <p>
+      See the documentation of the template package to get the values for
+      ${templates-config-package}, ${templates-group-id}, 
+      ${templates-artifact-id} and ${templates-version}.
+    </p>
+    <p>
+      See <a href="generate-mojo.html">the goal documentation</a>
+      for the avaliable configuration parameters.
+    </p> 
+  </section>
+ </body>
+</document>
\ No newline at end of file

Added: db/torque/torque4/trunk/maven-torque-gf-plugin/src/test/gettingStarted/src/main/torque-gf/conf/control.xml
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/maven-torque-gf-plugin/src/test/gettingStarted/src/main/torque-gf/conf/control.xml?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/maven-torque-gf-plugin/src/test/gettingStarted/src/main/torque-gf/conf/control.xml (added)
+++ db/torque/torque4/trunk/maven-torque-gf-plugin/src/test/gettingStarted/src/main/torque-gf/conf/control.xml Tue Feb 16 17:15:43 2010
@@ -0,0 +1,31 @@
+<?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.
+-->
+<control
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://db.apache.org/torque/gf/4.0/configuration http://db.apache.org/torque/gf/4.0/configuration.xsd"
+    xmlns="http://db.apache.org/torque/gf/4.0/configuration"
+    loglevel="debug">
+  <output name="propertyKeys" 
+      file="org/apache/torque/gf/example/gettingstarted/PropertyKeys.java">
+    <source path="propertiesData.properties"/>
+    <generator name="classFrame"/>
+  </output>
+</control>
+  
\ No newline at end of file

Added: db/torque/torque4/trunk/maven-torque-gf-plugin/src/test/gettingStarted/src/main/torque-gf/generatorDefs/enumGenerators.xml
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/maven-torque-gf-plugin/src/test/gettingStarted/src/main/torque-gf/generatorDefs/enumGenerators.xml?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/maven-torque-gf-plugin/src/test/gettingStarted/src/main/torque-gf/generatorDefs/enumGenerators.xml (added)
+++ db/torque/torque4/trunk/maven-torque-gf-plugin/src/test/gettingStarted/src/main/torque-gf/generatorDefs/enumGenerators.xml Tue Feb 16 17:15:43 2010
@@ -0,0 +1,53 @@
+<?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.
+-->
+<generators xmlns="http://db.apache.org/torque/gf/4.0/configuration"
+    xsi:schemaLocation="http://db.apache.org/torque/gf/4.0/configuration http://db.apache.org/torque/gf/4.0/generator.xsd"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+  <generator name="classFrame" xsi:type="velocityGenerator" path="classFrame.vm">
+    <mergepoint name="constants">
+      <action xsi:type="traverseAllAction" element="entry" generator="constant"/>
+    </mergepoint>
+    <mergepoint name="fields">
+      <action xsi:type="applyAction" generator="keyField"/>
+      <action xsi:type="applyAction" generator="newline"/>
+    </mergepoint>
+    <mergepoint name="methods">
+      <action xsi:type="applyAction" generator="constructor"/>
+      <action xsi:type="applyAction" generator="newline"/>
+      <action xsi:type="applyAction" generator="getKey"/>
+      <action xsi:type="applyAction" generator="newline"/>
+      <action xsi:type="applyAction" generator="toString"/>
+    </mergepoint>
+  </generator>
+  <generator name="constant" xsi:type="velocityGenerator" path="constant.vm">
+    <mergepoint name="constantName">
+      <action xsi:type="applyAction" generator="constantName"/>
+    </mergepoint>
+  </generator>
+  <generator name="constantName" xsi:type="javaGenerator" class="org.apache.torque.gf.generator.java.ConstantNameGenerator">
+    <inputSourceElement>.</inputSourceElement>
+    <sourceElementAttribute>key</sourceElementAttribute>
+  </generator>
+  <generator name="keyField" xsi:type="velocityGenerator" path="keyField.vm"/>
+  <generator name="constructor" xsi:type="velocityGenerator" path="constructor.vm"/>
+  <generator name="getKey" xsi:type="velocityGenerator" path="getKey.vm"/>
+  <generator name="toString" xsi:type="velocityGenerator" path="toString.vm"/>
+  <generator name="newline" xsi:type="javaGenerator" class="org.apache.torque.gf.generator.java.NewlineGenerator"/>
+</generators>
\ No newline at end of file

Added: db/torque/torque4/trunk/maven-torque-gf-plugin/src/test/gettingStarted/src/main/torque-gf/src/propertiesData.properties
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/maven-torque-gf-plugin/src/test/gettingStarted/src/main/torque-gf/src/propertiesData.properties?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/maven-torque-gf-plugin/src/test/gettingStarted/src/main/torque-gf/src/propertiesData.properties (added)
+++ db/torque/torque4/trunk/maven-torque-gf-plugin/src/test/gettingStarted/src/main/torque-gf/src/propertiesData.properties Tue Feb 16 17:15:43 2010
@@ -0,0 +1,19 @@
+# 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.
+
+torque.sample.property = sampleValue
+torque.some.other.property = someOtherValue

Added: db/torque/torque4/trunk/maven-torque-gf-plugin/src/test/gettingStarted/src/main/torque-gf/templates/classFrame.vm
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/maven-torque-gf-plugin/src/test/gettingStarted/src/main/torque-gf/templates/classFrame.vm?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/maven-torque-gf-plugin/src/test/gettingStarted/src/main/torque-gf/templates/classFrame.vm (added)
+++ db/torque/torque4/trunk/maven-torque-gf-plugin/src/test/gettingStarted/src/main/torque-gf/templates/classFrame.vm Tue Feb 16 17:15:43 2010
@@ -0,0 +1,47 @@
+## 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.
+##
+package org.apache.torque.gf.example.gettingstarted;
+
+/*
+ * 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.
+ */
+
+/**
+ * Contains all keys in the property file.
+ */
+public enum PropertyKeys 
+{
+$torqueGf.mergepoint("constants")##
+$torqueGf.mergepoint("fields")##
+$torqueGf.mergepoint("methods")##
+}

Added: db/torque/torque4/trunk/maven-torque-gf-plugin/src/test/gettingStarted/src/main/torque-gf/templates/constant.vm
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/maven-torque-gf-plugin/src/test/gettingStarted/src/main/torque-gf/templates/constant.vm?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/maven-torque-gf-plugin/src/test/gettingStarted/src/main/torque-gf/templates/constant.vm (added)
+++ db/torque/torque4/trunk/maven-torque-gf-plugin/src/test/gettingStarted/src/main/torque-gf/templates/constant.vm Tue Feb 16 17:15:43 2010
@@ -0,0 +1,21 @@
+## 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.
+##
+    /** Key for ${key} */
+    $torqueGf.mergepoint("constantName")("${key}")#if(${torqueGf.getSourceElement().hasFollowingSibling()}),#else;#end
+
+

Added: db/torque/torque4/trunk/maven-torque-gf-plugin/src/test/gettingStarted/src/main/torque-gf/templates/constructor.vm
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/maven-torque-gf-plugin/src/test/gettingStarted/src/main/torque-gf/templates/constructor.vm?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/maven-torque-gf-plugin/src/test/gettingStarted/src/main/torque-gf/templates/constructor.vm (added)
+++ db/torque/torque4/trunk/maven-torque-gf-plugin/src/test/gettingStarted/src/main/torque-gf/templates/constructor.vm Tue Feb 16 17:15:43 2010
@@ -0,0 +1,26 @@
+## 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.
+##
+    /**
+     * Constructor.
+     *
+     * @param key the key of the property. 
+     */
+    private PropertyKeys(String key)
+    {
+        this.key = key;
+    }

Added: db/torque/torque4/trunk/maven-torque-gf-plugin/src/test/gettingStarted/src/main/torque-gf/templates/getKey.vm
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/maven-torque-gf-plugin/src/test/gettingStarted/src/main/torque-gf/templates/getKey.vm?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/maven-torque-gf-plugin/src/test/gettingStarted/src/main/torque-gf/templates/getKey.vm (added)
+++ db/torque/torque4/trunk/maven-torque-gf-plugin/src/test/gettingStarted/src/main/torque-gf/templates/getKey.vm Tue Feb 16 17:15:43 2010
@@ -0,0 +1,26 @@
+## 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.
+##
+    /**
+     * Returns the property key.
+     *
+     * @return the property key.
+     */
+    public String getKey() 
+    {
+        return key;
+    }

Added: db/torque/torque4/trunk/maven-torque-gf-plugin/src/test/gettingStarted/src/main/torque-gf/templates/keyField.vm
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/maven-torque-gf-plugin/src/test/gettingStarted/src/main/torque-gf/templates/keyField.vm?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/maven-torque-gf-plugin/src/test/gettingStarted/src/main/torque-gf/templates/keyField.vm (added)
+++ db/torque/torque4/trunk/maven-torque-gf-plugin/src/test/gettingStarted/src/main/torque-gf/templates/keyField.vm Tue Feb 16 17:15:43 2010
@@ -0,0 +1,19 @@
+## 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.
+##
+    /** The property key. */
+    private String key;

Added: db/torque/torque4/trunk/maven-torque-gf-plugin/src/test/gettingStarted/src/main/torque-gf/templates/toString.vm
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/maven-torque-gf-plugin/src/test/gettingStarted/src/main/torque-gf/templates/toString.vm?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/maven-torque-gf-plugin/src/test/gettingStarted/src/main/torque-gf/templates/toString.vm (added)
+++ db/torque/torque4/trunk/maven-torque-gf-plugin/src/test/gettingStarted/src/main/torque-gf/templates/toString.vm Tue Feb 16 17:15:43 2010
@@ -0,0 +1,22 @@
+## 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.
+##
+    @Override
+    public String toString()
+    {
+        return key;
+    }

Added: db/torque/torque4/trunk/maven-torque-gf-plugin/src/test/java/org/apache/torque/gf/maven/GettingStartedTest.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/maven-torque-gf-plugin/src/test/java/org/apache/torque/gf/maven/GettingStartedTest.java?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/maven-torque-gf-plugin/src/test/java/org/apache/torque/gf/maven/GettingStartedTest.java (added)
+++ db/torque/torque4/trunk/maven-torque-gf-plugin/src/test/java/org/apache/torque/gf/maven/GettingStartedTest.java Tue Feb 16 17:15:43 2010
@@ -0,0 +1,53 @@
+package org.apache.torque.gf.maven;
+
+/*
+ * 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.
+ */
+
+import java.io.File;
+
+import junit.framework.TestCase;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.maven.project.MavenProject;
+
+public class GettingStartedTest extends TestCase
+{
+    public void testRun() throws Exception
+    {
+        File target = new File("target/tests/gettingStarted");
+        FileUtils.deleteDirectory(target);
+        TorqueGfMojo mojo = new TorqueGfMojo();
+        mojo.setPackaging("directory");
+        mojo.setProjectRootDir(new File("src/test/gettingStarted"));
+        mojo.setNewFileTargetDir(target);
+        mojo.setProject(new MavenProject());
+        mojo.execute();
+
+        assertTrue(target.exists());
+        File generatedJavaFile = new File(
+                target,
+                "org/apache/torque/gf/example/gettingstarted/PropertyKeys.java");
+        assertTrue(generatedJavaFile.exists());
+        File expectedJavaFile = new File(
+                "src/test/resources/org/apache/torque/gf/example/gettingstarted/PropertyKeys.java");
+        junitx.framework.FileAssert.assertEquals(
+                expectedJavaFile,
+                generatedJavaFile);
+    }
+}

Added: db/torque/torque4/trunk/maven-torque-gf-plugin/src/test/resources/org/apache/torque/gf/example/gettingstarted/PropertyKeys.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/maven-torque-gf-plugin/src/test/resources/org/apache/torque/gf/example/gettingstarted/PropertyKeys.java?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/maven-torque-gf-plugin/src/test/resources/org/apache/torque/gf/example/gettingstarted/PropertyKeys.java (added)
+++ db/torque/torque4/trunk/maven-torque-gf-plugin/src/test/resources/org/apache/torque/gf/example/gettingstarted/PropertyKeys.java Tue Feb 16 17:15:43 2010
@@ -0,0 +1,61 @@
+package org.apache.torque.gf.example.gettingstarted;
+
+/*
+ * 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.
+ */
+
+/**
+ * Contains all keys in the property file.
+ */
+public enum PropertyKeys 
+{
+    /** Key for torque.sample.property */
+    TORQUE_SAMPLE_PROPERTY("torque.sample.property"),
+
+    /** Key for torque.some.other.property */
+    TORQUE_SOME_OTHER_PROPERTY("torque.some.other.property");
+
+    /** The property key. */
+    private String key;
+
+    /**
+     * Constructor.
+     *
+     * @param key the key of the property. 
+     */
+    private PropertyKeys(String key)
+    {
+        this.key = key;
+    }
+
+    /**
+     * Returns the property key.
+     *
+     * @return the property key.
+     */
+    public String getKey() 
+    {
+        return key;
+    }
+
+    @Override
+    public String toString()
+    {
+        return key;
+    }
+}

Added: db/torque/torque4/trunk/torque-generator/pom.xml
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/pom.xml?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-generator/pom.xml (added)
+++ db/torque/torque4/trunk/torque-generator/pom.xml Tue Feb 16 17:15:43 2010
@@ -0,0 +1,235 @@
+<?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.
+-->
+<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/maven-v4_0_0.xsd">
+
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.apache.torque</groupId>
+  <artifactId>torque-gf</artifactId>
+  <packaging>jar</packaging>
+  <version>0.2-SNAPSHOT</version>
+  <name>Torque Generation Framework</name>
+  <url>http://db.apache.org/torque</url>
+  <dependencies>
+    <dependency>
+      <groupId>velocity</groupId>
+      <artifactId>velocity</artifactId>
+      <version>1.4</version>
+    </dependency>
+    <dependency>
+      <groupId>commons-logging</groupId>
+      <artifactId>commons-logging</artifactId>
+      <version>1.0.4</version>
+    </dependency>
+    <dependency>
+      <groupId>log4j</groupId>
+      <artifactId>log4j</artifactId>
+      <version>1.2.13</version>
+    </dependency>
+    <dependency>
+      <groupId>commons-lang</groupId>
+      <artifactId>commons-lang</artifactId>
+      <version>2.1</version>
+    </dependency>
+    <dependency>
+      <groupId>commons-collections</groupId>
+      <artifactId>commons-collections</artifactId>
+      <version>3.1</version>
+    </dependency>
+    <dependency>
+      <groupId>commons-beanutils</groupId>
+      <artifactId>commons-beanutils-core</artifactId>
+      <version>1.7.0</version>
+    </dependency>
+    <dependency>
+      <groupId>commons-io</groupId>
+      <artifactId>commons-io</artifactId>
+      <version>1.3.1</version>
+    </dependency>
+
+    <!--dependency>
+      <groupId>org.netbeans.mdr</groupId>
+      <artifactId>jmiutils</artifactId>
+      <version>200507110943</version>
+    </dependency>
+    <dependency>
+      <groupId>jmi</groupId>
+      <artifactId>jmiuml</artifactId>
+      <version>1.4di</version>
+    </dependency-->
+
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>4.4</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>junit-addons</groupId>
+      <artifactId>junit-addons</artifactId>
+      <version>1.4</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <configuration>
+          <source>1.5</source>
+          <target>1.5</target>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <version>2.4.2</version>
+        <configuration>
+          <excludes>
+            <exclude>BaseTest.java</exclude>
+          </excludes>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-eclipse-plugin</artifactId>
+        <configuration>
+          <downloadSources>true</downloadSources>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-source-plugin</artifactId>
+        <executions>
+          <execution>
+            <phase>package</phase>
+            <goals>
+              <goal>jar</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-antrun-plugin</artifactId>
+        <executions>
+          <execution>
+            <phase>process-test-resources</phase>
+            <configuration>
+              <tasks>
+                <!-- prepare the PropertyToJavaJarGenerationTest -->
+                <mkdir dir="${basedir}/target/test/propertyToJavaJar/src/main/torque-gf/src"/>
+                <copy todir="${basedir}/target/test/propertyToJavaJar/src/main/torque-gf/src">
+                  <fileset dir="${basedir}/src/test/propertyToJava/src/main/torque-gf/src" />
+                </copy>
+                <jar basedir="${basedir}/src/test/propertyToJava/src/main/torque-gf"
+                    destfile="${basedir}/target/test/propertyToJavaJar/src/main/torque-gf/propertyToJava.jar"/>
+              </tasks>
+            </configuration>
+            <goals>
+              <goal>run</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+      <!--plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-assembly-plugin</artifactId>
+        <configuration>
+          <descriptorRefs>
+            <descriptorRef>src</descriptorRef>
+          </descriptorRefs>
+        </configuration>
+        <executions>
+          <execution>
+            <id>make-assembly</id>
+            <phase>package</phase>
+            <goals>
+              <goal>assembly</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin-->
+      <plugin>
+        <groupId>org.apache.rat</groupId>
+        <artifactId>apache-rat-plugin</artifactId>
+      </plugin>
+    </plugins>
+  </build>
+  
+  <reporting>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-jxr-plugin</artifactId>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-javadoc-plugin</artifactId>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-surefire-report-plugin</artifactId>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-pmd-plugin</artifactId>
+        <configuration>
+          <linkXref>true</linkXref>
+          <targetJdk>1.5</targetJdk>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.codehaus.mojo</groupId>
+        <artifactId>findbugs-maven-plugin</artifactId>
+        <version>2.0.1</version>
+        <configuration>
+          <excludeFilterFile>${basedir}/src/maven-plugin-config/findbugs/findbugs-exclude.xml</excludeFilterFile>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-checkstyle-plugin</artifactId>
+        <configuration>
+          <configLocation>${basedir}/src/maven-plugin-config/checkstyle/turbine-checkstyle.xml</configLocation>
+          <headerLocation>${basedir}/src/maven-plugin-config/checkstyle/checkstyle-license.txt</headerLocation>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.codehaus.mojo</groupId>
+        <artifactId>jdepend-maven-plugin</artifactId>
+      </plugin>
+      <plugin>
+        <groupId>org.codehaus.mojo</groupId>
+        <artifactId>cobertura-maven-plugin</artifactId>
+        <version>2.3</version>
+      </plugin>
+    </plugins>
+  </reporting>
+  
+  <properties>
+    <project.build.sourceEncoding>ISO-8859-1</project.build.sourceEncoding>
+  </properties>
+  
+</project>
\ No newline at end of file

Added: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/ClassHelper.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/ClassHelper.java?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/ClassHelper.java (added)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/ClassHelper.java Tue Feb 16 17:15:43 2010
@@ -0,0 +1,93 @@
+package org.apache.torque.gf.configuration;
+
+/*
+ * 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.
+ */
+
+
+/**
+ * Helper for instantiating classes.
+ * $Id: $
+ */
+public final class ClassHelper
+{
+    /**
+     * No Instances for utility class.
+     */
+    private ClassHelper()
+    {
+    }
+
+    /**
+     * Creates an instance of ca class and checks whether it can be casted
+     * to another class
+     *
+     * @param className the fully qualified name of the class to instantiate.
+     * @param isInstanceOf the Interface or class the instance
+     *        must be an instance of, or null to disable the check.
+     *
+     * @throws ConfigurationException if the class cannot be instantiated
+     *         or it is not an instance of <code>isInstanceOf</code>
+     */
+    public static Object getInstance(
+                    String className,
+                    Class<?> isInstanceOf)
+            throws ConfigurationException
+    {
+        if (className == null)
+        {
+            return null;
+        }
+        Object result;
+        try
+        {
+            Class<?> clazz = Class.forName(className);
+            result = clazz.newInstance();
+        }
+        catch (ClassNotFoundException e)
+        {
+            throw new ConfigurationException("The class "
+                         + className
+                         + " could not be found.",
+                    e);
+        }
+        catch (IllegalAccessException e)
+        {
+            throw new ConfigurationException("Instantiating "
+                        + className
+                        + " is not allowed",
+                    e);
+        }
+        catch (InstantiationException e)
+        {
+            throw new ConfigurationException("The class "
+                        + className
+                        + " has no standard constructor.",
+                    e);
+        }
+        if (isInstanceOf != null
+            && !(isInstanceOf.isInstance(result)))
+        {
+            throw new ConfigurationException("Classes with class : "
+                    + className
+                    + " are not instances of "
+                    + isInstanceOf.getName());
+        }
+        return result;
+    }
+}

Added: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/ClasspathConfigurationProvider.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/ClasspathConfigurationProvider.java?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/ClasspathConfigurationProvider.java (added)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/ClasspathConfigurationProvider.java Tue Feb 16 17:15:43 2010
@@ -0,0 +1,301 @@
+package org.apache.torque.gf.configuration;
+
+/*
+ * 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.
+ */
+
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.jar.JarFile;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.torque.gf.configuration.paths.TorqueGfPaths;
+import org.apache.torque.gf.configuration.paths.ProjectPaths;
+
+/**
+ * Provides InputStreams to read a configuration of a unit of generation from a
+ * jar file.
+ */
+public class ClasspathConfigurationProvider implements ConfigurationProvider
+{
+    /** The logger. */
+    private static Log log
+            = LogFactory.getLog(ClasspathConfigurationProvider.class);
+
+    /**
+     * The paths needed to interact with the enclosing project, not null.
+     */
+    private ProjectPaths projectPaths;
+
+    /**
+     * The internal directory structure of the generator configuration files,
+     * not null.
+     */
+    private TorqueGfPaths configurationPaths;
+
+    /** The prefix if an url points to a file. */
+    private static final String FILE_URL_PREFIX = "file:";
+
+    /**
+     * Constructor.
+     * @param projectPaths the paths needed to interact with the enclosing
+     *         project, not null.
+     * @param configurationPaths The internal directory structure of the
+     *         generator configuration files, not null.
+     *
+     * @throws NullPointerException if projectPaths or configurationPaths
+     *          are null.
+     */
+    public ClasspathConfigurationProvider(
+            ProjectPaths projectPaths,
+            TorqueGfPaths configurationPaths)
+    {
+        if (projectPaths == null)
+        {
+            throw new NullPointerException("projectPaths is null");
+        }
+        if (configurationPaths == null)
+        {
+            throw new NullPointerException("configurationPaths is null");
+        }
+        this.projectPaths = projectPaths;
+        this.configurationPaths = configurationPaths;
+    }
+
+    public InputStream getControlConfigurationInputStream()
+        throws ConfigurationException
+    {
+        String configFileName
+                = getConfigResourceBase()
+                    + "/"
+                    + configurationPaths.getConfigurationDirectory()
+                    + "/"
+                    + configurationPaths.getControlConfigurationFile();
+
+        InputStream inputStream
+                = getClass().getClassLoader().getResourceAsStream(
+                        configFileName);
+        if (inputStream == null)
+        {
+            throw new ConfigurationException("Could not read entry "
+                        + configFileName
+                        + " in classpath");
+        }
+        BufferedInputStream bis = new BufferedInputStream(inputStream);
+        if (log.isInfoEnabled())
+        {
+            log.info("Using control file: '"
+                    + configFileName
+                    + "' from classpath");
+        }
+        return bis;
+    }
+
+    public InputStream getTemplateInputStream(String name)
+        throws ConfigurationException
+    {
+        String templateFileName
+                = getConfigResourceBase()
+                    + "/"
+                    + configurationPaths.getTemplateSubdirectory()
+                    + "/"
+                    + name;
+
+        InputStream inputStream
+                = getClass().getClassLoader().getResourceAsStream(
+                        templateFileName);
+
+        if (inputStream == null)
+        {
+            throw new ConfigurationException("Could not read template file "
+                        + templateFileName
+                        + " in classpath");
+        }
+        BufferedInputStream bis = new BufferedInputStream(inputStream);
+        if (log.isInfoEnabled())
+        {
+            log.info("Reading template: '"
+                    + templateFileName
+                    + "' in class path");
+        }
+        return bis;
+    }
+
+    public InputStream getGeneratorConfigurationInputStream(String name)
+        throws ConfigurationException
+    {
+        String generatorConfigFileName
+                = getConfigResourceBase()
+                    + "/"
+                    + configurationPaths.getGeneratorDefDirectory()
+                    + "/"
+                    + name;
+
+        InputStream inputStream
+                = getClass().getClassLoader().getResourceAsStream(
+                        generatorConfigFileName);
+
+        if (inputStream == null)
+        {
+            throw new ConfigurationException(
+                    "Could not read generator configuration file "
+                        + generatorConfigFileName
+                        + " in classpath");
+        }
+        BufferedInputStream bis = new BufferedInputStream(inputStream);
+        if (log.isInfoEnabled())
+        {
+            log.info("Reading generator configuration file: '"
+                    + generatorConfigFileName
+                    + "' in classpath");
+        }
+        return bis;
+   }
+
+    public Collection<String> getGeneratorConfigurationNames()
+        throws ConfigurationException
+    {
+        String generatorConfigurationSubdir
+                = getConfigResourceBase()
+                    + "/"
+                    + configurationPaths.getGeneratorDefDirectory();
+        generatorConfigurationSubdir
+                = generatorConfigurationSubdir.replace('\\', '/');
+
+
+        URL dirUrl = getClass().getClassLoader().getResource(
+                    generatorConfigurationSubdir);
+        String dirUrlString = dirUrl.toExternalForm();
+        if (dirUrlString.startsWith("jar"))
+        {
+            String jarFilePath = dirUrl.getFile();
+            if (jarFilePath.startsWith(FILE_URL_PREFIX))
+            {
+                jarFilePath = jarFilePath.substring(FILE_URL_PREFIX.length());
+            }
+            jarFilePath = jarFilePath.substring(0, jarFilePath.indexOf("!"));
+            if (log.isDebugEnabled())
+            {
+                log.debug("generator config located in jar file"
+                        + jarFilePath);
+            }
+            JarFile jarFile;
+            try
+            {
+                jarFile = new JarFile(jarFilePath);
+            }
+            catch (IOException e)
+            {
+                log.error("Could not open jar File "
+                        + jarFilePath);
+                throw new ConfigurationException(e);
+            }
+
+            String generatorConfigurationDirectory
+                    = dirUrlString.substring(dirUrlString.lastIndexOf("!") + 1);
+            if (generatorConfigurationDirectory.startsWith("/"))
+            {
+                generatorConfigurationDirectory
+                        = generatorConfigurationDirectory.substring(1);
+            }
+            return JarConfigurationProvider.getGeneratorConfigurationNames(
+                    jarFile,
+                    generatorConfigurationDirectory);
+        }
+        File directory = new File(dirUrl.getFile());
+        if (!directory.exists())
+        {
+            throw new ConfigurationException(
+                    "Could not read generator directory "
+                        + generatorConfigurationSubdir
+                        + " in classpath; directory URL is "
+                        + dirUrl
+                        + " file is "
+                        + dirUrl.getFile());
+        }
+        String[] filenames = directory.list();
+
+        List<String> result = new ArrayList<String>();
+        for (String filename : filenames)
+        {
+            File file = new File(filename);
+            if (file.isDirectory())
+            {
+                continue;
+            }
+            String rawName = file.getName();
+            if (!rawName.endsWith(".xml"))
+            {
+                continue;
+            }
+            result.add(filename);
+        }
+        return result;
+    }
+
+    public InputStream getOptionsInputStream(String name)
+        throws ConfigurationException
+    {
+        String optionsFileName
+                = getConfigResourceBase()
+                    + "/"
+                    + configurationPaths.getConfigurationDirectory()
+                    + "/"
+                    + name;
+
+        InputStream inputStream
+                = getClass().getClassLoader().getResourceAsStream(
+                        optionsFileName);
+
+        if (inputStream == null)
+        {
+            throw new ConfigurationException("Could not read options file "
+                        + optionsFileName
+                        + " in classpath");
+        }
+        BufferedInputStream bis = new BufferedInputStream(inputStream);
+        if (log.isInfoEnabled())
+        {
+            log.info("Reading options file: '"
+                    +  optionsFileName
+                     + "' in classpath");
+        }
+        return bis;
+    }
+
+    /**
+     * Gets the resource name for the configuration base directory from the
+     * projectPaths.
+     *
+     * @return the resource name for the configuration base directory,
+     *         not null.
+     */
+    private String getConfigResourceBase()
+    {
+        String configResourceBase
+            = projectPaths.getConfigurationPackage().replace('.', '/');
+        return configResourceBase;
+    }
+}

Added: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/Configuration.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/Configuration.java?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/Configuration.java (added)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/Configuration.java Tue Feb 16 17:15:43 2010
@@ -0,0 +1,185 @@
+package org.apache.torque.gf.configuration;
+
+/*
+ * 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.
+ */
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.torque.gf.configuration.controller.Loglevel;
+
+/**
+ * The configuration class keeps the complete configuration needed for the
+ * generation process. It is supplied with UnitDescriptors describing the
+ * available units of generation, and can then read the configuration.
+ * After the configuration is read, no new units of generation can be added.
+ */
+public class Configuration
+{
+    /**
+     * All known units of generation.
+     */
+    private List<UnitDescriptor> unitDescriptors
+            = new ArrayList<UnitDescriptor>();
+
+    /**
+     * The configurations for all known units of generation.
+     */
+    private List<UnitConfiguration> unitConfigurations;
+
+    /**
+     * The available configuration handlers.
+     */
+    private ConfigurationHandlers configurationHandlers
+        = new ConfigurationHandlers();
+
+    /**
+     * Whether the configuration has already been read.
+     */
+    private boolean read = false;
+
+    /**
+     * Adds a unit of generation to the configuration.
+     *
+     * @param unitDescriptor Describes the unit of generation to add,
+     *         not null.
+     *
+     * @throws NullPointerException if unitDescriptor is null.
+     * @throws IllegalStateException if the configuration has already been
+     *          read.
+     */
+    public void addUnit(UnitDescriptor unitDescriptor)
+    {
+        if (unitDescriptor == null)
+        {
+            throw new NullPointerException("unitDescriptor must not be null.");
+        }
+        if (read)
+        {
+            throw new IllegalStateException(
+                    "Configuration has already been read.");
+        }
+        unitDescriptors.add(unitDescriptor);
+    }
+
+
+    /**
+     * Adds several units of generation to the configuration.
+     *
+     * @param unitDescriptors Describes the units of generation to add,
+     *         not null.
+     *
+     * @throws NullPointerException if unitDescriptors is null or the list
+     *          contains a null entry.
+     * @throws IllegalStateException if the configuration has already been
+     *          read.
+     */
+    public void addUnits(List<UnitDescriptor> unitDescriptors)
+    {
+        for (UnitDescriptor unitDescriptor : unitDescriptors)
+        {
+            addUnit(unitDescriptor);
+        }
+    }
+
+    /**
+     * Reads the configuration.
+     *
+     * @throws ConfigurationException if an error occurs during reading the
+     *          configuration.
+     */
+    public void read() throws ConfigurationException
+    {
+        if (read)
+        {
+            throw new IllegalStateException(
+                    "Configuration has already been read.");
+        }
+        unitConfigurations = new ArrayList<UnitConfiguration>();
+        Loglevel oldLoglevel = Loglevel.getCurrentLoglevel();
+        for (UnitDescriptor unitDescriptor : unitDescriptors)
+        {
+           if (unitDescriptor.getLoglevel() != null)
+           {
+               unitDescriptor.getLoglevel().apply();
+           }
+           else
+           {
+               oldLoglevel.apply();
+           }
+           UnitConfigurationReader configurationReader
+                    = new UnitConfigurationReader();
+
+            UnitConfiguration unitConfiguration
+                = configurationReader.read(
+                        unitDescriptor,
+                        configurationHandlers);
+            if (unitDescriptor.getLoglevel() != null)
+            {
+                unitConfiguration.setLoglevel(unitDescriptor.getLoglevel());
+            }
+            unitConfigurations.add(unitConfiguration);
+        }
+        read = true;
+     }
+
+    /**
+     * Returns the list of UnitConfigurations.
+     *
+     * @return the list of unit configurations, never null.
+     *
+     * @throws IllegalStateException if the configuration was not yet read.
+     */
+    public List<UnitConfiguration> getUnitConfigurations()
+    {
+        if (!read)
+        {
+            throw new IllegalStateException("Configuration was not yet read");
+        }
+        return Collections.unmodifiableList(unitConfigurations);
+    }
+
+    /**
+     * Returns the available configuration handlers.
+     *
+     * @return the available configuration handlers, not null.
+     */
+    public ConfigurationHandlers getConfigurationHandlers()
+    {
+        return configurationHandlers;
+    }
+
+    /**
+     * Sets the available configuration handlers.
+     *
+     * @param configurationHandlers the available configuration handlers,
+     *        not null.
+     */
+    public void setConfigurationHandlers(
+            ConfigurationHandlers configurationHandlers)
+    {
+        if (configurationHandlers == null)
+        {
+            throw new NullPointerException(
+                    "configurationHandlers must not be null");
+        }
+        this.configurationHandlers = configurationHandlers;
+    }
+}

Added: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/ConfigurationEntityResolver.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/ConfigurationEntityResolver.java?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/ConfigurationEntityResolver.java (added)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/ConfigurationEntityResolver.java Tue Feb 16 17:15:43 2010
@@ -0,0 +1,143 @@
+package org.apache.torque.gf.configuration;
+
+/*
+ * 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.
+ */
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.xml.sax.EntityResolver;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+/**
+ * A resolver to get the confoguration.xsd file for the XML parser from the jar.
+ *
+ * @version $Id: DTDResolver.java 491216 2006-12-30 12:14:45Z tfischer $
+ */
+public class ConfigurationEntityResolver implements EntityResolver
+{
+   /** The SystemId of the configuration schema. */
+    public static final String CONFIGURATION_SCHEMA_SYSTEMID
+            = XMLConstants.GF_CONFIGURATION_NAMESPACE + ".xsd";
+
+    /** The SystemId of the configuration schema. */
+    public static final String GENERATOR_SCHEMA_SYSTEMID
+            = XMLConstants.GF_GENERATOR_NAMESPACE + ".xsd";
+
+    /** Logging class from commons.logging */
+    private static Log log
+            = LogFactory.getLog(ConfigurationEntityResolver.class);
+
+    /** The class object of this class. */
+    private static final Class<ConfigurationEntityResolver> CLAZZ
+            = ConfigurationEntityResolver.class;
+
+    /**
+     * An implementation of the SAX <code>EntityResolver</code>
+     * interface to be called by the XML parser.  If the URI is known,
+     * the corresponding resource from the jar is returned.
+     * In all other cases, null is returned to indicate that the parser
+     * should open a regular connection to the systemId URI.
+     *
+     * @param publicId The public identifier of the external entity
+     * @param systemId The system identifier of the external entity
+     * @return An <code>InputSource</code> for the entity if the uri is known,
+     *         or null otherwise.
+     */
+    public InputSource resolveEntity(String publicId, String systemId)
+            throws IOException, SAXException
+    {
+        if (CONFIGURATION_SCHEMA_SYSTEMID.equals(systemId))
+        {
+            return readFromClasspath("configuration.xsd");
+        }
+        else if (GENERATOR_SCHEMA_SYSTEMID.equals(systemId))
+        {
+            return readFromClasspath("generator.xsd");
+        }
+        else
+        {
+            log.debug("Resolver: used default behaviour");
+            return null;
+        }
+    }
+
+    /**
+     * Reads the resource with the given name from the classpath.
+     *
+     * @param resourceName the name of the resource to read
+     * @return an <code>InputSource</code> with the content of the resource.
+     *
+     * @throws SAXException if the resource cannot be read.
+     */
+    private InputSource readFromClasspath(String resourceName)
+        throws SAXException
+    {
+        try
+        {
+            InputStream inputStream
+                    = CLAZZ.getResourceAsStream(resourceName);
+
+            // getResource was buggy on many systems including Linux,
+            // OSX, and some versions of windows in jdk1.3.
+            // getResourceAsStream works on linux, maybe others?
+            if (inputStream != null)
+            {
+                String pkg = CLAZZ.getName().substring(0,
+                        CLAZZ.getName().lastIndexOf('.'));
+                log.debug("Resolver: used " + resourceName + " from '"
+                         + pkg + "' package");
+                return new InputSource(inputStream);
+            }
+            else
+            {
+                log.warn("Could not locate resource");
+                return null;
+            }
+        }
+        catch (Exception ex)
+        {
+            throw new SAXException(
+                    "Could not get stream for " + resourceName,
+                    ex);
+        }
+    }
+}

Added: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/ConfigurationException.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/ConfigurationException.java?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/ConfigurationException.java (added)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/ConfigurationException.java Tue Feb 16 17:15:43 2010
@@ -0,0 +1,83 @@
+package org.apache.torque.gf.configuration;
+
+/*
+ * 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.
+ */
+
+import org.apache.torque.gf.generator.GeneratorException;
+
+/**
+ * This exception is thrown if the Torque generator cannot access its
+ * configuration or if an error occurs accessing the configuration.
+ */
+public class ConfigurationException extends GeneratorException
+{
+    /**
+     * The version of the class
+     * (for serialisation and deserialisation purposes).
+     */
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * Constructs a ConfigurationException without error message.
+     *
+     * @see Exception#Exception()
+     */
+    public ConfigurationException()
+    {
+        super();
+    }
+
+    /**
+     * Constructs a ConfigurationException with the given error message.
+     *
+     * @param message the error message
+     *
+     * @see Exception#Exception(java.lang.String)
+     */
+    public ConfigurationException(String message)
+    {
+        super(message);
+    }
+
+    /**
+     * Constructs a ConfigurationException which wraps another exception.
+     *
+     * @param cause The initial exception which was caught.
+     *
+     * @see Exception#Exception(java.lang.Throwable)
+     */
+    public ConfigurationException(Throwable cause)
+    {
+        super(cause);
+    }
+
+    /**
+     * Constructs a ConfigurationException which wraps another exception,
+     * and which has its own error message.
+     *
+     * @param message The error message.
+     * @param cause The exception to wrap.
+     *
+     * @see Exception#Exception(java.lang.String, java.lang.Throwable)
+     */
+    public ConfigurationException(String message, Throwable cause)
+    {
+        super(message, cause);
+    }
+}

Added: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/ConfigurationHandlers.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/ConfigurationHandlers.java?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/ConfigurationHandlers.java (added)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/ConfigurationHandlers.java Tue Feb 16 17:15:43 2010
@@ -0,0 +1,108 @@
+package org.apache.torque.gf.configuration;
+
+/*
+ * 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.
+ */
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.torque.gf.configuration.mergepoint.ActionSaxHandlerFactories;
+import org.apache.torque.gf.configuration.mergepoint.OptionsSaxHandlerFactories;
+import org.apache.torque.gf.source.SourceType;
+import org.apache.torque.gf.source.properties.PropertiesSourceType;
+import org.apache.torque.gf.source.xml.XmlSourceType;
+
+/**
+ * Contains the required handlers for reading the configuration.
+ *
+ * $Id: $
+ */
+public class ConfigurationHandlers
+{
+    /**
+     * The known types of generators and how to read their configuration.
+     */
+    private GeneratorTypes generatorTypes = new GeneratorTypes();
+
+    /**
+     * The known types of source types.
+     */
+    private Set<SourceType> sourceTypes = new HashSet<SourceType>();
+
+    /**
+     * The known types of mergepoint action handlers.
+     */
+    private ActionSaxHandlerFactories actionSaxHandlerFactories
+            = new ActionSaxHandlerFactories();
+
+    /**
+     * The known types of options.
+     */
+    private OptionsSaxHandlerFactories optionsSaxHandlerFactories
+            = new OptionsSaxHandlerFactories();
+
+    /**
+     * Standard constructor.
+     */
+    public ConfigurationHandlers()
+    {
+        sourceTypes.add(new XmlSourceType());
+        sourceTypes.add(new PropertiesSourceType());
+    }
+
+    /**
+     * Returns the known generator types.
+     *
+     * @return the known generator types.
+     */
+    public GeneratorTypes getGeneratorTypes()
+    {
+        return generatorTypes;
+    }
+
+    /**
+     * Returns the known source types.
+     *
+     * @return the known source types.
+     */
+    public Set<SourceType> getSourceTypes()
+    {
+        return sourceTypes;
+    }
+
+    /**
+     * Returns the known mergepoint action handlers.
+     *
+     * @return the known mergepoint action handlers.
+     */
+    public ActionSaxHandlerFactories getActionSaxHandlerFactories()
+    {
+        return actionSaxHandlerFactories;
+    }
+
+    /**
+     * Returns the known options handlers.
+     *
+     * @return the known options handlers.
+     */
+    public OptionsSaxHandlerFactories getOptionsSaxHandlerFactories()
+    {
+        return optionsSaxHandlerFactories;
+    }
+}

Added: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/ConfigurationProvider.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/ConfigurationProvider.java?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/ConfigurationProvider.java (added)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/ConfigurationProvider.java Tue Feb 16 17:15:43 2010
@@ -0,0 +1,92 @@
+package org.apache.torque.gf.configuration;
+
+/*
+ * 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.
+ */
+
+import java.io.InputStream;
+import java.util.Collection;
+
+/**
+ * Defines how the configuration for a generation unit can be accessed.
+ * Implementing classes provide InputStreams to access the various parts
+ * of the configuration.
+ */
+public interface ConfigurationProvider
+{
+    /**
+     * Creates a reader to access the control configuration.
+     * It is the callers responsibility to close the reader after use.
+     *
+     * @return a reader to access the control configuration, never null.
+     * @throws ConfigurationException if the reader can not be created.
+     */
+    InputStream getControlConfigurationInputStream()
+        throws ConfigurationException;
+
+    /**
+     * Creates a reader to access a template.
+     * It is the callers responsibility to close the reader after use.
+     *
+     * @param name the name (==path to) of the template.
+     *
+     * @return a reader to access a template, never null.
+     *
+     * @throws ConfigurationException if the reader can not be created.
+     */
+    InputStream getTemplateInputStream(String name)
+        throws ConfigurationException;
+
+    /**
+     * Returns a list of all found generator configuration files in the
+     * generation unit.
+     *
+     * @return a list with the generation configuration files, not null.
+     *
+     * @throws ConfigurationException if the configuration can not be read.
+     */
+    Collection<String> getGeneratorConfigurationNames()
+        throws ConfigurationException;
+
+    /**
+     * Creates a reader to access the configuration for one generator..
+     * It is the callers responsibility to close the reader after use.
+     *
+     * @param name the name (==path to) of the generator configuration.
+     *
+     * @return a reader to access the generator configuration, never null.
+     *
+     * @throws ConfigurationException if the reader can not be created.
+     */
+    InputStream getGeneratorConfigurationInputStream(String name)
+        throws ConfigurationException;
+
+    /**
+     * Creates a reader to access an options file.
+     * It is the callers responsibility to close the reader after use.
+     *
+     * @param name the name (==path to) of the options file.
+     *
+     * @return a reader to access the options file, never null.
+     *
+     * @throws ConfigurationException if the reader can not be created.
+     */
+    InputStream getOptionsInputStream(String name)
+        throws ConfigurationException;
+
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org