You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ibatis.apache.org by jg...@apache.org on 2010/03/01 00:55:42 UTC
svn commit: r917330 - in /ibatis/java/ibator/trunk/core: ibator-core/doc/
ibator-core/doc/html/ ibator-core/doc/html/reference/
ibator-core/doc/html/running/
ibator-core/src/main/java/org/apache/ibatis/ibator/api/dom/java/
ibator-core/src/main/java/org...
Author: jgbutler
Date: Sun Feb 28 23:55:42 2010
New Revision: 917330
URL: http://svn.apache.org/viewvc?rev=917330&view=rev
Log:
[Ibator] More doc updates and some maven plugin enhancements
Removed:
ibatis/java/ibator/trunk/core/ibator-core/doc/html/reference/attributes.html
Modified:
ibatis/java/ibator/trunk/core/ibator-core/doc/html/menu.html
ibatis/java/ibator/trunk/core/ibator-core/doc/html/reference/pluggingIn.html
ibatis/java/ibator/trunk/core/ibator-core/doc/html/running/runningWithMaven.html
ibatis/java/ibator/trunk/core/ibator-core/doc/todo.txt
ibatis/java/ibator/trunk/core/ibator-core/src/main/java/org/apache/ibatis/ibator/api/dom/java/FullyQualifiedJavaType.java
ibatis/java/ibator/trunk/core/ibator-core/src/main/java/org/apache/ibatis/ibator/generator/ibatis3/Ibatis3FormattingUtilities.java
ibatis/java/ibator/trunk/core/ibator-maven-plugin/src/main/java/org/apache/ibatis/ibator/maven/IbatorMojo.java
Modified: ibatis/java/ibator/trunk/core/ibator-core/doc/html/menu.html
URL: http://svn.apache.org/viewvc/ibatis/java/ibator/trunk/core/ibator-core/doc/html/menu.html?rev=917330&r1=917329&r2=917330&view=diff
==============================================================================
--- ibatis/java/ibator/trunk/core/ibator-core/doc/html/menu.html (original)
+++ ibatis/java/ibator/trunk/core/ibator-core/doc/html/menu.html Sun Feb 28 23:55:42 2010
@@ -56,7 +56,6 @@
<a href="reference/building.html" target="mainFrame">Building Ibator from Source</a><br/>
<a href="reference/extending.html" target="mainFrame">Extending Ibator</a><br/>
<a href="reference/pluggingIn.html" target="mainFrame">Implementing Ibator Plugins</a><br/>
- <a href="reference/attributes.html" target="mainFrame">Introspected Table Attributes</a><br/>
<a href="reference/logging.html" target="mainFrame">Logging Information</a><br/>
<a href="philosophy.html" target="mainFrame">Design Philosophy</a><br/>
<a href="license.html" target="mainFrame">Licensing Information</a><br/>
Modified: ibatis/java/ibator/trunk/core/ibator-core/doc/html/reference/pluggingIn.html
URL: http://svn.apache.org/viewvc/ibatis/java/ibator/trunk/core/ibator-core/doc/html/reference/pluggingIn.html?rev=917330&r1=917329&r2=917330&view=diff
==============================================================================
--- ibatis/java/ibator/trunk/core/ibator-core/doc/html/reference/pluggingIn.html (original)
+++ ibatis/java/ibator/trunk/core/ibator-core/doc/html/reference/pluggingIn.html Sun Feb 28 23:55:42 2010
@@ -30,7 +30,7 @@
different types of tasks that can be accomplished with Ibator plugins. Source
code for the plugins is available with the Ibator downloads, or can be viewed
online
-<a target="_blank" href="http://svn.apache.org/repos/asf/ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/plugins/">
+<a target="_blank" href="http://svn.apache.org/repos/asf/ibatis/java/ibator/trunk/core/ibator-core/src/main/java/org/apache/ibatis/ibator/plugins/">
here</a>.</p>
<h2>Plugin Lifecycle</h2>
Modified: ibatis/java/ibator/trunk/core/ibator-core/doc/html/running/runningWithMaven.html
URL: http://svn.apache.org/viewvc/ibatis/java/ibator/trunk/core/ibator-core/doc/html/running/runningWithMaven.html?rev=917330&r1=917329&r2=917330&view=diff
==============================================================================
--- ibatis/java/ibator/trunk/core/ibator-core/doc/html/running/runningWithMaven.html (original)
+++ ibatis/java/ibator/trunk/core/ibator-core/doc/html/running/runningWithMaven.html Sun Feb 28 23:55:42 2010
@@ -43,9 +43,226 @@
<p>Of course, things are never that easy! </p>
+<h2>Maven Goal and Execution</h2>
+<p>The Ibator Maven plugin includes one goal:</p>
+<ul>
+ <li><code>ibator:generate</code></li>
+</ul>
+<p>The goal is not automatically executed by Maven. It can be executed in two
+ways.</p>
+<p>The goal can be executed from the command line with the command:</p>
+<ul>
+ <li><code>mvn ibator:generate</code></li>
+</ul>
+<p>You can pass parameters to the goal with standard Maven command line properties.
+For example:</p>
+<ul>
+ <li><code>mvn -Dibator.overwrite=true ibator:generate</code></li>
+</ul>
+<p>This will run Ibator and instruct Ibator to overwrite any existing Java files
+it may find.</p>
+<p>In a continuous build environment, you may want to automatically execute
+Ibator as a part of a Maven build. This can be accomplished by configuring
+the goal to execute automatically. An example of this is shown below:</p>
+<pre>
+ <project ...>
+ ...
+ <build>
+ ...
+ <plugins>
+ ...
+ <plugin>
+ <groupId>org.apache.ibatis.ibator</groupId>
+ <artifactId>ibator-maven-plugin</artifactId>
+ <version>1.2.2</version>
+ <executions>
+ <execution>
+ <id>Generate iBATIS Artifacts</id>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ ...
+ </plugins>
+ ...
+ </build>
+ ...
+ </project>
+
+</pre>
+<p>The Ibator plugin is bound to the <code>generate-sources</code> phase of a
+Maven build, so it will execute before the complie step. Also note that
+Ibator generates both Java source files and XML resources. The Ibator goal
+will bind both generated Java files and XML resources to the build and they
+will both be included in any JAR generated by the build.</p>
+
+<h2>Ibator Configuration Properties</h2>
+<p>Any property specified in the POM will be passed into the Ibator configuration
+file and may be used in the normal way. For example:</p>
+<pre>
+ <project ...>
+ ...
+ <properties>
+ <dao.target.dir>src/main/java</dao.target.dir>
+ </properties>
+ ...
+ <build>
+ ...
+ <plugins>
+ ...
+ <plugin>
+ <groupId>org.apache.ibatis.ibator</groupId>
+ <artifactId>ibator-maven-plugin</artifactId>
+ <version>1.2.2</version>
+ <executions>
+ <execution>
+ <id>Generate iBATIS Artifacts</id>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ ...
+ </plugins>
+ ...
+ </build>
+ ...
+ </project>
+
+</pre>
+<p>In this case, the property may be accessed in the Ibator configuration file with the
+syntax <code>${dao.target.dir}</code>.
+
+<h2>Parameter Reference</h2>
+<p>All parameters are optional and have suitable defaults.</p>
+<table cellspacing="0" cellpadding="5" border="1">
+ <tr>
+ <th>Parameter</th>
+ <th>Expression</th>
+ <th>Type</th>
+ <th>Comments</th>
+ <tr>
+ <tr>
+ <td valign="top">configurationFile</td>
+ <td valign="top">${ibator.configurationFile}</td>
+ <td valign="top">java.io.File</td>
+ <td valign="top">The location of the Ibator configuration file.
+ <p>Default value:</p>
+ ${basedir}/src/main/resources/ibatorConfig.xml
+ </td>
+ </tr>
+ <tr>
+ <td valign="top">contexts</td>
+ <td valign="top">${ibator.contexts}</td>
+ <td valign="top">java.lang.String</td>
+ <td valign="top">A comma delimited list of contexts to use in the current run of
+ Ibator. Any id specified in the list must exactly match the value of the id
+ attribute of an <ibatorContext> configuration element.
+ Only ids specified in this list will be active for this run of Ibator.
+ If this parameter is not specified, then all contexts will be active.
+ </td>
+ </tr>
+ <tr>
+ <td valign="top">jdbcDriver</td>
+ <td valign="top">${ibator.jdbcDriver}</td>
+ <td valign="top">java.lang.String</td>
+ <td valign="top">If you specify a <code>sqlScript</code>, then this is the
+ fully qualified JDBC driver class name to use when connecting to the
+ database.
+ </td>
+ </tr>
+ <tr>
+ <td valign="top">jdbcPassword</td>
+ <td valign="top">${ibator.jdbcPassword}</td>
+ <td valign="top">java.lang.String</td>
+ <td valign="top">If you specify a <code>sqlScript</code>, then this is the
+ password to use when connecting to the database.
+ </td>
+ </tr>
+ <tr>
+ <td valign="top">jdbcURL</td>
+ <td valign="top">${ibator.jdbcURL}</td>
+ <td valign="top">java.lang.String</td>
+ <td valign="top">If you specify a <code>sqlScript</code>, then this is the
+ JDBC URL to use when connecting to the database.
+ </td>
+ </tr>
+ <tr>
+ <td valign="top">jdbcUserId</td>
+ <td valign="top">${ibator.jdbcUserId}</td>
+ <td valign="top">java.lang.String</td>
+ <td valign="top">If you specify a <code>sqlScript</code>, then this is the
+ JDBC user ID to use when connecting to the database.
+ </td>
+ </tr>
+ <tr>
+ <td valign="top">outputDirectory</td>
+ <td valign="top">${ibator.outputDirectory}</td>
+ <td valign="top">java.io.File</td>
+ <td valign="top">The directory where files generated by Ibator will be placed.
+ This directory is used whenever a <code>targetProject</code> in the Ibator
+ configuration file is set to the special value "MAVEN" (case sensitive).
+ <p>Default value:</p>
+ ${project.build.directory}/generated-sources/ibator
+ </td>
+ </tr>
+ <tr>
+ <td valign="top">overwrite</td>
+ <td valign="top">${ibator.overwrite}</td>
+ <td valign="top">boolean</td>
+ <td valign="top">If true, then existing Java files will be overwritten if an
+ existing Java file if found with the same name as a generated file. If not
+ specified, and a Java file already exists with the same name as a generated
+ file, then Ibator will write the newly generated Java file to the proper
+ directory with a unique name (e.g. MyClass.java.1, MyClass.java.2, etc.).
+ <b>Important: Ibator will always merge and overwrite XML files.</b>
+ <p>Default value:</p>
+ false
+ </td>
+ </tr>
+ <tr>
+ <td valign="top">sqlScript</td>
+ <td valign="top">${ibator.sqlScript}</td>
+ <td valign="top">java.io.File</td>
+ <td valign="top">Location of a SQL script file to run before generating code.
+ If null, then no script will be run. If not null, then <code>jdbcDriver</code>,
+ <code>jdbcURL</code> must be supplied also. In addition,
+ <code>jdbcUserId<code> and <code>jdbcPassword</code> may be supplied if
+ the database requires authentication.
+ </td>
+ </tr>
+ <tr>
+ <td valign="top">tableNames</td>
+ <td valign="top">${ibator.tableNames}</td>
+ <td valign="top">java.lang.String</td>
+ <td valign="top">If specified, then this is a comma delimited list of tables to
+ use in the current run of Ibator. Any table specified in the list must exactly
+ match the fully qualified table name specified in a <table> configuration
+ element. Only tables specified in this list will be active for this run of
+ Ibator. If this argument is not specified, then all tables will be active.
+ Specify table names as:
+ <p><code>table<br/>
+ schema.table<br/>
+ catalog..table<br/>
+ etc.</code></p>
+ </td>
+ </tr>
+ <tr>
+ <td valign="top">verbose</td>
+ <td valign="top">${ibator.verbose}</td>
+ <td valign="top">boolean</td>
+ <td valign="top">If true, then Ibator will write progress messages to the
+ build log.
+ </td>
+ </tr>
+</table>
+
<h2>Interpretation of targetProject</h2>
<p>The <code>targetProject</code> attribute of the generator configurations is interpreted
-somewhat differently when running with Maven. If set to the special value "MAVEN" (case
+differently when running with Maven. If set to the special value "MAVEN" (case
sensitive), then <code>targetProject</code> will be set to the plugin's output directory,
and that directory will be created if it doesn't already exist. If not set to "MAVEN", then
<code>targetProject</code> will be interpreted as normal by Ibator - it must be set
Modified: ibatis/java/ibator/trunk/core/ibator-core/doc/todo.txt
URL: http://svn.apache.org/viewvc/ibatis/java/ibator/trunk/core/ibator-core/doc/todo.txt?rev=917330&r1=917329&r2=917330&view=diff
==============================================================================
--- ibatis/java/ibator/trunk/core/ibator-core/doc/todo.txt (original)
+++ ibatis/java/ibator/trunk/core/ibator-core/doc/todo.txt Sun Feb 28 23:55:42 2010
@@ -1,25 +1,16 @@
Core:
- 1.2.2
-
- 1. Add a way to override default types in the JavaTypeResolver
- 2. Document change to JavaTypeResolver interface in release notes
- 3. Document attributes
- 4. <tableSet> - to allow specification of common attributes for a set of
- tables
-
-
Future
1. Write page explaining how to use the GENERIC DAOs
-
2. Change the base API to allow specifying a connection at
runtime, rather than requiring a connection in the
XML config.
-
3. Relationships?
-
4. Java merger with ANTLR?
+ 5. Add a way to override default types in the JavaTypeResolver
+ 6. <tableSet> - to allow specification of common attributes for a set of
+ tables
Eclipse:
Modified: ibatis/java/ibator/trunk/core/ibator-core/src/main/java/org/apache/ibatis/ibator/api/dom/java/FullyQualifiedJavaType.java
URL: http://svn.apache.org/viewvc/ibatis/java/ibator/trunk/core/ibator-core/src/main/java/org/apache/ibatis/ibator/api/dom/java/FullyQualifiedJavaType.java?rev=917330&r1=917329&r2=917330&view=diff
==============================================================================
--- ibatis/java/ibator/trunk/core/ibator-core/src/main/java/org/apache/ibatis/ibator/api/dom/java/FullyQualifiedJavaType.java (original)
+++ ibatis/java/ibator/trunk/core/ibator-core/src/main/java/org/apache/ibatis/ibator/api/dom/java/FullyQualifiedJavaType.java Sun Feb 28 23:55:42 2010
@@ -58,7 +58,7 @@
* Use this constructor to construct a generic type with the specified
* type parameters
*
- * @param fullyQualifiedName
+ * @param fullTypeSpecification
*/
public FullyQualifiedJavaType(String fullTypeSpecification) {
super();
Modified: ibatis/java/ibator/trunk/core/ibator-core/src/main/java/org/apache/ibatis/ibator/generator/ibatis3/Ibatis3FormattingUtilities.java
URL: http://svn.apache.org/viewvc/ibatis/java/ibator/trunk/core/ibator-core/src/main/java/org/apache/ibatis/ibator/generator/ibatis3/Ibatis3FormattingUtilities.java?rev=917330&r1=917329&r2=917330&view=diff
==============================================================================
--- ibatis/java/ibator/trunk/core/ibator-core/src/main/java/org/apache/ibatis/ibator/generator/ibatis3/Ibatis3FormattingUtilities.java (original)
+++ ibatis/java/ibator/trunk/core/ibator-core/src/main/java/org/apache/ibatis/ibator/generator/ibatis3/Ibatis3FormattingUtilities.java Sun Feb 28 23:55:42 2010
@@ -164,21 +164,7 @@
}
public static String escapeStringForIbatis3(String s) {
- // TODO - not sure what to do here
+ // nothing to do for iBATIS3 so far
return s;
-// StringTokenizer st = new StringTokenizer(s, "$#", true); //$NON-NLS-1$
-// StringBuilder sb = new StringBuilder();
-// while (st.hasMoreTokens()) {
-// String token = st.nextToken();
-// if ("$".equals(token)) { //$NON-NLS-1$
-// sb.append("$$"); //$NON-NLS-1$
-// } else if ("#".equals(token)) { //$NON-NLS-1$
-// sb.append("##"); //$NON-NLS-1$
-// } else {
-// sb.append(token);
-// }
-// }
-//
-// return sb.toString();
}
}
Modified: ibatis/java/ibator/trunk/core/ibator-maven-plugin/src/main/java/org/apache/ibatis/ibator/maven/IbatorMojo.java
URL: http://svn.apache.org/viewvc/ibatis/java/ibator/trunk/core/ibator-maven-plugin/src/main/java/org/apache/ibatis/ibator/maven/IbatorMojo.java?rev=917330&r1=917329&r2=917330&view=diff
==============================================================================
--- ibatis/java/ibator/trunk/core/ibator-maven-plugin/src/main/java/org/apache/ibatis/ibator/maven/IbatorMojo.java (original)
+++ ibatis/java/ibator/trunk/core/ibator-maven-plugin/src/main/java/org/apache/ibatis/ibator/maven/IbatorMojo.java Sun Feb 28 23:55:42 2010
@@ -22,6 +22,7 @@
import java.util.HashSet;
import java.util.List;
import java.util.Set;
+import java.util.StringTokenizer;
import org.apache.ibatis.ibator.api.Ibator;
import org.apache.ibatis.ibator.api.ShellCallback;
@@ -29,6 +30,7 @@
import org.apache.ibatis.ibator.config.xml.IbatorConfigurationParser;
import org.apache.ibatis.ibator.exception.InvalidConfigurationException;
import org.apache.ibatis.ibator.exception.XMLParserException;
+import org.apache.ibatis.ibator.internal.util.StringUtility;
import org.apache.ibatis.ibator.internal.util.messages.Messages;
import org.apache.maven.model.Resource;
import org.apache.maven.plugin.AbstractMojo;
@@ -84,8 +86,8 @@
/**
* Location of a SQL script file to run before generating code.
* If null, then no script will be run. If not null,
- * then jdbc.driver, jdbc.url must be supplies also,
- * and jdbc.user.id and jdbc.password may be supplied.
+ * then jdbcDriver, jdbcURL must be supplied also,
+ * and jdbcUserId and jdbcPassword may be supplied.
*
* @parameter expression="${ibator.sqlScript}"
*/
@@ -119,6 +121,20 @@
*/
private String jdbcPassword;
+ /**
+ * Comma delimited list of table names to generate
+ *
+ * @parameter expression="${ibator.tableNames}"
+ */
+ private String tableNames;
+
+ /**
+ * Comma delimited list of contexts to generate
+ *
+ * @parameter expression="${ibator.contexts}"
+ */
+ private String contexts;
+
public void execute() throws MojoExecutionException {
if (configurationFile == null) {
throw new MojoExecutionException(Messages.getString("RuntimeError.0")); //$NON-NLS-1$
@@ -134,29 +150,27 @@
runScriptIfNecessary();
Set<String> fullyqualifiedTables = new HashSet<String>();
- // TODO...
-// if (StringUtility.stringHasValue(fullyQualifiedTableNames)) {
-// StringTokenizer st = new StringTokenizer(fullyQualifiedTableNames,
-// ","); //$NON-NLS-1$
-// while (st.hasMoreTokens()) {
-// String s = st.nextToken().trim();
-// if (s.length() > 0) {
-// fullyqualifiedTables.add(s);
-// }
-// }
-// }
-
- Set<String> contexts = new HashSet<String>();
- // TODO...
-// if (StringUtility.stringHasValue(contextIds)) {
-// StringTokenizer st = new StringTokenizer(contextIds, ","); //$NON-NLS-1$
-// while (st.hasMoreTokens()) {
-// String s = st.nextToken().trim();
-// if (s.length() > 0) {
-// contexts.add(s);
-// }
-// }
-// }
+ if (StringUtility.stringHasValue(tableNames)) {
+ StringTokenizer st = new StringTokenizer(tableNames,
+ ","); //$NON-NLS-1$
+ while (st.hasMoreTokens()) {
+ String s = st.nextToken().trim();
+ if (s.length() > 0) {
+ fullyqualifiedTables.add(s);
+ }
+ }
+ }
+
+ Set<String> contextsToRun = new HashSet<String>();
+ if (StringUtility.stringHasValue(contexts)) {
+ StringTokenizer st = new StringTokenizer(contexts, ","); //$NON-NLS-1$
+ while (st.hasMoreTokens()) {
+ String s = st.nextToken().trim();
+ if (s.length() > 0) {
+ contextsToRun.add(s);
+ }
+ }
+ }
try {
IbatorConfigurationParser cp = new IbatorConfigurationParser(project.getProperties(), warnings);
@@ -167,7 +181,7 @@
Ibator ibator = new Ibator(config, callback, warnings);
- ibator.generate(new MavenProgressCallback(getLog(), verbose), contexts,
+ ibator.generate(new MavenProgressCallback(getLog(), verbose), contextsToRun,
fullyqualifiedTables);
} catch (XMLParserException e) {