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 2009/02/20 00:07:38 UTC
svn commit: r746048 - in /ibatis/trunk/java/tools/ibator/core: build/
devlib/ doc/ htmldoc/ htmldoc/reference/ src/org/apache/ibatis/ibator/api/
src/org/apache/ibatis/ibator/config/ src/org/apache/ibatis/ibator/internal/
src/org/apache/ibatis/ibator/in...
Author: jgbutler
Date: Thu Feb 19 23:07:37 2009
New Revision: 746048
URL: http://svn.apache.org/viewvc?rev=746048&view=rev
Log:
[Ibator] Added some additional command line arguments and logging
Added:
ibatis/trunk/java/tools/ibator/core/devlib/log4j-1.2.15.jar (with props)
ibatis/trunk/java/tools/ibator/core/htmldoc/reference/logging.html
ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/api/VerboseProgressCallback.java
ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/logging/
ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/logging/JdkLoggingImpl.java
ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/logging/Log.java
ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/logging/Log4jImpl.java
ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/logging/LogFactory.java
Modified:
ibatis/trunk/java/tools/ibator/core/build/version.properties
ibatis/trunk/java/tools/ibator/core/doc/ReleaseNotes.txt
ibatis/trunk/java/tools/ibator/core/htmldoc/menu.html
ibatis/trunk/java/tools/ibator/core/htmldoc/reference/intro.html
ibatis/trunk/java/tools/ibator/core/htmldoc/running.html
ibatis/trunk/java/tools/ibator/core/htmldoc/whatsNew.html
ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/api/IbatorRunner.java
ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/config/IbatorContext.java
ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/IbatorObjectFactory.java
ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/NullProgressCallback.java
ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/db/DatabaseIntrospector.java
ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/types/JavaTypeResolverDefaultImpl.java
ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/types/JdbcTypeNameTranslator.java
ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/util/messages/messages.properties
Modified: ibatis/trunk/java/tools/ibator/core/build/version.properties
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/build/version.properties?rev=746048&r1=746047&r2=746048&view=diff
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/build/version.properties (original)
+++ ibatis/trunk/java/tools/ibator/core/build/version.properties Thu Feb 19 23:07:37 2009
@@ -1,4 +1,4 @@
#Ibator build version info
-#Wed Feb 04 16:05:31 CST 2009
+#Thu Feb 19 17:02:37 CST 2009
version=1.2.2
-buildNum=707
+buildNum=711
Added: ibatis/trunk/java/tools/ibator/core/devlib/log4j-1.2.15.jar
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/devlib/log4j-1.2.15.jar?rev=746048&view=auto
==============================================================================
Binary file - no diff available.
Propchange: ibatis/trunk/java/tools/ibator/core/devlib/log4j-1.2.15.jar
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Modified: ibatis/trunk/java/tools/ibator/core/doc/ReleaseNotes.txt
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/doc/ReleaseNotes.txt?rev=746048&r1=746047&r2=746048&view=diff
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/doc/ReleaseNotes.txt (original)
+++ ibatis/trunk/java/tools/ibator/core/doc/ReleaseNotes.txt Thu Feb 19 23:07:37 2009
@@ -11,6 +11,8 @@
2. IBATIS-571 - Added "autoDelimitKeywords" support to <ibatorContext>
3. IBATIS-577 - Define SQL fragments for column lists. Thanks to Iwao
AVE! for the idea and the initial patch
+4. Added some additional command line arguments
+5. Added logging
-------------------------------------------------------------------------------
Version 1.2.1:
Modified: ibatis/trunk/java/tools/ibator/core/htmldoc/menu.html
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/htmldoc/menu.html?rev=746048&r1=746047&r2=746048&view=diff
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/htmldoc/menu.html (original)
+++ ibatis/trunk/java/tools/ibator/core/htmldoc/menu.html Thu Feb 19 23:07:37 2009
@@ -51,6 +51,7 @@
<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/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/>
</p>
Modified: ibatis/trunk/java/tools/ibator/core/htmldoc/reference/intro.html
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/htmldoc/reference/intro.html?rev=746048&r1=746047&r2=746048&view=diff
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/htmldoc/reference/intro.html (original)
+++ ibatis/trunk/java/tools/ibator/core/htmldoc/reference/intro.html Thu Feb 19 23:07:37 2009
@@ -23,6 +23,7 @@
<li><a href="building.html">Building Ibator from Source</a></li>
<li><a href="extending.html">Extending Ibator</a></li>
<li><a href="pluggingIn.html">Implementing Ibator Plugins</a></li>
+ <li><a href="logging.html">Logging Information</a></li>
</ul>
</body>
</html>
Added: ibatis/trunk/java/tools/ibator/core/htmldoc/reference/logging.html
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/htmldoc/reference/logging.html?rev=746048&view=auto
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/htmldoc/reference/logging.html (added)
+++ ibatis/trunk/java/tools/ibator/core/htmldoc/reference/logging.html Thu Feb 19 23:07:37 2009
@@ -0,0 +1,114 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3c.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+ <title>Logging Information</title>
+ <link type="text/css" rel="stylesheet" href="../ibator.css"/>
+</head>
+<body>
+
+<div class="menuNav">
+ <p>
+ <a href="../index.html" target="_top">Show Menu</a>
+ <a href="logging.html" target="_top">Hide Menu</a>
+ </p>
+</div>
+
+<h1>Logging Information</h1>
+<p>Ibator reports logging information in several different ways:</p>
+<ul>
+ <li>Ibator may generate and display warning messages every time it is run. These
+ messages are meant to inform the user of significant events that may, or may not,
+ require attention. Examples are files being overwritten, non-fatal configuration errors, etc.
+ Warnings are always displayed - regardless of configuration or command line options.</li>
+ <li>Ibator generates and may, or may not, display progress messages every time it is run.
+ These messages are meant to inform to user of progress in code generation. These messages
+ are not displayed by default, but may be enabled by specifying the <code>-verbose</code>
+ command line argument. Or, if you are running Ibator with the built in Ant task, these
+ messages may be enabled by setting the <code>verbose</code> attribute to <code>true</code>,
+ and then running Ant in verbose mode.</li>
+ <li>Lastly, Ibator will generate tracing (logging) messages for detailed debugging.
+ This page explains how to enable these statements.</li>
+</ul>
+
+<p>In general, Ibator will not repeat messages. So if Ibator generates a warning,
+that warning is typically not also logged. In some situations it may be useful
+to enable logging as well as asking Ibator to be verbose with progress messages.
+This may generate a substantial output, but it will also give a very complete
+picture of what's happening internally during the Ibator run.</p>
+
+<p>Ibator will use Apache Log4J logging if Log4J is in the runtime classpath.
+See <a href="http://logging.apache.org/log4j/">http://logging.apache.org/log4j/</a>
+for more information about Log4J. If Log4J is not in the runtime classpath,
+Ibator will use standard Java logging.</p>
+<p>If for any reason you prefer to force the use of standard Java logging, even
+if Log4J is in the runtime classpath, you may specify the <code>-forceJavaLogging</code>
+command line argument, or specify the following line of code when running
+Ibator from Java:</p>
+<p><code>org.apache.ibatis.ibator.logging.LogFactory.selectJavaLogging();</code></p>
+
+<h2>Configuring Log4J Logging</h2>
+<p>The following is a sample Log4J configuration file:</p>
+<pre>
+# Set root logger
+log4j.rootLogger=INFO, A1
+
+# A1 is set to be a ConsoleAppender.
+log4j.appender.A1=org.apache.log4j.ConsoleAppender
+log4j.appender.A1.layout=org.apache.log4j.PatternLayout
+log4j.appender.A1.layout.ConversionPattern=%-4r %-5p %c - %m%n
+
+# Ibator logging configuration...
+log4j.logger.org.apache.ibatis.ibator=DEBUG
+</pre>
+<p>This file will instruct Log4J to write all Ibator debug messages
+to the console. To use this file:</p>
+<ol>
+ <li>Create a file called <code>log4j.properties</code> in the
+ root of your runtime classpath</li>
+ <li>Copy the above entries into the new file</li>
+ <li>Run Ibator with the Log4J JAR file also in the runtime
+ classpath.</li>
+</ol>
+<p>You should see many log messages in the console.</p>
+<p>You may also configure Log4J in any of the other supported
+methods if you prefer.</p>
+
+<h2>Configuring Java Logging</h2>
+<p>The following is a sample Java logging configuration file:</p>
+<pre>
+# Specify the handlers to create in the root logger
+# (all loggers are children of the root logger)
+handlers = java.util.logging.ConsoleHandler
+
+# Set the default logging level for the root logger
+.level = INFO
+
+# Set the default logging level for new ConsoleHandler instances
+java.util.logging.ConsoleHandler.level = ALL
+
+# Set the default formatter for new ConsoleHandler instances
+java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
+
+# Set the default logging level for the logger named org.apache.ibatis.ibator
+org.apache.ibatis.ibator.level = FINE
+</pre>
+<p>This file will instruct Java to write all Ibator debug messages
+to the console. To use this file:</p>
+<ol>
+ <li>Create a file called <code>logging.properties</code> (or any
+ file name you prefer). The file can exist anywhere in
+ the file system (for example, in a <code>\temp</code> directory).</li>
+ <li>Copy the above entries into the new file</li>
+ <li>Run Ibator with this VM argument:<br/>
+ <code>-Djava.util.logging.config.file=\temp\logging.properties</code>
+ (specify whatever actual file name and directory you used)
+ </li>
+</ol>
+<p>You should see many log messages in the console.</p>
+<p>You may also configure Java logging in any of the other supported
+methods if you prefer.</p>
+
+</body>
+</html>
Modified: ibatis/trunk/java/tools/ibator/core/htmldoc/running.html
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/htmldoc/running.html?rev=746048&r1=746047&r2=746048&view=diff
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/htmldoc/running.html (original)
+++ ibatis/trunk/java/tools/ibator/core/htmldoc/running.html Thu Feb 19 23:07:37 2009
@@ -53,20 +53,29 @@
<th>Value</th>
</tr>
<tr>
- <td>-configfile (required)</td>
+ <td>-configfile <i>file_name</i> <br/>(required)</td>
<td>Specifies the name of the configuration file.</td>
</tr>
<tr>
<td>-overwrite (optional)</td>
<td>If specified, then existing Java files will be overwritten if an existing Java
- file if found with the same nae as a generated file. If not specified, and a
+ 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></td>
</tr>
<tr>
- <td>-contextids (optional)</td>
+ <td>-verbose (optional)</td>
+ <td>If specified, then Ibator will write progress messages to the console.</td>
+</tr>
+<tr>
+ <td>-forceJavaLogging (optional)</td>
+ <td>If specified, then Ibator will use Java logging rather than Log4J even if
+ Log4J is in the runtime classpath.</td>
+</tr>
+<tr>
+ <td>-contextids <i>context1,context2,...</i><br/>(optional)</td>
<td>If specified, then this is 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 <code>id</code> attribute of an
@@ -75,7 +84,7 @@
is not specified, then all contexts will be active.</td>
</tr>
<tr>
- <td>-tables (optional)</td>
+ <td>-tables <i>table1, table2,...</i><br/>(optional)</td>
<td>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
Modified: ibatis/trunk/java/tools/ibator/core/htmldoc/whatsNew.html
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/htmldoc/whatsNew.html?rev=746048&r1=746047&r2=746048&view=diff
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/htmldoc/whatsNew.html (original)
+++ ibatis/trunk/java/tools/ibator/core/htmldoc/whatsNew.html Thu Feb 19 23:07:37 2009
@@ -33,12 +33,18 @@
for more information.</li>
<li>IBATIS-571 - Added support for automatically delimiting SQL keywords
if they are used as column names in tables. See the
- <a href="configreference/ibatorContext.html"><ibatorContext></a> page for detailed
+ <a href="configreference/ibatorContext.html"><ibatorContext></a> page
for more information.</li>
<li>IBATIS-577 - Define SQL fragments for column lists to improve
reusability of generated code. Thanks to Iwao AVE! for the idea
and the initial patch.
</li>
+ <li>Added new <code>-verbose</code> command line argument. See the
+ <a href="running.html">Running Ibator</a> page
+ for more information.</li>
+ <li>Added logging statements for use in debug. See the
+ <a href="reference/logging.html">Logging</a> page
+ for more information.</li>
</ul>
<h2>Version 1.2.1</h2>
Modified: ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/api/IbatorRunner.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/api/IbatorRunner.java?rev=746048&r1=746047&r2=746048&view=diff
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/api/IbatorRunner.java (original)
+++ ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/api/IbatorRunner.java Thu Feb 19 23:07:37 2009
@@ -32,9 +32,10 @@
import org.apache.ibatis.ibator.exception.XMLParserException;
import org.apache.ibatis.ibator.internal.DefaultShellCallback;
import org.apache.ibatis.ibator.internal.util.messages.Messages;
+import org.apache.ibatis.ibator.logging.LogFactory;
/**
- * This class allows ibator to be run from the command line.
+ * This class allows Ibator to be run from the command line.
*
* @author Jeff Butler
*/
@@ -43,6 +44,8 @@
private static final String OVERWRITE = "-overwrite"; //$NON-NLS-1$
private static final String CONTEXT_IDS = "-contextids"; //$NON-NLS-1$
private static final String TABLES = "-tables"; //$NON-NLS-1$
+ private static final String VERBOSE = "-verbose"; //$NON-NLS-1$
+ private static final String FORCE_JAVA_LOGGING = "-forceJavaLogging"; //$NON-NLS-1$
public static void main(String[] args) {
if (args.length == 0) {
@@ -94,11 +97,14 @@
warnings);
IbatorConfiguration config = cp.parseIbatorConfiguration(configurationFile);
- DefaultShellCallback callback = new DefaultShellCallback(arguments.containsKey(OVERWRITE));
+ DefaultShellCallback shellCallback = new DefaultShellCallback(arguments.containsKey(OVERWRITE));
- Ibator ibator = new Ibator(config, callback, warnings);
+ Ibator ibator = new Ibator(config, shellCallback, warnings);
- ibator.generate(null, contexts, fullyqualifiedTables);
+ ProgressCallback progressCallback =
+ arguments.containsKey(VERBOSE) ? new VerboseProgressCallback() : null;
+
+ ibator.generate(progressCallback, contexts, fullyqualifiedTables);
} catch (XMLParserException e) {
writeLine(Messages.getString("Progress.3")); //$NON-NLS-1$
@@ -165,6 +171,10 @@
i++;
} else if (OVERWRITE.equalsIgnoreCase(args[i])) {
arguments.put(OVERWRITE, "Y"); //$NON-NLS-1$
+ } else if (VERBOSE.equalsIgnoreCase(args[i])) {
+ arguments.put(VERBOSE, "Y"); //$NON-NLS-1$
+ } else if (FORCE_JAVA_LOGGING.equalsIgnoreCase(args[i])) {
+ LogFactory.selectJavaLogging();
} else if (CONTEXT_IDS.equalsIgnoreCase(args[i])) {
if ((i + 1) < args.length) {
arguments.put(CONTEXT_IDS, args[i + 1]);
Added: ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/api/VerboseProgressCallback.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/api/VerboseProgressCallback.java?rev=746048&view=auto
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/api/VerboseProgressCallback.java (added)
+++ ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/api/VerboseProgressCallback.java Thu Feb 19 23:07:37 2009
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2009 The Apache Software Foundation
+ *
+ * Licensed 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.ibatis.ibator.api;
+
+import org.apache.ibatis.ibator.internal.NullProgressCallback;
+
+/**
+ * @author Jeff Butler
+ *
+ */
+public class VerboseProgressCallback extends NullProgressCallback {
+
+ /**
+ *
+ */
+ public VerboseProgressCallback() {
+ super();
+ }
+
+ @Override
+ public void startTask(String taskName) {
+ System.out.println(taskName);
+ }
+}
Modified: ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/config/IbatorContext.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/config/IbatorContext.java?rev=746048&r1=746047&r2=746048&view=diff
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/config/IbatorContext.java (original)
+++ ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/config/IbatorContext.java Thu Feb 19 23:07:37 2009
@@ -415,7 +415,7 @@
introspectedTables = new ArrayList<IntrospectedTable>();
JavaTypeResolver javaTypeResolver = IbatorObjectFactory
- .createJavaTypeResolver(IbatorContext.this, warnings);
+ .createJavaTypeResolver(this, warnings);
Connection connection = null;
@@ -424,7 +424,7 @@
connection = getConnection();
DatabaseIntrospector databaseIntrospector = new DatabaseIntrospector(
- IbatorContext.this, connection.getMetaData(), javaTypeResolver,
+ this, connection.getMetaData(), javaTypeResolver,
warnings);
for (TableConfiguration tc : tableConfigurations) {
@@ -481,7 +481,7 @@
pluginAggregator = new IbatorPluginAggregator();
for (IbatorPluginConfiguration ibatorPluginConfiguration : pluginConfigurations) {
IbatorPlugin plugin = IbatorObjectFactory.createIbatorPlugin(
- IbatorContext.this, ibatorPluginConfiguration);
+ this, ibatorPluginConfiguration);
if (plugin.validate(warnings)) {
pluginAggregator.addPlugin(plugin);
} else {
Modified: ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/IbatorObjectFactory.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/IbatorObjectFactory.java?rev=746048&r1=746047&r2=746048&view=diff
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/IbatorObjectFactory.java (original)
+++ ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/IbatorObjectFactory.java Thu Feb 19 23:07:37 2009
@@ -105,7 +105,7 @@
return answer;
}
- public static Object createInternalObject(String type) {
+ public static Class<?> internalClassForName(String type) throws ClassNotFoundException {
Class<?> clazz = null;
try {
@@ -115,12 +115,18 @@
// ignore - failsafe below
}
+ if (clazz == null) {
+ clazz = Class.forName(type);
+ }
+
+ return clazz;
+ }
+
+ public static Object createInternalObject(String type) {
Object answer;
try {
- if (clazz == null) {
- clazz = Class.forName(type);
- }
+ Class<?> clazz = internalClassForName(type);
answer = clazz.newInstance();
} catch (Exception e) {
Modified: ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/NullProgressCallback.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/NullProgressCallback.java?rev=746048&r1=746047&r2=746048&view=diff
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/NullProgressCallback.java (original)
+++ ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/NullProgressCallback.java Thu Feb 19 23:07:37 2009
@@ -19,7 +19,7 @@
/**
* This class implements a progress callback that does nothing. It is used when the
- * ibator client passes in a null for the ProgressCallback.
+ * Ibator client passes in a null for the ProgressCallback.
*
* @author Jeff Butler
*/
Modified: ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/db/DatabaseIntrospector.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/db/DatabaseIntrospector.java?rev=746048&r1=746047&r2=746048&view=diff
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/db/DatabaseIntrospector.java (original)
+++ ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/db/DatabaseIntrospector.java Thu Feb 19 23:07:37 2009
@@ -41,6 +41,8 @@
import org.apache.ibatis.ibator.internal.util.JavaBeansUtil;
import org.apache.ibatis.ibator.internal.util.StringUtility;
import org.apache.ibatis.ibator.internal.util.messages.Messages;
+import org.apache.ibatis.ibator.logging.Log;
+import org.apache.ibatis.ibator.logging.LogFactory;
/**
*
@@ -52,6 +54,7 @@
private JavaTypeResolver javaTypeResolver;
private List<String> warnings;
private IbatorContext ibatorContext;
+ private Log logger;
public DatabaseIntrospector(IbatorContext ibatorContext, DatabaseMetaData databaseMetaData,
JavaTypeResolver javaTypeResolver, List<String> warnings) {
@@ -60,6 +63,7 @@
this.databaseMetaData = databaseMetaData;
this.javaTypeResolver = javaTypeResolver;
this.warnings = warnings;
+ logger = LogFactory.getLog(getClass());
}
private void calculatePrimaryKey(FullyQualifiedTable table, IntrospectedTable introspectedTable) {
@@ -168,12 +172,16 @@
if (!introspectedTable.hasAnyColumns()) {
// add warning that the table has no columns, remove from the list
- warnings.add(Messages.getString("Warning.1", introspectedTable.getFullyQualifiedTable().toString())); //$NON-NLS-1$
+ String warning = Messages.getString("Warning.1", introspectedTable.getFullyQualifiedTable().toString()); //$NON-NLS-1$
+ warnings.add(warning);
+ logger.debug(warning);
iter.remove();
} else if (!introspectedTable.hasPrimaryKeyColumns()
&& !introspectedTable.hasBaseColumns()) {
// add warning that the table has only BLOB columns, remove from the list
- warnings.add(Messages.getString("Warning.18", introspectedTable.getFullyQualifiedTable().toString())); //$NON-NLS-1$
+ String warning = Messages.getString("Warning.18", introspectedTable.getFullyQualifiedTable().toString()); //$NON-NLS-1$
+ warnings.add(warning);
+ logger.debug(warning);
iter.remove();
} else {
// now make sure that all columns called out in the configuration
@@ -196,6 +204,11 @@
IntrospectedColumn introspectedColumn = tableColumns.next();
if (tc.isColumnIgnored(introspectedColumn.getActualColumnName())) {
tableColumns.remove();
+ if (logger.isDebugEnabled()) {
+ logger.debug(Messages.getString("Tracing.3", //$NON-NLS-1$
+ introspectedColumn.getActualColumnName(),
+ entry.getKey().toString()));
+ }
}
}
}
@@ -208,7 +221,7 @@
if (tc.getColumnRenamingRule() != null) {
pattern = Pattern.compile(tc.getColumnRenamingRule().getSearchString());
replaceString = tc.getColumnRenamingRule().getReplaceString();
- replaceString = replaceString == null ? "" : replaceString;//$NON-NLS-1$
+ replaceString = replaceString == null ? "" : replaceString; //$NON-NLS-1$
}
for (Map.Entry<ActualTableName, List<IntrospectedColumn>> entry : columns.entrySet()) {
@@ -251,9 +264,12 @@
if (warn) {
introspectedColumn.setFullyQualifiedJavaType(FullyQualifiedJavaType.getObjectInstance());
- warnings.add(Messages.getString("Warning.14", //$NON-NLS-1$
- entry.getKey().toString(),
- introspectedColumn.getActualColumnName()));
+ String warning = Messages.getString("Warning.14", //$NON-NLS-1$
+ entry.getKey().toString(),
+ introspectedColumn.getActualColumnName());
+
+ warnings.add(warning);
+ logger.debug(warning);
}
}
@@ -297,6 +313,12 @@
.getActualColumnName());
if (columnOverride != null) {
+ if (logger.isDebugEnabled()) {
+ logger.debug(Messages.getString("Tracing.4", //$NON-NLS-1$
+ introspectedColumn.getActualColumnName(),
+ entry.getKey().toString()));
+ }
+
if (StringUtility.stringHasValue(columnOverride.getJavaProperty())) {
introspectedColumn.setJavaProperty(columnOverride.getJavaProperty());
}
@@ -400,6 +422,11 @@
Map<ActualTableName, List<IntrospectedColumn>> answer = new HashMap<ActualTableName, List<IntrospectedColumn>>();
+ if (logger.isDebugEnabled()) {
+ String fullTableName = StringUtility.composeFullyQualifiedTableName(localCatalog, localSchema, localTableName, '.');
+ logger.debug(Messages.getString("Tracing.1", fullTableName)); //$NON-NLS-1$
+ }
+
ResultSet rs = databaseMetaData.getColumns(localCatalog, localSchema,
localTableName, null);
@@ -424,6 +451,13 @@
}
columns.add(introspectedColumn);
+
+ if (logger.isDebugEnabled()) {
+ logger.debug(Messages.getString("Tracing.2", //$NON-NLS-1$
+ introspectedColumn.getActualColumnName(),
+ Integer.toString(introspectedColumn.getJdbcType()),
+ atn.toString()));
+ }
}
closeResultSet(rs);
Modified: ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/types/JavaTypeResolverDefaultImpl.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/types/JavaTypeResolverDefaultImpl.java?rev=746048&r1=746047&r2=746048&view=diff
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/types/JavaTypeResolverDefaultImpl.java (original)
+++ ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/types/JavaTypeResolverDefaultImpl.java Thu Feb 19 23:07:37 2009
@@ -18,7 +18,9 @@
import java.math.BigDecimal;
import java.sql.Types;
import java.util.Date;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import java.util.Properties;
import org.apache.ibatis.ibator.api.IntrospectedColumn;
@@ -34,181 +36,95 @@
*/
public class JavaTypeResolverDefaultImpl implements JavaTypeResolver {
- protected List<String> warnings;
+ protected List<String> warnings;
- protected Properties properties;
+ protected Properties properties;
protected IbatorContext ibatorContext;
+
+ protected boolean forceBigDecimals;
+
+ protected Map<Integer, FullyQualifiedJavaType> typeMap;
- public JavaTypeResolverDefaultImpl() {
- super();
+ public JavaTypeResolverDefaultImpl() {
+ super();
properties = new Properties();
- }
+ typeMap = new HashMap<Integer, FullyQualifiedJavaType>();
+
+ typeMap.put(Types.ARRAY, new FullyQualifiedJavaType(Object.class.getName()));
+ typeMap.put(Types.BIGINT, new FullyQualifiedJavaType(Long.class.getName()));
+ typeMap.put(Types.BINARY, new FullyQualifiedJavaType("byte[]")); //$NON-NLS-1$
+ typeMap.put(Types.BIT, new FullyQualifiedJavaType(Boolean.class.getName()));
+ typeMap.put(Types.BLOB, new FullyQualifiedJavaType("byte[]")); //$NON-NLS-1$
+ typeMap.put(Types.BOOLEAN, new FullyQualifiedJavaType(Boolean.class.getName()));
+ typeMap.put(Types.CHAR, new FullyQualifiedJavaType(String.class.getName()));
+ typeMap.put(Types.CLOB, new FullyQualifiedJavaType(String.class.getName()));
+ typeMap.put(Types.DATALINK, new FullyQualifiedJavaType(Object.class.getName()));
+ typeMap.put(Types.DATE, new FullyQualifiedJavaType(Date.class.getName()));
+ typeMap.put(Types.DISTINCT, new FullyQualifiedJavaType(Object.class.getName()));
+ typeMap.put(Types.DOUBLE, new FullyQualifiedJavaType(Double.class.getName()));
+ typeMap.put(Types.FLOAT, new FullyQualifiedJavaType(Double.class.getName()));
+ typeMap.put(Types.INTEGER, new FullyQualifiedJavaType(Integer.class.getName()));
+ typeMap.put(Types.JAVA_OBJECT, new FullyQualifiedJavaType(Object.class.getName()));
+ typeMap.put(Types.LONGVARBINARY, new FullyQualifiedJavaType("byte[]")); //$NON-NLS-1$
+ typeMap.put(Types.LONGVARCHAR, new FullyQualifiedJavaType(String.class.getName()));
+ typeMap.put(Types.NULL, new FullyQualifiedJavaType(Object.class.getName()));
+ typeMap.put(Types.OTHER, new FullyQualifiedJavaType(Object.class.getName()));
+ typeMap.put(Types.REAL, new FullyQualifiedJavaType(Float.class.getName()));
+ typeMap.put(Types.REF, new FullyQualifiedJavaType(Object.class.getName()));
+ typeMap.put(Types.SMALLINT, new FullyQualifiedJavaType(Short.class.getName()));
+ typeMap.put(Types.STRUCT, new FullyQualifiedJavaType(Object.class.getName()));
+ typeMap.put(Types.TIME, new FullyQualifiedJavaType(Date.class.getName()));
+ typeMap.put(Types.TIMESTAMP, new FullyQualifiedJavaType(Date.class.getName()));
+ typeMap.put(Types.TINYINT, new FullyQualifiedJavaType(Byte.class.getName()));
+ typeMap.put(Types.VARBINARY, new FullyQualifiedJavaType("byte[]")); //$NON-NLS-1$
+ typeMap.put(Types.VARCHAR, new FullyQualifiedJavaType(String.class.getName()));
+ }
public void addConfigurationProperties(Properties properties) {
this.properties.putAll(properties);
+ forceBigDecimals = StringUtility.isTrue(properties
+ .getProperty(PropertyRegistry.TYPE_RESOLVER_FORCE_BIG_DECIMALS));
}
- /*
- * (non-Javadoc)
- * @see org.apache.ibatis.ibator.api.JavaTypeResolver#initializeResolvedJavaType(org.apache.ibatis.ibator.internal.db.ColumnDefinition)
- */
- public FullyQualifiedJavaType calculateJavaType(IntrospectedColumn introspectedColumn) {
- boolean forceBigDecimals = StringUtility.isTrue(properties
- .getProperty(PropertyRegistry.TYPE_RESOLVER_FORCE_BIG_DECIMALS));
+ /*
+ * (non-Javadoc)
+ * @see org.apache.ibatis.ibator.api.JavaTypeResolver#initializeResolvedJavaType(org.apache.ibatis.ibator.internal.db.ColumnDefinition)
+ */
+ public FullyQualifiedJavaType calculateJavaType(IntrospectedColumn introspectedColumn) {
FullyQualifiedJavaType answer;
- switch (introspectedColumn.getJdbcType()) {
- case Types.ARRAY:
- answer = new FullyQualifiedJavaType(Object.class.getName());
- break;
-
- case Types.BIGINT:
- answer = new FullyQualifiedJavaType(Long.class.getName());
- break;
-
- case Types.BINARY:
- answer = new FullyQualifiedJavaType("byte[]"); //$NON-NLS-1$
- break;
-
- case Types.BIT:
- answer = new FullyQualifiedJavaType(Boolean.class.getName());
- break;
-
- case Types.BLOB:
- answer = new FullyQualifiedJavaType("byte[]"); //$NON-NLS-1$
- break;
-
- case Types.BOOLEAN:
- answer = new FullyQualifiedJavaType(Boolean.class.getName());
- break;
-
- case Types.CHAR:
- answer = new FullyQualifiedJavaType(String.class.getName());
- break;
-
- case Types.CLOB:
- answer = new FullyQualifiedJavaType(String.class.getName());
- break;
-
- case Types.DATALINK:
- answer = new FullyQualifiedJavaType(Object.class.getName());
- break;
-
- case Types.DATE:
- answer = new FullyQualifiedJavaType(Date.class.getName());
- break;
-
- case Types.DECIMAL:
- if (introspectedColumn.getScale() > 0 || introspectedColumn.getLength() > 18 || forceBigDecimals) {
- answer = new FullyQualifiedJavaType(BigDecimal.class.getName());
- } else if (introspectedColumn.getLength() > 9) {
- answer = new FullyQualifiedJavaType(Long.class.getName());
- } else if (introspectedColumn.getLength() > 4) {
- answer = new FullyQualifiedJavaType(Integer.class.getName());
- } else {
- answer = new FullyQualifiedJavaType(Short.class.getName());
- }
- break;
-
- case Types.DISTINCT:
- answer = new FullyQualifiedJavaType(Object.class.getName());
- break;
-
- case Types.DOUBLE:
- answer = new FullyQualifiedJavaType(Double.class.getName());
- break;
-
- case Types.FLOAT:
- answer = new FullyQualifiedJavaType(Double.class.getName());
- break;
-
- case Types.INTEGER:
- answer = new FullyQualifiedJavaType(Integer.class.getName());
- break;
-
- case Types.JAVA_OBJECT:
- answer = new FullyQualifiedJavaType(Object.class.getName());
- break;
-
- case Types.LONGVARBINARY:
- answer = new FullyQualifiedJavaType("byte[]"); //$NON-NLS-1$
- break;
-
- case Types.LONGVARCHAR:
- answer = new FullyQualifiedJavaType(String.class.getName());
- break;
-
- case Types.NULL:
- answer = new FullyQualifiedJavaType(Object.class.getName());
- break;
-
- case Types.NUMERIC:
- if (introspectedColumn.getScale() > 0 || introspectedColumn.getLength() > 18 || forceBigDecimals) {
- answer = new FullyQualifiedJavaType(BigDecimal.class.getName());
- } else if (introspectedColumn.getLength() > 9) {
- answer = new FullyQualifiedJavaType(Long.class.getName());
- } else if (introspectedColumn.getLength() > 4) {
- answer = new FullyQualifiedJavaType(Integer.class.getName());
- } else {
- answer = new FullyQualifiedJavaType(Short.class.getName());
- }
- break;
-
- case Types.OTHER:
- answer = new FullyQualifiedJavaType(Object.class.getName());
- break;
-
- case Types.REAL:
- answer = new FullyQualifiedJavaType(Float.class.getName());
- break;
-
- case Types.REF:
- answer = new FullyQualifiedJavaType(Object.class.getName());
- break;
-
- case Types.SMALLINT:
- answer = new FullyQualifiedJavaType(Short.class.getName());
- break;
-
- case Types.STRUCT:
- answer = new FullyQualifiedJavaType(Object.class.getName());
- break;
-
- case Types.TIME:
- answer = new FullyQualifiedJavaType(Date.class.getName());
- break;
-
- case Types.TIMESTAMP:
- answer = new FullyQualifiedJavaType(Date.class.getName());
- break;
-
- case Types.TINYINT:
- answer = new FullyQualifiedJavaType(Byte.class.getName());
- break;
-
- case Types.VARBINARY:
- answer = new FullyQualifiedJavaType("byte[]"); //$NON-NLS-1$
- break;
-
- case Types.VARCHAR:
- answer = new FullyQualifiedJavaType(String.class.getName());
- break;
+ switch (introspectedColumn.getJdbcType()) {
+ case Types.DECIMAL:
+ case Types.NUMERIC:
+ answer = typeMap.get(introspectedColumn.getJdbcType());
+ if (answer == null) {
+ if (introspectedColumn.getScale() > 0 || introspectedColumn.getLength() > 18 || forceBigDecimals) {
+ answer = new FullyQualifiedJavaType(BigDecimal.class.getName());
+ } else if (introspectedColumn.getLength() > 9) {
+ answer = new FullyQualifiedJavaType(Long.class.getName());
+ } else if (introspectedColumn.getLength() > 4) {
+ answer = new FullyQualifiedJavaType(Integer.class.getName());
+ } else {
+ answer = new FullyQualifiedJavaType(Short.class.getName());
+ }
+ }
+ break;
- default:
- answer = null;
+ default:
+ answer = typeMap.get(introspectedColumn.getJdbcType());
break;
- }
+ }
return answer;
- }
+ }
- /* (non-Javadoc)
- * @see org.apache.ibatis.ibator.api.JavaTypeResolver#setWarnings(java.util.List)
- */
- public void setWarnings(List<String> warnings) {
- this.warnings = warnings;
- }
+ /* (non-Javadoc)
+ * @see org.apache.ibatis.ibator.api.JavaTypeResolver#setWarnings(java.util.List)
+ */
+ public void setWarnings(List<String> warnings) {
+ this.warnings = warnings;
+ }
public void setIbatorContext(IbatorContext ibatorContext) {
this.ibatorContext = ibatorContext;
Modified: ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/types/JdbcTypeNameTranslator.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/types/JdbcTypeNameTranslator.java?rev=746048&r1=746047&r2=746048&view=diff
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/types/JdbcTypeNameTranslator.java (original)
+++ ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/types/JdbcTypeNameTranslator.java Thu Feb 19 23:07:37 2009
@@ -16,156 +16,119 @@
package org.apache.ibatis.ibator.internal.types;
import java.sql.Types;
+import java.util.HashMap;
+import java.util.Map;
/**
*
* @author Jeff Butler
*/
public class JdbcTypeNameTranslator {
+
+ private static Map<Integer, String> typeToName;
+ private static Map<String, Integer> nameToType;
+
+ static {
+ typeToName = new HashMap<Integer, String>();
+ typeToName.put(Types.ARRAY, "ARRAY"); //$NON-NLS-1$
+ typeToName.put(Types.BIGINT, "BIGINT"); //$NON-NLS-1$
+ typeToName.put(Types.BINARY, "BINARY"); //$NON-NLS-1$
+ typeToName.put(Types.BIT, "BIT"); //$NON-NLS-1$
+ typeToName.put(Types.BLOB, "BLOB"); //$NON-NLS-1$
+ typeToName.put(Types.BOOLEAN, "BOOLEAN"); //$NON-NLS-1$
+ typeToName.put(Types.CHAR, "CHAR"); //$NON-NLS-1$
+ typeToName.put(Types.CLOB, "CLOB"); //$NON-NLS-1$
+ typeToName.put(Types.DATALINK, "DATALINK"); //$NON-NLS-1$
+ typeToName.put(Types.DATE, "DATE"); //$NON-NLS-1$
+ typeToName.put(Types.DECIMAL, "DECIMAL"); //$NON-NLS-1$
+ typeToName.put(Types.DISTINCT, "DISTINCT"); //$NON-NLS-1$
+ typeToName.put(Types.DOUBLE, "DOUBLE"); //$NON-NLS-1$
+ typeToName.put(Types.FLOAT, "FLOAT"); //$NON-NLS-1$
+ typeToName.put(Types.INTEGER, "INTEGER"); //$NON-NLS-1$
+ typeToName.put(Types.JAVA_OBJECT, "JAVA_OBJECT"); //$NON-NLS-1$
+ typeToName.put(Types.LONGVARBINARY, "LONGVARBINARY"); //$NON-NLS-1$
+ typeToName.put(Types.LONGVARCHAR, "LONGVARCHAR"); //$NON-NLS-1$
+ typeToName.put(Types.NULL, "NULL"); //$NON-NLS-1$
+ typeToName.put(Types.NUMERIC, "NUMERIC"); //$NON-NLS-1$
+ typeToName.put(Types.OTHER, "OTHER"); //$NON-NLS-1$
+ typeToName.put(Types.REAL, "REAL"); //$NON-NLS-1$
+ typeToName.put(Types.REF, "REF"); //$NON-NLS-1$
+ typeToName.put(Types.SMALLINT, "SMALLINT"); //$NON-NLS-1$
+ typeToName.put(Types.STRUCT, "STRUCT"); //$NON-NLS-1$
+ typeToName.put(Types.TIME, "TIME"); //$NON-NLS-1$
+ typeToName.put(Types.TIMESTAMP, "TIMESTAMP"); //$NON-NLS-1$
+ typeToName.put(Types.TINYINT, "TINYINT"); //$NON-NLS-1$
+ typeToName.put(Types.VARBINARY, "VARBINARY"); //$NON-NLS-1$
+ typeToName.put(Types.VARCHAR, "VARCHAR"); //$NON-NLS-1$
+
+ nameToType = new HashMap<String, Integer>();
+ nameToType.put("ARRAY", Types.ARRAY); //$NON-NLS-1$
+ nameToType.put("BIGINT", Types.BIGINT); //$NON-NLS-1$
+ nameToType.put("BINARY", Types.BINARY); //$NON-NLS-1$
+ nameToType.put("BIT", Types.BIT); //$NON-NLS-1$
+ nameToType.put("BLOB", Types.BLOB); //$NON-NLS-1$
+ nameToType.put("BOOLEAN", Types.BOOLEAN); //$NON-NLS-1$
+ nameToType.put("CHAR", Types.CHAR); //$NON-NLS-1$
+ nameToType.put("CLOB", Types.CLOB); //$NON-NLS-1$
+ nameToType.put("DATALINK", Types.DATALINK); //$NON-NLS-1$
+ nameToType.put("DATE", Types.DATE); //$NON-NLS-1$
+ nameToType.put("DECIMAL", Types.DECIMAL); //$NON-NLS-1$
+ nameToType.put("DISTINCT", Types.DISTINCT); //$NON-NLS-1$
+ nameToType.put("DOUBLE", Types.DOUBLE); //$NON-NLS-1$
+ nameToType.put("FLOAT", Types.FLOAT); //$NON-NLS-1$
+ nameToType.put("INTEGER", Types.INTEGER); //$NON-NLS-1$
+ nameToType.put("JAVA_OBJECT", Types.JAVA_OBJECT); //$NON-NLS-1$
+ nameToType.put("LONGVARBINARY", Types.LONGVARBINARY); //$NON-NLS-1$
+ nameToType.put("LONGVARCHAR", Types.LONGVARCHAR); //$NON-NLS-1$
+ nameToType.put("NULL", Types.NULL); //$NON-NLS-1$
+ nameToType.put("NUMERIC", Types.NUMERIC); //$NON-NLS-1$
+ nameToType.put("OTHER", Types.OTHER); //$NON-NLS-1$
+ nameToType.put("REAL", Types.REAL); //$NON-NLS-1$
+ nameToType.put("REF", Types.REF); //$NON-NLS-1$
+ nameToType.put("SMALLINT", Types.SMALLINT); //$NON-NLS-1$
+ nameToType.put("STRUCT", Types.STRUCT); //$NON-NLS-1$
+ nameToType.put("TIME", Types.TIME); //$NON-NLS-1$
+ nameToType.put("TIMESTAMP", Types.TIMESTAMP); //$NON-NLS-1$
+ nameToType.put("TINYINT", Types.TINYINT); //$NON-NLS-1$
+ nameToType.put("VARBINARY", Types.VARBINARY); //$NON-NLS-1$
+ nameToType.put("VARCHAR", Types.VARCHAR); //$NON-NLS-1$
+ }
/**
* Utility Class - no instances
*/
- private JdbcTypeNameTranslator() {
- super();
- }
+ private JdbcTypeNameTranslator() {
+ super();
+ }
- /**
- * Translates from a java.sql.Types values to the proper iBATIS
- * string representation of the type.
- *
- * @param jdbcType a value from java.sql.Types
- * @return the iBATIS String representation of a JDBC type
- */
- public static String getJdbcTypeName(int jdbcType) {
- String answer;
-
- switch (jdbcType) {
- case Types.ARRAY:
- answer = "ARRAY"; //$NON-NLS-1$
- break;
-
- case Types.BIGINT:
- answer = "BIGINT"; //$NON-NLS-1$
- break;
-
- case Types.BINARY:
- answer = "BINARY"; //$NON-NLS-1$
- break;
-
- case Types.BIT:
- answer = "BIT"; //$NON-NLS-1$
- break;
-
- case Types.BLOB:
- answer = "BLOB"; //$NON-NLS-1$
- break;
-
- case Types.BOOLEAN:
- answer = "BOOLEAN"; //$NON-NLS-1$
- break;
-
- case Types.CHAR:
- answer = "CHAR"; //$NON-NLS-1$
- break;
-
- case Types.CLOB:
- answer = "CLOB"; //$NON-NLS-1$
- break;
-
- case Types.DATALINK:
- answer = "DATALINK"; //$NON-NLS-1$
- break;
-
- case Types.DATE:
- answer = "DATE"; //$NON-NLS-1$
- break;
-
- case Types.DECIMAL:
- answer = "DECIMAL"; //$NON-NLS-1$
- break;
-
- case Types.DISTINCT:
- answer = "DISTINCT"; //$NON-NLS-1$
- break;
-
- case Types.DOUBLE:
- answer = "DOUBLE"; //$NON-NLS-1$
- break;
-
- case Types.FLOAT:
- answer = "FLOAT"; //$NON-NLS-1$
- break;
-
- case Types.INTEGER:
- answer = "INTEGER"; //$NON-NLS-1$
- break;
-
- case Types.JAVA_OBJECT:
- answer = "JAVA_OBJECT"; //$NON-NLS-1$
- break;
-
- case Types.LONGVARBINARY:
- answer = "LONGVARBINARY"; //$NON-NLS-1$
- break;
-
- case Types.LONGVARCHAR:
- answer = "LONGVARCHAR"; //$NON-NLS-1$
- break;
-
- case Types.NULL:
- answer = "NULL"; //$NON-NLS-1$
- break;
-
- case Types.NUMERIC:
- answer = "NUMERIC"; //$NON-NLS-1$
- break;
-
- case Types.OTHER:
- answer = "OTHER"; //$NON-NLS-1$
- break;
-
- case Types.REAL:
- answer = "REAL"; //$NON-NLS-1$
- break;
-
- case Types.REF:
- answer = "REF"; //$NON-NLS-1$
- break;
-
- case Types.SMALLINT:
- answer = "SMALLINT"; //$NON-NLS-1$
- break;
-
- case Types.STRUCT:
- answer = "STRUCT"; //$NON-NLS-1$
- break;
-
- case Types.TIME:
- answer = "TIME"; //$NON-NLS-1$
- break;
-
- case Types.TIMESTAMP:
- answer = "TIMESTAMP"; //$NON-NLS-1$
- break;
-
- case Types.TINYINT:
- answer = "TINYINT"; //$NON-NLS-1$
- break;
-
- case Types.VARBINARY:
- answer = "VARBINARY"; //$NON-NLS-1$
- break;
-
- case Types.VARCHAR:
- answer = "VARCHAR"; //$NON-NLS-1$
- break;
-
- default:
+ /**
+ * Translates from a java.sql.Types values to the proper iBATIS
+ * string representation of the type.
+ *
+ * @param jdbcType a value from java.sql.Types
+ * @return the iBATIS String representation of a JDBC type
+ */
+ public static String getJdbcTypeName(int jdbcType) {
+ String answer = typeToName.get(jdbcType);
+ if (answer == null) {
answer = "OTHER"; //$NON-NLS-1$
- break;
- }
-
+ }
+
+ return answer;
+ }
+ /**
+ * Translates from the string representation of the type to the
+ * java.sql.Types value.
+ *
+ * @param jdbcTypeName the iBATIS String representation of a JDBC type
+ * @return a value from java.sql.Types
+ */
+ public static int getJdbcType(String jdbcTypeName) {
+ Integer answer = nameToType.get(jdbcTypeName);
+ if (answer == null) {
+ answer = Types.OTHER;
+ }
+
return answer;
- }
+ }
}
Modified: ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/util/messages/messages.properties
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/util/messages/messages.properties?rev=746048&r1=746047&r2=746048&view=diff
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/util/messages/messages.properties (original)
+++ ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/util/messages/messages.properties Thu Feb 19 23:07:37 2009
@@ -37,6 +37,7 @@
RuntimeError.18=Unsupported XML Node Type {0} in XML File Merger
RuntimeError.19=Value missing after {0}
RuntimeError.20=Unknown argument: {0}
+RuntimeError.21=Error creating logger for class {0}. Cause: {1}
Warning.0=There are no statements enabled for table {0}, this table will be ignored.
Warning.1=Table {0} does not exist, this table will be ignored
@@ -60,9 +61,9 @@
Warning.18=Table {0} contains only LOB fields, this table will be ignored
Warning.19=Table configuration with catalog {0}, schema {1}, and table {2} did not resolve to any tables
Warning.20=Root class {0} cannot be loaded, checking for member overrides is disabled for this class
-Warning.21=Property {0} exists in root class {1}, but is not of type {2}. iBATOR will generate the property.
-Warning.22=Property {0} exists in root class {1}, but does not have a getter. iBATOR will generate the property.
-Warning.23=Property {0} exists in root class {1}, but does not have a setter. iBATOR will generate the property.
+Warning.21=Property {0} exists in root class {1}, but is not of type {2}. Ibator will generate the property.
+Warning.22=Property {0} exists in root class {1}, but does not have a getter. Ibator will generate the property.
+Warning.23=Property {0} exists in root class {1}, but does not have a setter. Ibator will generate the property.
Warning.24=Plugin {0} in context {1} is invalid and will be ignored.
Warning.25=SqlMapConfigPlugin requires the targetProject property
Warning.26=SqlMapConfigPlugin requires the targetPackage property
@@ -72,8 +73,8 @@
Progress.0=Connecting to the Database
Progress.1=Introspecting table {0}
Progress.3=XML Parser Errors occurred:
-Progress.4=ibator finshed successfully.
-Progress.5=ibator finshed successfully, there were warninigs.
+Progress.4=Ibator finshed successfully.
+Progress.5=Ibator finshed successfully, there were warninigs.
Progress.6=Generating Example class for table {0}
Progress.7=Generating Primary Key class for table {0}
Progress.8=Generating Record class for table {0}
@@ -83,23 +84,28 @@
Progress.14=Generating DAO Interface and Implementation for table {0}
Progress.15=Saving file {0}
+Tracing.1=Retrieving column information for table "{0}"
+Tracing.2=Found column "{0}", data type {1}, in table "{2}"
+Tracing.3=Removing column "{0}" in table "{1}" because it is ignored by configuration
+Tracing.4=Found override for column "{0}" in table "{1}"
+
Usage.Lines=19
-Usage.0=Apache iBATIS ibator - a code generator for iBATIS. Usage:
+Usage.0=Apache iBATIS Ibator - a code generator for iBATIS. Usage:
Usage.1=\ java -jar ibator.jar -configfile file_name [-overwrite]
Usage.2=\ [-contextids ids] [-tables tableName]
Usage.3=
Usage.4=Where:
-Usage.5=\ -configfile: Specifies the the ibator XML configuration file (required)
+Usage.5=\ -configfile: Specifies the the Ibator XML configuration file (required)
Usage.6=
Usage.7=\ -overwrite: If specified then exsting Java files will be overwritten.
-Usage.8=\ If not specified, then ibator will not overwrite existing
+Usage.8=\ If not specified, then Ibator will not overwrite existing
Usage.9=\ Java files (will save results in uniqely named files)
Usage.10=
Usage.11=\ -contextids: Used to specify a comma delimited list of contexts to use in
-Usage.12=\ this run of ibator. If not specified, all contexts will be
+Usage.12=\ this run of Ibator. If not specified, all contexts will be
Usage.13=\ used.
Usage.14=
Usage.15=\ -tables: Used to specify a comma delimited list of tables to use in this
-Usage.16=\ run of ibator. If not specified, all tables will be used. Table
+Usage.16=\ run of Ibator. If not specified, all tables will be used. Table
Usage.17=\ names must be fully qualified (e.g. schema.tablename). Table names
Usage.18=\ must exactly match the case specified in the configuration file.
Added: ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/logging/JdkLoggingImpl.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/logging/JdkLoggingImpl.java?rev=746048&view=auto
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/logging/JdkLoggingImpl.java (added)
+++ ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/logging/JdkLoggingImpl.java Thu Feb 19 23:07:37 2009
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2009 The Apache Software Foundation
+ *
+ * Licensed 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.ibatis.ibator.logging;
+
+import java.util.logging.Level;
+import java.util.logging.LogRecord;
+import java.util.logging.Logger;
+
+/**
+ *
+ * @author Clinton Begin
+ * @author Jeff Butler
+ *
+ */
+public class JdkLoggingImpl implements Log {
+
+ private Logger log;
+
+ public JdkLoggingImpl(Class<?> clazz) {
+ log = Logger.getLogger(clazz.getName());
+ }
+
+ public boolean isDebugEnabled() {
+ return log.isLoggable(Level.FINE);
+ }
+
+ public void error(String s, Throwable e) {
+ LogRecord lr = new LogRecord(Level.SEVERE, s);
+ lr.setSourceClassName(log.getName());
+ lr.setThrown(e);
+
+ log.log(lr);
+ }
+
+ public void error(String s) {
+ LogRecord lr = new LogRecord(Level.SEVERE, s);
+ lr.setSourceClassName(log.getName());
+
+ log.log(lr);
+ }
+
+ public void debug(String s) {
+ LogRecord lr = new LogRecord(Level.FINE, s);
+ lr.setSourceClassName(log.getName());
+
+ log.log(lr);
+ }
+
+ public void warn(String s) {
+ LogRecord lr = new LogRecord(Level.WARNING, s);
+ lr.setSourceClassName(log.getName());
+
+ log.log(lr);
+ }
+}
Added: ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/logging/Log.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/logging/Log.java?rev=746048&view=auto
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/logging/Log.java (added)
+++ ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/logging/Log.java Thu Feb 19 23:07:37 2009
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2009 The Apache Software Foundation
+ *
+ * Licensed 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.ibatis.ibator.logging;
+
+/**
+ *
+ * @author Clinton Begin
+ */
+public interface Log {
+
+ boolean isDebugEnabled();
+
+ void error(String s, Throwable e);
+
+ void error(String s);
+
+ public void debug(String s);
+
+ public void warn(String s);
+}
Added: ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/logging/Log4jImpl.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/logging/Log4jImpl.java?rev=746048&view=auto
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/logging/Log4jImpl.java (added)
+++ ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/logging/Log4jImpl.java Thu Feb 19 23:07:37 2009
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2009 The Apache Software Foundation
+ *
+ * Licensed 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.ibatis.ibator.logging;
+
+import org.apache.log4j.Logger;
+
+/**
+ *
+ * @author Clinton Begin
+ *
+ */
+public class Log4jImpl implements Log {
+
+ private Logger log;
+
+ public Log4jImpl(Class<?> clazz) {
+ log = Logger.getLogger(clazz);
+ }
+
+ public boolean isDebugEnabled() {
+ return log.isDebugEnabled();
+ }
+
+ public void error(String s, Throwable e) {
+ log.error(s, e);
+ }
+
+ public void error(String s) {
+ log.error(s);
+ }
+
+ public void debug(String s) {
+ log.debug(s);
+ }
+
+ public void warn(String s) {
+ log.warn(s);
+ }
+}
Added: ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/logging/LogFactory.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/logging/LogFactory.java?rev=746048&view=auto
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/logging/LogFactory.java (added)
+++ ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/logging/LogFactory.java Thu Feb 19 23:07:37 2009
@@ -0,0 +1,81 @@
+/*
+ * Copyright 2009 The Apache Software Foundation
+ *
+ * Licensed 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.ibatis.ibator.logging;
+
+import java.lang.reflect.Constructor;
+
+import org.apache.ibatis.ibator.internal.IbatorObjectFactory;
+import org.apache.ibatis.ibator.internal.util.messages.Messages;
+
+/**
+ *
+ * @author Clinton Begin
+ * @author Jeff Butler
+ *
+ */
+public class LogFactory {
+
+ private static Constructor<?> logConstructor;
+
+ static {
+ tryImplementation("org.apache.log4j.Logger", //$NON-NLS-1$
+ "org.apache.ibatis.ibator.logging.Log4jImpl"); //$NON-NLS-1$
+ tryImplementation("java.util.logging.Logger", //$NON-NLS-1$
+ "org.apache.ibatis.ibator.logging.JdkLoggingImpl"); //$NON-NLS-1$
+ }
+
+ private static void tryImplementation(String testClassName,
+ String implClassName) {
+ if (logConstructor == null) {
+ try {
+ IbatorObjectFactory.internalClassForName(testClassName);
+ Class<?> implClass = IbatorObjectFactory.internalClassForName(implClassName);
+ logConstructor = implClass
+ .getConstructor(new Class[] { Class.class });
+ } catch (Throwable t) {
+ }
+ }
+ }
+
+ public static Log getLog(Class<?> aClass) {
+ try {
+ return (Log) logConstructor.newInstance(new Object[] { aClass });
+ } catch (Throwable t) {
+ throw new RuntimeException(Messages.getString("RuntimeError.21", //$NON-NLS-1$
+ aClass.getName(), t.getMessage()), t);
+ }
+ }
+
+ /**
+ * This method will switch the logging implementation to Java native logging.
+ * This is useful in situations
+ * where you want to use Java native logging to log Ibator activity but
+ * Log4J is on the classpath. Note that this method is
+ * only effective for log classes obtained after calling this method. If you
+ * intend to use this method you should call it before calling any other
+ * Ibator method.
+ */
+ public static synchronized void selectJavaLogging() {
+ try {
+ IbatorObjectFactory.internalClassForName("java.util.logging.Logger"); //$NON-NLS-1$
+ Class<?> implClass = IbatorObjectFactory.internalClassForName(
+ "org.apache.ibatis.ibator.logging.JdkLoggingImpl"); //$NON-NLS-1$
+ logConstructor = implClass
+ .getConstructor(new Class[] { Class.class });
+ } catch (Throwable t) {
+ }
+ }
+}