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 2008/10/10 22:08:12 UTC

svn commit: r703569 [2/6] - in /ibatis/trunk/java/tools/ibator/core: build/ devlib/ doc/ src/org/apache/ibatis/ibator/api/ src/org/apache/ibatis/ibator/config/ src/org/apache/ibatis/ibator/config/xml/ src/org/apache/ibatis/ibator/generator/ src/org/apa...

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=703569&r1=703568&r2=703569&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 Fri Oct 10 13:08:10 2008
@@ -23,15 +23,12 @@
 import java.util.Set;
 
 import org.apache.ibatis.ibator.api.CommentGenerator;
-import org.apache.ibatis.ibator.api.DAOGenerator;
 import org.apache.ibatis.ibator.api.GeneratedJavaFile;
 import org.apache.ibatis.ibator.api.GeneratedXmlFile;
 import org.apache.ibatis.ibator.api.IbatorPlugin;
 import org.apache.ibatis.ibator.api.IntrospectedTable;
-import org.apache.ibatis.ibator.api.JavaModelGenerator;
 import org.apache.ibatis.ibator.api.JavaTypeResolver;
 import org.apache.ibatis.ibator.api.ProgressCallback;
-import org.apache.ibatis.ibator.api.SqlMapGenerator;
 import org.apache.ibatis.ibator.api.dom.xml.Attribute;
 import org.apache.ibatis.ibator.api.dom.xml.XmlElement;
 import org.apache.ibatis.ibator.internal.IbatorObjectFactory;
@@ -47,111 +44,100 @@
  */
 public class IbatorContext extends PropertyHolder {
     private String id;
-    
-	private JDBCConnectionConfiguration jdbcConnectionConfiguration;
 
-	private SqlMapGeneratorConfiguration sqlMapGeneratorConfiguration;
+    private JDBCConnectionConfiguration jdbcConnectionConfiguration;
 
-	private JavaTypeResolverConfiguration javaTypeResolverConfiguration;
+    private SqlMapGeneratorConfiguration sqlMapGeneratorConfiguration;
 
-	private JavaModelGeneratorConfiguration javaModelGeneratorConfiguration;
+    private JavaTypeResolverConfiguration javaTypeResolverConfiguration;
 
-	private DAOGeneratorConfiguration daoGeneratorConfiguration;
+    private JavaModelGeneratorConfiguration javaModelGeneratorConfiguration;
+
+    private DAOGeneratorConfiguration daoGeneratorConfiguration;
+
+    private ArrayList<TableConfiguration> tableConfigurations;
 
-	private ArrayList<TableConfiguration> tableConfigurations;
-    
-    private GeneratorSet generatorSet;
-    
     private ModelType defaultModelType;
-    
-    private String configuredGeneratorSet;
-    
+
     private String beginningDelimiter = "\""; //$NON-NLS-1$
-	
+
     private String endingDelimiter = "\""; //$NON-NLS-1$
-    
+
     private boolean suppressTypeWarnings;
-    
+
     private CommentGeneratorConfiguration commentGeneratorConfiguration;
-    
+
     private CommentGenerator commentGenerator;
-    
+
     private IbatorPluginAggregator pluginAggregator;
-    
+
     private List<IbatorPluginConfiguration> pluginConfigurations;
-    
-    private String introspectedTableImplementation;
-    
+
+    private String targetJRE;
+
     /**
      * Constructs an IbatorContext object.
      * 
-     * @param generatorSetType - may be null
-     * @param defaultModelType - may be null
+     * @param targetJRE -
+     *            may be null
+     * @param defaultModelType -
+     *            may be null
      */
-    public IbatorContext(String generatorSetType, ModelType defaultModelType) {
+    public IbatorContext(String targetJRE, ModelType defaultModelType) {
         super();
-        
-        this.configuredGeneratorSet = generatorSetType;
-        
+
+        this.targetJRE = targetJRE;
+
         if (defaultModelType == null) {
             this.defaultModelType = ModelType.CONDITIONAL;
         } else {
             this.defaultModelType = defaultModelType;
         }
-        
-        if (generatorSetType == null) {
-            generatorSet = new Java2GeneratorSet();
-        } else if ("Java2".equalsIgnoreCase(generatorSetType)) { //$NON-NLS-1$
-            generatorSet = new Java2GeneratorSet();
-        } else if ("Java5".equalsIgnoreCase(generatorSetType)) { //$NON-NLS-1$
-            generatorSet = new Java5GeneratorSet();
-        } else {
-            generatorSet = (GeneratorSet) IbatorObjectFactory.createObject(generatorSetType);
-        }
-        
-		tableConfigurations = new ArrayList<TableConfiguration>();
+
+        tableConfigurations = new ArrayList<TableConfiguration>();
         pluginConfigurations = new ArrayList<IbatorPluginConfiguration>();
     }
 
-	public void addTableConfiguration(TableConfiguration tc) {
-		tableConfigurations.add(tc);
-	}
-
-	public JDBCConnectionConfiguration getJdbcConnectionConfiguration() {
-		return jdbcConnectionConfiguration;
-	}
-
-	public DAOGeneratorConfiguration getDaoGeneratorConfiguration() {
-		return daoGeneratorConfiguration;
-	}
-
-	public JavaModelGeneratorConfiguration getJavaModelGeneratorConfiguration() {
-		return javaModelGeneratorConfiguration;
-	}
-
-	public JavaTypeResolverConfiguration getJavaTypeResolverConfiguration() {
-		return javaTypeResolverConfiguration;
-	}
-
-	public SqlMapGeneratorConfiguration getSqlMapGeneratorConfiguration() {
-		return sqlMapGeneratorConfiguration;
-	}
+    public void addTableConfiguration(TableConfiguration tc) {
+        tableConfigurations.add(tc);
+    }
+
+    public JDBCConnectionConfiguration getJdbcConnectionConfiguration() {
+        return jdbcConnectionConfiguration;
+    }
+
+    public DAOGeneratorConfiguration getDaoGeneratorConfiguration() {
+        return daoGeneratorConfiguration;
+    }
+
+    public JavaModelGeneratorConfiguration getJavaModelGeneratorConfiguration() {
+        return javaModelGeneratorConfiguration;
+    }
+
+    public JavaTypeResolverConfiguration getJavaTypeResolverConfiguration() {
+        return javaTypeResolverConfiguration;
+    }
+
+    public SqlMapGeneratorConfiguration getSqlMapGeneratorConfiguration() {
+        return sqlMapGeneratorConfiguration;
+    }
     
-    public void addPluginConfiguration(IbatorPluginConfiguration ibatorPluginConfiguration) {
+    public void addPluginConfiguration(
+            IbatorPluginConfiguration ibatorPluginConfiguration) {
         pluginConfigurations.add(ibatorPluginConfiguration);
     }
 
-	/**
-	 * This method does a simple validate, it makes sure that all required
-	 * fields have been filled in. It does not do any more complex operations such
-	 * as validating that database tables exist or validating that named
-	 * columns exist
-	 */
-	public void validate(List<String> errors) {
+    /**
+     * This method does a simple validate, it makes sure that all required
+     * fields have been filled in. It does not do any more complex operations
+     * such as validating that database tables exist or validating that named
+     * columns exist
+     */
+    public void validate(List<String> errors) {
         if (!StringUtility.stringHasValue(id)) {
             errors.add(Messages.getString("ValidationError.16")); //$NON-NLS-1$
         }
-        
+
         if (jdbcConnectionConfiguration == null) {
             errors.add(Messages.getString("ValidationError.10")); //$NON-NLS-1$
         } else {
@@ -182,188 +168,42 @@
                 errors.add(Messages.getString("ValidationError.12", //$NON-NLS-1$
                         "SQLMapGenerator", id)); //$NON-NLS-1$
             }
-		}
+        }
 
-		if (daoGeneratorConfiguration != null) {
-			if (!StringUtility.stringHasValue(daoGeneratorConfiguration.getTargetProject())) {
-				errors.add(Messages.getString("ValidationError.2", id)); //$NON-NLS-1$
-			}
+        if (daoGeneratorConfiguration != null) {
+            if (!StringUtility.stringHasValue(daoGeneratorConfiguration.getTargetProject())) {
+                errors.add(Messages.getString("ValidationError.2", id)); //$NON-NLS-1$
+            }
 
             if (!StringUtility.stringHasValue(daoGeneratorConfiguration.getTargetPackage())) {
                 errors.add(Messages.getString("ValidationError.12", //$NON-NLS-1$
                         "DAOGenerator", id)); //$NON-NLS-1$
             }
-		}
-        
-		if (tableConfigurations.size() == 0) {
-			errors.add(Messages.getString("ValidationError.3")); //$NON-NLS-1$
-		} else {
-			for (int i = 0; i < tableConfigurations.size(); i++) {
-				TableConfiguration tc = tableConfigurations.get(i);
-
-				tc.validate(errors, i);
-			}
-		}
-        
-        for (IbatorPluginConfiguration ibatorPluginConfiguration : pluginConfigurations) {
-            ibatorPluginConfiguration.validate(errors, id);
-        }
-	}
-	
-	/**
-	 * Generate iBATIS artifacts based on the configuration specified in the
-	 * constructor.  This method is long running.
-	 * 
-	 * @param callback a progress callback if progress information is desired, or <code>null</code>
-	 * @param generatedJavaFiles any Java file generated from this method will be added to the List
-	 *                            The objects will be of type GeneratedJavaFile.
-	 * @param generatedXmlFiles any XML file generated from this method will be added to the List.
-	 *                            The objects will be of type GeneratedXMLFile.
-	 * @param warnings any warning generated from this method will be added to the List.  Warnings
-	 *                   are always Strings.
-     * @param fullyQualifiedTableNames a set of table names to generate.  The elements
-     *   of the set must be Strings that exactly match what's specified in the configuration.
-     *   For example, if table name = "foo" and schema = "bar", then the fully qualified
-     *   table name is "foo.bar".
-     *   If the Set is null or empty, then all tables in the configuration will be
-     *   used for code generation.
-	 * 
-	 * @throws SQLException if some error arrises while introspecting the specified
-	 *                      database tables.
-	 * 
-	 * @throws InterruptedException if the progress callback reports a cancel
-	 */
-	public void generateFiles(ProgressCallback callback, List<GeneratedJavaFile> generatedJavaFiles,
-			List<GeneratedXmlFile> generatedXmlFiles, List<String> warnings,
-            Set<String> fullyQualifiedTableNames)
-            throws SQLException, InterruptedException {
-	    
-	    if (callback == null) {
-	        callback = new NullProgressCallback();
-	    }
-	    
-        JavaTypeResolver javaTypeResolver = IbatorObjectFactory.createJavaTypeResolver(this, warnings);
-        JavaModelGenerator javaModelGenerator = IbatorObjectFactory.createJavaModelGenerator(this, warnings);
-        SqlMapGenerator sqlMapGenerator = IbatorObjectFactory.createSqlMapGenerator(this, warnings);
-        DAOGenerator daoGenerator = IbatorObjectFactory.createDAOGenerator(this, warnings);
-        pluginAggregator = new IbatorPluginAggregator();
-        for (IbatorPluginConfiguration ibatorPluginConfiguration : pluginConfigurations) {
-            IbatorPlugin plugin = IbatorObjectFactory.createIbatorPlugin(this, ibatorPluginConfiguration);
-            if (plugin.validate(warnings)) {
-                pluginAggregator.addPlugin(plugin);
-            } else {
-                warnings.add(Messages.getString("Warning.24", //$NON-NLS-1$
-                        ibatorPluginConfiguration.getConfigurationType(),
-                        id));
-            }
         }
 
-        Connection connection = null;
-		
-        try {
-            callback.startSubTask(Messages.getString("Progress.0")); //$NON-NLS-1$
-            connection = getConnection();
-
-            DatabaseIntrospector databaseIntrospector =
-                new DatabaseIntrospector(this, connection.getMetaData(), javaTypeResolver, warnings);
-
-            for (TableConfiguration tc : tableConfigurations) {
-                String tableName = StringUtility.composeFullyQualifiedTableName(
-                        tc.getCatalog(), tc.getSchema(), tc.getTableName(), '.');
-                
-                if (fullyQualifiedTableNames != null
-                        && fullyQualifiedTableNames.size() > 0) {
-                    if (!fullyQualifiedTableNames.contains(tableName)) {
-                        continue;
-                    }
-                }
-				
-                if (!tc.areAnyStatementsEnabled()) {
-                    warnings.add(Messages.getString("Warning.0", tableName)); //$NON-NLS-1$
-                    continue;
-                }
-
-                Collection<? extends IntrospectedTable> introspectedTables;
-                callback.startSubTask(Messages.getString("Progress.1", tableName)); //$NON-NLS-1$
-                introspectedTables  = databaseIntrospector.introspectTables(tc);
-                callback.checkCancel();
-                
-                if (introspectedTables != null) {
-                    for (IntrospectedTable introspectedTable : introspectedTables) {
-                        callback.checkCancel();
-
-                        if (daoGenerator != null) {
-                            generatedJavaFiles.addAll(daoGenerator.getGeneratedJavaFiles(introspectedTable, callback));
-                        }
-                        
-                        generatedJavaFiles.addAll(javaModelGenerator.getGeneratedJavaFiles(introspectedTable, callback));
-                        generatedXmlFiles.addAll(sqlMapGenerator.getGeneratedXMLFiles(introspectedTable, callback));
+        if (tableConfigurations.size() == 0) {
+            errors.add(Messages.getString("ValidationError.3")); //$NON-NLS-1$
+        } else {
+            for (int i = 0; i < tableConfigurations.size(); i++) {
+                TableConfiguration tc = tableConfigurations.get(i);
 
-                        generatedJavaFiles.addAll(pluginAggregator.contextGenerateAdditionalJavaFiles(introspectedTable));
-                        generatedXmlFiles.addAll(pluginAggregator.contextGenerateAdditionalXmlFiles(introspectedTable));
-                    }
-                }
+                tc.validate(errors, i);
             }
-            
-            generatedJavaFiles.addAll(pluginAggregator.contextGenerateAdditionalJavaFiles());
-            generatedXmlFiles.addAll(pluginAggregator.contextGenerateAdditionalXmlFiles());
-        } finally {
-            closeConnection(connection);
-            callback.finished();
-        }
-	}
-	
-	public int getTotalSteps() {
-	    int steps = 0;
-	    
-	    steps++;  // connect to database
-        
-        // for each table:
-        //
-        // 1. Introspect
-        // 2. Generate Example
-        // 3. Generate Primary Key
-        // 4. Generate Record
-        // 5. Generate Record with BLOBs
-        // 6. Generate SQL Map
-        // 7. Generate DAO Interface
-        // 8. Generate DAO Implementation
+        }
 
-	    steps += tableConfigurations.size() * 8;
-        
-	    return steps;
-	}
+        for (IbatorPluginConfiguration ibatorPluginConfiguration : pluginConfigurations) {
+            ibatorPluginConfiguration.validate(errors, id);
+        }
+    }
 
-	private Connection getConnection() throws SQLException {
-		Connection connection = ConnectionFactory.getInstance().
-				getConnection(jdbcConnectionConfiguration);
-
-		return connection;
-	}
-
-	private void closeConnection(Connection connection) {
-		if (connection != null) {
-			try {
-				connection.close();
-			} catch (SQLException e) {
-				// ignore
-				;
-			}
-		}
-	}
-	
     public String getId() {
         return id;
     }
-    
+
     public void setId(String id) {
         this.id = id;
     }
 
-    public GeneratorSet getGeneratorSet() {
-        return generatorSet;
-    }
-
     public void setDaoGeneratorConfiguration(
             DAOGeneratorConfiguration daoGeneratorConfiguration) {
         this.daoGeneratorConfiguration = daoGeneratorConfiguration;
@@ -394,41 +234,39 @@
     }
 
     /**
-     * Builds an XmlElement representation of this context.  Note that the
-     * XML may not necessarity validate if the context is invalid.  Call the
+     * Builds an XmlElement representation of this context. Note that the XML
+     * may not necessarity validate if the context is invalid. Call the
      * <code>validate</code> method to check validity of this context.
      * 
      * @return the XML representation of this context
      */
     public XmlElement toXmlElement() {
         XmlElement xmlElement = new XmlElement("ibatorContext"); //$NON-NLS-1$
-        
+
         if (defaultModelType != ModelType.CONDITIONAL) {
-            xmlElement.addAttribute(new Attribute("defaultModelType", defaultModelType.getModelType())); //$NON-NLS-1$
+            xmlElement.addAttribute(new Attribute(
+                    "defaultModelType", defaultModelType.getModelType())); //$NON-NLS-1$
         }
-        
-        if (StringUtility.stringHasValue(configuredGeneratorSet)) {
-            xmlElement.addAttribute(new Attribute("generatorSet", configuredGeneratorSet)); //$NON-NLS-1$
-        }
-        
-        if (StringUtility.stringHasValue(introspectedTableImplementation)) {
-            xmlElement.addAttribute(new Attribute("introspectedTableImplementation", introspectedTableImplementation)); //$NON-NLS-1$
+
+        if (StringUtility.stringHasValue(targetJRE)) {
+            xmlElement.addAttribute(new Attribute(
+                    "targetJRE", targetJRE)); //$NON-NLS-1$
         }
-        
+
         addPropertyXmlElements(xmlElement);
-        
+
         if (commentGeneratorConfiguration != null) {
             xmlElement.addElement(commentGeneratorConfiguration.toXmlElement());
         }
-        
+
         if (jdbcConnectionConfiguration != null) {
             xmlElement.addElement(jdbcConnectionConfiguration.toXmlElement());
         }
-        
+
         if (javaTypeResolverConfiguration != null) {
             xmlElement.addElement(javaTypeResolverConfiguration.toXmlElement());
         }
-        
+
         if (javaModelGeneratorConfiguration != null) {
             xmlElement.addElement(javaModelGeneratorConfiguration.toXmlElement());
         }
@@ -444,7 +282,7 @@
         for (TableConfiguration tableConfiguration : tableConfigurations) {
             xmlElement.addElement(tableConfiguration.toXmlElement());
         }
-        
+
         return xmlElement;
     }
 
@@ -463,7 +301,7 @@
     @Override
     public void addProperty(String name, String value) {
         super.addProperty(name, value);
-        
+
         if (PropertyRegistry.CONTEXT_SUPPRESS_TYPE_WARNINGS.equals(name)) {
             suppressTypeWarnings = StringUtility.isTrue(value);
         } else if (PropertyRegistry.CONTEXT_BEGINNING_DELIMITER.equals(name)) {
@@ -474,14 +312,14 @@
     }
 
     public boolean getSuppressTypeWarnings() {
-        return suppressTypeWarnings;
+        return suppressTypeWarnings && !"Java5".equalsIgnoreCase(targetJRE);
     }
 
     public CommentGenerator getCommentGenerator() {
         if (commentGenerator == null) {
             commentGenerator = IbatorObjectFactory.createCommentGenerator(this);
         }
-        
+
         return commentGenerator;
     }
 
@@ -498,16 +336,177 @@
         return pluginAggregator;
     }
 
-    public String getConfiguredGeneratorSet() {
-        return configuredGeneratorSet;
+    public String getTargetJRE() {
+        return targetJRE;
     }
 
-    public String getIntrospectedTableImplementation() {
-        return introspectedTableImplementation;
+    /**
+     * Generate iBATIS artifacts based on the configuration specified in the
+     * constructor. This method is long running.
+     * 
+     * @param callback
+     *            a progress callback if progress information is desired, or
+     *            <code>null</code>
+     * @param generatedJavaFiles
+     *            any Java file generated from this method will be added to
+     *            the List The objects will be of type GeneratedJavaFile.
+     * @param generatedXmlFiles
+     *            any XML file generated from this method will be added to
+     *            the List. The objects will be of type GeneratedXMLFile.
+     * @param warnings
+     *            any warning generated from this method will be added to
+     *            the List. Warnings are always Strings.
+     * @param fullyQualifiedTableNames
+     *            a set of table names to generate. The elements of the set
+     *            must be Strings that exactly match what's specified in the
+     *            configuration. For example, if table name = "foo" and
+     *            schema = "bar", then the fully qualified table name is
+     *            "foo.bar". If the Set is null or empty, then all tables in
+     *            the configuration will be used for code generation.
+     * 
+     * @throws SQLException
+     *             if some error arrises while introspecting the specified
+     *             database tables.
+     * 
+     * @throws InterruptedException
+     *             if the progress callback reports a cancel
+     */
+    public void generateFiles(ProgressCallback callback,
+            List<GeneratedJavaFile> generatedJavaFiles,
+            List<GeneratedXmlFile> generatedXmlFiles,
+            List<String> warnings, Set<String> fullyQualifiedTableNames)
+            throws SQLException, InterruptedException {
+        IbatorEngine ibatorEngine = new IbatorEngine();
+        ibatorEngine.generateFiles(callback, generatedJavaFiles, generatedXmlFiles, warnings, fullyQualifiedTableNames);
     }
+    
+    private class IbatorEngine {
+        public void generateFiles(ProgressCallback callback,
+                List<GeneratedJavaFile> generatedJavaFiles,
+                List<GeneratedXmlFile> generatedXmlFiles,
+                List<String> warnings, Set<String> fullyQualifiedTableNames)
+                throws SQLException, InterruptedException {
+
+            if (callback == null) {
+                callback = new NullProgressCallback();
+            }
+
+            JavaTypeResolver javaTypeResolver = IbatorObjectFactory
+                    .createJavaTypeResolver(IbatorContext.this, warnings);
+            pluginAggregator = new IbatorPluginAggregator();
+            for (IbatorPluginConfiguration ibatorPluginConfiguration : pluginConfigurations) {
+                IbatorPlugin plugin = IbatorObjectFactory.createIbatorPlugin(
+                        IbatorContext.this, ibatorPluginConfiguration);
+                if (plugin.validate(warnings)) {
+                    pluginAggregator.addPlugin(plugin);
+                } else {
+                    warnings.add(Messages.getString(
+                            "Warning.24", //$NON-NLS-1$
+                            ibatorPluginConfiguration.getConfigurationType(),
+                            id));
+                }
+            }
+
+            Connection connection = null;
+
+            try {
+                callback.startSubTask(Messages.getString("Progress.0")); //$NON-NLS-1$
+                connection = getConnection();
+
+                DatabaseIntrospector databaseIntrospector = new DatabaseIntrospector(
+                        IbatorContext.this, connection.getMetaData(), javaTypeResolver,
+                        warnings);
+
+                for (TableConfiguration tc : tableConfigurations) {
+                    String tableName = StringUtility
+                            .composeFullyQualifiedTableName(tc.getCatalog(), tc
+                                    .getSchema(), tc.getTableName(), '.');
+
+                    if (fullyQualifiedTableNames != null
+                            && fullyQualifiedTableNames.size() > 0) {
+                        if (!fullyQualifiedTableNames.contains(tableName)) {
+                            continue;
+                        }
+                    }
+
+                    if (!tc.areAnyStatementsEnabled()) {
+                        warnings
+                                .add(Messages.getString("Warning.0", tableName)); //$NON-NLS-1$
+                        continue;
+                    }
+
+                    Collection<? extends IntrospectedTable> introspectedTables;
+                    callback.startSubTask(Messages.getString(
+                            "Progress.1", tableName)); //$NON-NLS-1$
+                    introspectedTables = databaseIntrospector
+                            .introspectTables(tc);
+                    callback.checkCancel();
+
+                    if (introspectedTables != null) {
+                        for (IntrospectedTable introspectedTable : introspectedTables) {
+                            callback.checkCancel();
+                            
+                            introspectedTable.calculateGenerators(warnings, callback);
+                            generatedJavaFiles.addAll(introspectedTable.getGeneratedJavaFiles());
+                            generatedXmlFiles.addAll(introspectedTable.getGeneratedXmlFiles());
+
+                            generatedJavaFiles
+                                    .addAll(pluginAggregator
+                                            .contextGenerateAdditionalJavaFiles(introspectedTable));
+                            generatedXmlFiles
+                                    .addAll(pluginAggregator
+                                            .contextGenerateAdditionalXmlFiles(introspectedTable));
+                        }
+                    }
+                }
+
+                generatedJavaFiles.addAll(pluginAggregator
+                        .contextGenerateAdditionalJavaFiles());
+                generatedXmlFiles.addAll(pluginAggregator
+                        .contextGenerateAdditionalXmlFiles());
+            } finally {
+                closeConnection(connection);
+                callback.finished();
+            }
+        }
+
+        public int getTotalSteps() {
+            int steps = 0;
+
+            steps++; // connect to database
+
+            // for each table:
+            //
+            // 1. Introspect
+            // 2. Generate Example
+            // 3. Generate Primary Key
+            // 4. Generate Record
+            // 5. Generate Record with BLOBs
+            // 6. Generate SQL Map
+            // 7. Generate DAO Interface
+            // 8. Generate DAO Implementation
+
+            steps += tableConfigurations.size() * 8;
 
-    public void setIntrospectedTableImplementation(
-            String introspectedTableImplementation) {
-        this.introspectedTableImplementation = introspectedTableImplementation;
+            return steps;
+        }
+
+        private Connection getConnection() throws SQLException {
+            Connection connection = ConnectionFactory.getInstance()
+                    .getConnection(jdbcConnectionConfiguration);
+
+            return connection;
+        }
+
+        private void closeConnection(Connection connection) {
+            if (connection != null) {
+                try {
+                    connection.close();
+                } catch (SQLException e) {
+                    // ignore
+                    ;
+                }
+            }
+        }
     }
 }

Modified: ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/config/JavaModelGeneratorConfiguration.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/config/JavaModelGeneratorConfiguration.java?rev=703569&r1=703568&r2=703569&view=diff
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/config/JavaModelGeneratorConfiguration.java (original)
+++ ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/config/JavaModelGeneratorConfiguration.java Fri Oct 10 13:08:10 2008
@@ -22,7 +22,7 @@
 /**
  * @author Jeff Butler
  */
-public class JavaModelGeneratorConfiguration extends TypedPropertyHolder {
+public class JavaModelGeneratorConfiguration extends PropertyHolder {
 
     private String targetPackage;
 
@@ -53,9 +53,6 @@
 
     public XmlElement toXmlElement() {
         XmlElement answer = new XmlElement("javaModelGenerator"); //$NON-NLS-1$
-        if (getConfigurationType() != null) {
-            answer.addAttribute(new Attribute("type", getConfigurationType())); //$NON-NLS-1$
-        }
         
         if (targetPackage != null) {
             answer.addAttribute(new Attribute("targetPackage", targetPackage)); //$NON-NLS-1$

Modified: ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/config/SqlMapGeneratorConfiguration.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/config/SqlMapGeneratorConfiguration.java?rev=703569&r1=703568&r2=703569&view=diff
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/config/SqlMapGeneratorConfiguration.java (original)
+++ ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/config/SqlMapGeneratorConfiguration.java Fri Oct 10 13:08:10 2008
@@ -22,7 +22,7 @@
 /**
  * @author Jeff Butler
  */
-public class SqlMapGeneratorConfiguration extends TypedPropertyHolder {
+public class SqlMapGeneratorConfiguration extends PropertyHolder {
 	private String targetPackage;
 
 	private String targetProject;
@@ -52,9 +52,6 @@
 
     public XmlElement toXmlElement() {
         XmlElement answer = new XmlElement("sqlMapGenerator"); //$NON-NLS-1$
-        if (getConfigurationType() != null) {
-            answer.addAttribute(new Attribute("type", getConfigurationType())); //$NON-NLS-1$
-        }
         
         if (targetPackage != null) {
             answer.addAttribute(new Attribute("targetPackage", targetPackage)); //$NON-NLS-1$

Modified: ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/config/xml/IbatorConfigurationParser.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/config/xml/IbatorConfigurationParser.java?rev=703569&r1=703568&r2=703569&view=diff
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/config/xml/IbatorConfigurationParser.java (original)
+++ ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/config/xml/IbatorConfigurationParser.java Fri Oct 10 13:08:10 2008
@@ -237,17 +237,15 @@
             Node node) {
 
         Properties attributes = parseAttributes(node);
-        String generatorSet = attributes.getProperty("generatorSet"); //$NON-NLS-1$
+        String targetJRE = attributes.getProperty("targetJRE"); //$NON-NLS-1$
         String defaultModelType = attributes.getProperty("defaultModelType"); //$NON-NLS-1$
         String id = attributes.getProperty("id"); //$NON-NLS-1$
-        String introspectedTableImplementation = attributes.getProperty("introspectedTableImplementation"); //$NON-NLS-1$
 
         ModelType mt = defaultModelType == null ? null : ModelType
                 .getModelType(defaultModelType);
 
-        IbatorContext ibatorContext = new IbatorContext(generatorSet, mt);
+        IbatorContext ibatorContext = new IbatorContext(targetJRE, mt);
         ibatorContext.setId(id);
-        ibatorContext.setIntrospectedTableImplementation(introspectedTableImplementation);
 
         ibatorConfiguration.addIbatorContext(ibatorContext);
 
@@ -288,14 +286,9 @@
                 .setSqlMapGeneratorConfiguration(sqlMapGeneratorConfiguration);
 
         Properties attributes = parseAttributes(node);
-        String type = attributes.getProperty("type"); //$NON-NLS-1$
         String targetPackage = attributes.getProperty("targetPackage"); //$NON-NLS-1$
         String targetProject = attributes.getProperty("targetProject"); //$NON-NLS-1$
 
-        if (StringUtility.stringHasValue(type)) {
-            sqlMapGeneratorConfiguration.setConfigurationType(type);
-        }
-
         sqlMapGeneratorConfiguration.setTargetPackage(targetPackage);
         sqlMapGeneratorConfiguration.setTargetProject(targetProject);
 
@@ -575,14 +568,9 @@
                 .setJavaModelGeneratorConfiguration(javaModelGeneratorConfiguration);
 
         Properties attributes = parseAttributes(node);
-        String type = attributes.getProperty("type"); //$NON-NLS-1$
         String targetPackage = attributes.getProperty("targetPackage"); //$NON-NLS-1$
         String targetProject = attributes.getProperty("targetProject"); //$NON-NLS-1$
 
-        if (StringUtility.stringHasValue(type)) {
-            javaModelGeneratorConfiguration.setConfigurationType(type);
-        }
-
         javaModelGeneratorConfiguration.setTargetPackage(targetPackage);
         javaModelGeneratorConfiguration.setTargetProject(targetProject);
 

Modified: ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/config/xml/ParserEntityResolver.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/config/xml/ParserEntityResolver.java?rev=703569&r1=703568&r2=703569&view=diff
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/config/xml/ParserEntityResolver.java (original)
+++ ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/config/xml/ParserEntityResolver.java Fri Oct 10 13:08:10 2008
@@ -18,7 +18,7 @@
 import java.io.IOException;
 import java.io.InputStream;
 
-import org.apache.ibatis.ibator.internal.sqlmap.XmlConstants;
+import org.apache.ibatis.ibator.generator.ibatis2.XmlConstants;
 import org.xml.sax.EntityResolver;
 import org.xml.sax.InputSource;
 import org.xml.sax.SAXException;

Modified: ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/config/xml/ibator-config_1_0.dtd
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/config/xml/ibator-config_1_0.dtd?rev=703569&r1=703568&r2=703569&view=diff
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/config/xml/ibator-config_1_0.dtd (original)
+++ ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/config/xml/ibator-config_1_0.dtd Fri Oct 10 13:08:10 2008
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 
 <!--
-   Copyright 2006 The Apache Software Foundation
+   Copyright 2008 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.
@@ -54,8 +54,7 @@
                          javaModelGenerator, sqlMapGenerator, daoGenerator?, table+)>
 <!ATTLIST ibatorContext id ID #REQUIRED
   defaultModelType CDATA #IMPLIED
-  generatorSet CDATA #IMPLIED
-  introspectedTableImplementation CDATA #IMPLIED>
+  targetJRE CDATA #IMPLIED>
 
 <!--
   The jdbcConnection element is used to describe the JDBC connection that ibator
@@ -101,7 +100,6 @@
 -->
 <!ELEMENT javaModelGenerator (property*)>
 <!ATTLIST javaModelGenerator
-  type CDATA #IMPLIED
   targetPackage CDATA #REQUIRED
   targetProject CDATA #REQUIRED>
 
@@ -122,7 +120,6 @@
 -->
 <!ELEMENT sqlMapGenerator (property*)>
 <!ATTLIST sqlMapGenerator
-  type CDATA #IMPLIED
   targetPackage CDATA #REQUIRED
   targetProject CDATA #REQUIRED>
 

Added: ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/AbstractGenerator.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/AbstractGenerator.java?rev=703569&view=auto
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/AbstractGenerator.java (added)
+++ ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/AbstractGenerator.java Fri Oct 10 13:08:10 2008
@@ -0,0 +1,34 @@
+/*
+ *  Copyright 2008 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.generator;
+
+import java.util.List;
+
+import org.apache.ibatis.ibator.api.IntrospectedTable;
+import org.apache.ibatis.ibator.api.ProgressCallback;
+import org.apache.ibatis.ibator.config.IbatorContext;
+
+/**
+ * 
+ * @author Jeff Butler
+ *
+ */
+public interface AbstractGenerator {
+    void setIbatorContext(IbatorContext ibatorContext);
+    void setIntrospectedTable(IntrospectedTable introspectedTable);
+    void setWarnings(List<String> warnings);
+    void setProgressCallback(ProgressCallback progressCallback);
+}

Added: ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/AbstractGeneratorImpl.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/AbstractGeneratorImpl.java?rev=703569&view=auto
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/AbstractGeneratorImpl.java (added)
+++ ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/AbstractGeneratorImpl.java Fri Oct 10 13:08:10 2008
@@ -0,0 +1,71 @@
+/*
+ *  Copyright 2008 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.generator;
+
+import java.util.List;
+
+import org.apache.ibatis.ibator.api.IntrospectedTable;
+import org.apache.ibatis.ibator.api.ProgressCallback;
+import org.apache.ibatis.ibator.config.IbatorContext;
+
+/**
+ * 
+ * @author Jeff Butler
+ *
+ */
+public abstract class AbstractGeneratorImpl implements AbstractGenerator {
+    
+    protected IbatorContext ibatorContext;
+    protected IntrospectedTable introspectedTable;
+    protected List<String> warnings;
+    protected ProgressCallback progressCallback;
+
+    public AbstractGeneratorImpl() {
+        super();
+    }
+
+    public IbatorContext getIbatorContext() {
+        return ibatorContext;
+    }
+
+    public void setIbatorContext(IbatorContext ibatorContext) {
+        this.ibatorContext = ibatorContext;
+    }
+
+    public IntrospectedTable getIntrospectedTable() {
+        return introspectedTable;
+    }
+
+    public void setIntrospectedTable(IntrospectedTable introspectedTable) {
+        this.introspectedTable = introspectedTable;
+    }
+
+    public List<String> getWarnings() {
+        return warnings;
+    }
+
+    public void setWarnings(List<String> warnings) {
+        this.warnings = warnings;
+    }
+
+    public ProgressCallback getProgressCallback() {
+        return progressCallback;
+    }
+
+    public void setProgressCallback(ProgressCallback progressCallback) {
+        this.progressCallback = progressCallback;
+    }
+}

Added: ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/JavaGenerator.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/JavaGenerator.java?rev=703569&view=auto
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/JavaGenerator.java (added)
+++ ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/JavaGenerator.java Fri Oct 10 13:08:10 2008
@@ -0,0 +1,30 @@
+/*
+ *  Copyright 2008 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.generator;
+
+import java.util.List;
+
+import org.apache.ibatis.ibator.api.dom.java.CompilationUnit;
+
+/**
+ * 
+ * @author Jeff Butler
+ *
+ */
+public interface JavaGenerator extends AbstractGenerator {
+    List<CompilationUnit> getCompilationUnits();
+    int getNumberOfSubtasks();
+}

Added: ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/XmlGenerator.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/XmlGenerator.java?rev=703569&view=auto
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/XmlGenerator.java (added)
+++ ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/XmlGenerator.java Fri Oct 10 13:08:10 2008
@@ -0,0 +1,28 @@
+/*
+ *  Copyright 2008 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.generator;
+
+import org.apache.ibatis.ibator.api.dom.xml.Document;
+
+/**
+ * 
+ * @author Jeff Butler
+ *
+ */
+public interface XmlGenerator extends AbstractGenerator {
+    Document getDocument();
+    int getNumberOfSubtasks();
+}

Added: ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/IntrospectedTableIbatis2Impl.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/IntrospectedTableIbatis2Impl.java?rev=703569&view=auto
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/IntrospectedTableIbatis2Impl.java (added)
+++ ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/IntrospectedTableIbatis2Impl.java Fri Oct 10 13:08:10 2008
@@ -0,0 +1,189 @@
+/*
+ *  Copyright 2008 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.generator.ibatis2;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.ibatis.ibator.api.GeneratedJavaFile;
+import org.apache.ibatis.ibator.api.GeneratedXmlFile;
+import org.apache.ibatis.ibator.api.IntrospectedTable;
+import org.apache.ibatis.ibator.api.ProgressCallback;
+import org.apache.ibatis.ibator.api.dom.java.CompilationUnit;
+import org.apache.ibatis.ibator.api.dom.xml.Document;
+import org.apache.ibatis.ibator.generator.AbstractGenerator;
+import org.apache.ibatis.ibator.generator.JavaGenerator;
+import org.apache.ibatis.ibator.generator.XmlGenerator;
+import org.apache.ibatis.ibator.generator.ibatis2.dao.DAOGenerator;
+import org.apache.ibatis.ibator.generator.ibatis2.dao.templates.AbstractDAOTemplate;
+import org.apache.ibatis.ibator.generator.ibatis2.dao.templates.GenericCIDAOTemplate;
+import org.apache.ibatis.ibator.generator.ibatis2.dao.templates.GenericSIDAOTemplate;
+import org.apache.ibatis.ibator.generator.ibatis2.dao.templates.IbatisDAOTemplate;
+import org.apache.ibatis.ibator.generator.ibatis2.dao.templates.SpringDAOTemplate;
+import org.apache.ibatis.ibator.generator.ibatis2.model.BaseRecordGenerator;
+import org.apache.ibatis.ibator.generator.ibatis2.model.ExampleGenerator;
+import org.apache.ibatis.ibator.generator.ibatis2.model.PrimaryKeyGenerator;
+import org.apache.ibatis.ibator.generator.ibatis2.model.RecordWithBLOBsGenerator;
+import org.apache.ibatis.ibator.generator.ibatis2.sqlmap.SqlMapGenerator;
+import org.apache.ibatis.ibator.internal.IbatorObjectFactory;
+
+/**
+ * 
+ * @author Jeff Butler
+ *
+ */
+public class IntrospectedTableIbatis2Impl extends IntrospectedTable {
+    protected List<JavaGenerator> javaModelGenerators;
+    protected List<JavaGenerator> daoGenerators;
+    protected XmlGenerator sqlMapGenerator;
+
+    public IntrospectedTableIbatis2Impl() {
+        super();
+        javaModelGenerators = new ArrayList<JavaGenerator>();
+        daoGenerators = new ArrayList<JavaGenerator>();
+    }
+
+    @Override
+    public void calculateGenerators(List<String> warnings, ProgressCallback progressCallback) {
+        calculateJavaModelGenerators(warnings, progressCallback);
+        calculateDAOGenerators(warnings, progressCallback);
+        calculateSqlMapGenerator(warnings, progressCallback);
+    }
+    
+    protected void calculateSqlMapGenerator(List<String> warnings, ProgressCallback progressCallback) {
+        sqlMapGenerator = new SqlMapGenerator();
+        initializeAbstractGenerator(sqlMapGenerator, warnings, progressCallback);
+    }
+    
+    protected void calculateDAOGenerators(List<String> warnings, ProgressCallback progressCallback) {
+        if (ibatorContext.getDaoGeneratorConfiguration() == null) {
+            return;
+        }
+        
+        String type = ibatorContext.getDaoGeneratorConfiguration().getConfigurationType();
+        
+        AbstractDAOTemplate abstractDAOTemplate;
+        if ("IBATIS".equalsIgnoreCase(type)) {
+            abstractDAOTemplate = new IbatisDAOTemplate();
+        } else if ("SPRING".equalsIgnoreCase(type)) {
+            abstractDAOTemplate = new SpringDAOTemplate();
+        } else if ("GENERIC-CI".equalsIgnoreCase(type)) {
+            abstractDAOTemplate = new GenericCIDAOTemplate();
+        } else if ("GENERIC-SI".equalsIgnoreCase(type)) {
+            abstractDAOTemplate = new GenericSIDAOTemplate();
+        } else {
+            // TODO - document this as a way to supply custom template for DAOs
+            abstractDAOTemplate = (AbstractDAOTemplate) IbatorObjectFactory.createObject(type);
+        }
+
+        boolean generateForJava5 = "Java5".equalsIgnoreCase(ibatorContext.getTargetJRE());
+        JavaGenerator javaGenerator = new DAOGenerator(abstractDAOTemplate, generateForJava5);
+        initializeAbstractGenerator(javaGenerator, warnings, progressCallback);
+        daoGenerators.add(javaGenerator);
+    }
+    
+    protected void calculateJavaModelGenerators(List<String> warnings, ProgressCallback progressCallback) {
+        boolean generateForJava5 = "Java5".equalsIgnoreCase(ibatorContext.getTargetJRE());
+        
+        if (getRules().generateExampleClass()) {
+            JavaGenerator javaGenerator = new ExampleGenerator(generateForJava5);
+            initializeAbstractGenerator(javaGenerator, warnings, progressCallback);
+            javaModelGenerators.add(javaGenerator);
+        }
+        
+        if (getRules().generatePrimaryKeyClass()) {
+            JavaGenerator javaGenerator = new PrimaryKeyGenerator();
+            initializeAbstractGenerator(javaGenerator, warnings, progressCallback);
+            javaModelGenerators.add(javaGenerator);
+        }
+        
+        if (getRules().generateBaseRecordClass()) {
+            JavaGenerator javaGenerator = new BaseRecordGenerator();
+            initializeAbstractGenerator(javaGenerator, warnings, progressCallback);
+            javaModelGenerators.add(javaGenerator);
+        }
+        
+        if (getRules().generateRecordWithBLOBsClass()) {
+            JavaGenerator javaGenerator = new RecordWithBLOBsGenerator();
+            initializeAbstractGenerator(javaGenerator, warnings, progressCallback);
+            javaModelGenerators.add(javaGenerator);
+        }
+    }
+    
+    protected void initializeAbstractGenerator(AbstractGenerator abstractGenerator, List<String> warnings, ProgressCallback progressCallback) {
+        abstractGenerator.setIbatorContext(ibatorContext);
+        abstractGenerator.setIntrospectedTable(this);
+        abstractGenerator.setProgressCallback(progressCallback);
+        abstractGenerator.setWarnings(warnings);
+    }
+    
+    @Override
+    public List<GeneratedJavaFile> getGeneratedJavaFiles() {
+        List<GeneratedJavaFile> answer = new ArrayList<GeneratedJavaFile>();
+        
+        for (JavaGenerator javaGenerator : javaModelGenerators) {
+            List<CompilationUnit> compilationUnits = javaGenerator.getCompilationUnits();
+            for (CompilationUnit compilationUnit : compilationUnits) {
+                GeneratedJavaFile gjf = new GeneratedJavaFile(compilationUnit, ibatorContext.getJavaModelGeneratorConfiguration().getTargetProject());
+                answer.add(gjf);
+            }
+        }
+        
+        for (JavaGenerator javaGenerator : daoGenerators) {
+            List<CompilationUnit> compilationUnits = javaGenerator.getCompilationUnits();
+            for (CompilationUnit compilationUnit : compilationUnits) {
+                GeneratedJavaFile gjf = new GeneratedJavaFile(compilationUnit, ibatorContext.getDaoGeneratorConfiguration().getTargetProject());
+                answer.add(gjf);
+            }
+        }
+        
+        return answer;
+    }
+
+    @Override
+    public List<GeneratedXmlFile> getGeneratedXmlFiles() {
+        List<GeneratedXmlFile> answer = new ArrayList<GeneratedXmlFile>();
+        
+        Document document = sqlMapGenerator.getDocument();
+        GeneratedXmlFile gxf = new GeneratedXmlFile(document,
+            getSqlMapFileName(),
+            getSqlMapPackage(),
+            ibatorContext.getSqlMapGeneratorConfiguration().getTargetProject(),
+            true);
+        if (ibatorContext.getPlugins().sqlMapGenerated(gxf, this)) {
+            answer.add(gxf);
+        }
+        
+        return answer;
+    }
+
+    @Override
+    public int getNumberOfSubtasks() {
+        int answer = 0;
+        
+        for (JavaGenerator javaGenerator : javaModelGenerators) {
+            answer += javaGenerator.getNumberOfSubtasks();
+        }
+        
+        for (JavaGenerator javaGenerator : daoGenerators) {
+            answer += javaGenerator.getNumberOfSubtasks();
+        }
+        
+        answer += sqlMapGenerator.getNumberOfSubtasks();
+        
+        return answer;
+    }
+}

Added: ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/XmlConstants.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/XmlConstants.java?rev=703569&view=auto
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/XmlConstants.java (added)
+++ ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/XmlConstants.java Fri Oct 10 13:08:10 2008
@@ -0,0 +1,165 @@
+/*
+ *  Copyright 2005 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.generator.ibatis2;
+
+import org.apache.ibatis.ibator.config.MergeConstants;
+
+/**
+ * @author Jeff Butler
+ */
+public class XmlConstants {
+
+    /**
+     * Utility Class, no instances
+     */
+    private XmlConstants() {
+        super();
+    }
+    
+    static {
+        StringBuilder sb = new StringBuilder();
+
+        sb.append(MergeConstants.NEW_XML_ELEMENT_PREFIX);
+        sb.append("countByExample"); //$NON-NLS-1$
+        COUNT_BY_EXAMPLE_STATEMENT_ID = sb.toString();
+
+        sb.setLength(0);
+        sb.append(MergeConstants.NEW_XML_ELEMENT_PREFIX);
+        sb.append("deleteByExample"); //$NON-NLS-1$
+        DELETE_BY_EXAMPLE_STATEMENT_ID = sb.toString();
+        
+        sb.setLength(0);
+        sb.append(MergeConstants.NEW_XML_ELEMENT_PREFIX);
+        sb.append("deleteByPrimaryKey"); //$NON-NLS-1$
+        DELETE_BY_PRIMARY_KEY_STATEMENT_ID = sb.toString();
+        
+        sb.setLength(0);
+        sb.append(MergeConstants.NEW_XML_ELEMENT_PREFIX);
+        sb.append("insert"); //$NON-NLS-1$
+        INSERT_STATEMENT_ID = sb.toString();
+        
+        sb.setLength(0);
+        sb.append(MergeConstants.NEW_XML_ELEMENT_PREFIX);
+        sb.append("insertSelective"); //$NON-NLS-1$
+        INSERT_SELECTIVE_STATEMENT_ID = sb.toString();
+        
+        sb.setLength(0);
+        sb.append(MergeConstants.NEW_XML_ELEMENT_PREFIX);
+        sb.append("selectByExample"); //$NON-NLS-1$
+        SELECT_BY_EXAMPLE_STATEMENT_ID = sb.toString();
+
+        sb.setLength(0);
+        sb.append(MergeConstants.NEW_XML_ELEMENT_PREFIX);
+        sb.append("selectByExampleWithBLOBs"); //$NON-NLS-1$
+        SELECT_BY_EXAMPLE_WITH_BLOBS_STATEMENT_ID = sb.toString();
+
+        sb.setLength(0);
+        sb.append(MergeConstants.NEW_XML_ELEMENT_PREFIX);
+        sb.append("selectByPrimaryKey"); //$NON-NLS-1$
+        SELECT_BY_PRIMARY_KEY_STATEMENT_ID = sb.toString();
+
+        sb.setLength(0);
+        sb.append(MergeConstants.NEW_XML_ELEMENT_PREFIX);
+        sb.append("updateByExample"); //$NON-NLS-1$
+        UPDATE_BY_EXAMPLE_STATEMENT_ID = sb.toString();
+
+        sb.setLength(0);
+        sb.append(MergeConstants.NEW_XML_ELEMENT_PREFIX);
+        sb.append("updateByExampleSelective"); //$NON-NLS-1$
+        UPDATE_BY_EXAMPLE_SELECTIVE_STATEMENT_ID = sb.toString();
+
+        sb.setLength(0);
+        sb.append(MergeConstants.NEW_XML_ELEMENT_PREFIX);
+        sb.append("updateByExampleWithBLOBs"); //$NON-NLS-1$
+        UPDATE_BY_EXAMPLE_WITH_BLOBS_STATEMENT_ID = sb.toString();
+
+        sb.setLength(0);
+        sb.append(MergeConstants.NEW_XML_ELEMENT_PREFIX);
+        sb.append("updateByPrimaryKey"); //$NON-NLS-1$
+        UPDATE_BY_PRIMARY_KEY_STATEMENT_ID = sb.toString();
+
+        sb.setLength(0);
+        sb.append(MergeConstants.NEW_XML_ELEMENT_PREFIX);
+        sb.append("updateByPrimaryKeySelective"); //$NON-NLS-1$
+        UPDATE_BY_PRIMARY_KEY_SELECTIVE_STATEMENT_ID = sb.toString();
+
+        sb.setLength(0);
+        sb.append(MergeConstants.NEW_XML_ELEMENT_PREFIX);
+        sb.append("updateByPrimaryKeyWithBLOBs"); //$NON-NLS-1$
+        UPDATE_BY_PRIMARY_KEY_WITH_BLOBS_STATEMENT_ID = sb.toString();
+
+        sb.setLength(0);
+        sb.append(MergeConstants.NEW_XML_ELEMENT_PREFIX);
+        sb.append("BaseResultMap"); //$NON-NLS-1$
+        BASE_RESULT_MAP_ID = sb.toString();
+
+        sb.setLength(0);
+        sb.append(MergeConstants.NEW_XML_ELEMENT_PREFIX);
+        sb.append("ResultMapWithBLOBs"); //$NON-NLS-1$
+        RESULT_MAP_WITH_BLOBS_ID = sb.toString();
+
+        sb.setLength(0);
+        sb.append(MergeConstants.NEW_XML_ELEMENT_PREFIX);
+        sb.append("Example_Where_Clause"); //$NON-NLS-1$
+        EXAMPLE_WHERE_CLAUSE_ID = sb.toString();
+    }
+
+    public static final String SQL_MAP_SYSTEM_ID = "http://ibatis.apache.org/dtd/sql-map-2.dtd"; //$NON-NLS-1$
+
+    public static final String SQL_MAP_PUBLIC_ID = "-//ibatis.apache.org//DTD SQL Map 2.0//EN"; //$NON-NLS-1$
+    
+    public static final String SQL_MAP_CONFIG_SYSTEM_ID = "http://ibatis.apache.org/dtd/sql-map-config-2.dtd"; //$NON-NLS-1$
+
+    public static final String SQL_MAP_CONFIG_PUBLIC_ID = "-//ibatis.apache.org//DTD SQL Map Config 2.0//EN"; //$NON-NLS-1$
+    
+    public static final String IBATOR_CONFIG_SYSTEM_ID = "http://ibatis.apache.org/dtd/ibator-config_1_0.dtd"; //$NON-NLS-1$
+    
+    public static final String IBATOR_CONFIG_PUBLIC_ID = "-//Apache Software Foundation//DTD Apache iBATIS ibator Configuration 1.0//EN"; //$NON-NLS-1$
+    
+    public static final String COUNT_BY_EXAMPLE_STATEMENT_ID;
+    
+    public static final String DELETE_BY_EXAMPLE_STATEMENT_ID;
+    
+    public static final String DELETE_BY_PRIMARY_KEY_STATEMENT_ID;
+    
+    public static final String INSERT_STATEMENT_ID;
+    
+    public static final String INSERT_SELECTIVE_STATEMENT_ID;
+    
+    public static final String SELECT_BY_EXAMPLE_STATEMENT_ID;
+    
+    public static final String SELECT_BY_EXAMPLE_WITH_BLOBS_STATEMENT_ID;
+    
+    public static final String SELECT_BY_PRIMARY_KEY_STATEMENT_ID;
+    
+    public static final String UPDATE_BY_EXAMPLE_STATEMENT_ID;
+
+    public static final String UPDATE_BY_EXAMPLE_SELECTIVE_STATEMENT_ID;
+
+    public static final String UPDATE_BY_EXAMPLE_WITH_BLOBS_STATEMENT_ID;
+
+    public static final String UPDATE_BY_PRIMARY_KEY_STATEMENT_ID;
+    
+    public static final String UPDATE_BY_PRIMARY_KEY_SELECTIVE_STATEMENT_ID;
+
+    public static final String UPDATE_BY_PRIMARY_KEY_WITH_BLOBS_STATEMENT_ID;
+
+    public static final String BASE_RESULT_MAP_ID;
+
+    public static final String RESULT_MAP_WITH_BLOBS_ID;
+    
+    public static final String EXAMPLE_WHERE_CLAUSE_ID;
+}

Added: ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/dao/DAOGenerator.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/dao/DAOGenerator.java?rev=703569&view=auto
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/dao/DAOGenerator.java (added)
+++ ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/dao/DAOGenerator.java Fri Oct 10 13:08:10 2008
@@ -0,0 +1,286 @@
+/*
+ *  Copyright 2008 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.generator.ibatis2.dao;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.ibatis.ibator.api.CommentGenerator;
+import org.apache.ibatis.ibator.api.FullyQualifiedTable;
+import org.apache.ibatis.ibator.api.dom.java.CompilationUnit;
+import org.apache.ibatis.ibator.api.dom.java.Field;
+import org.apache.ibatis.ibator.api.dom.java.FullyQualifiedJavaType;
+import org.apache.ibatis.ibator.api.dom.java.Interface;
+import org.apache.ibatis.ibator.api.dom.java.JavaVisibility;
+import org.apache.ibatis.ibator.api.dom.java.Method;
+import org.apache.ibatis.ibator.api.dom.java.TopLevelClass;
+import org.apache.ibatis.ibator.config.PropertyRegistry;
+import org.apache.ibatis.ibator.generator.AbstractGeneratorImpl;
+import org.apache.ibatis.ibator.generator.JavaGenerator;
+import org.apache.ibatis.ibator.generator.ibatis2.dao.elements.CountByExampleMethodGenerator;
+import org.apache.ibatis.ibator.generator.ibatis2.dao.elements.DAOElementGenerator;
+import org.apache.ibatis.ibator.generator.ibatis2.dao.elements.DeleteByExampleMethodGenerator;
+import org.apache.ibatis.ibator.generator.ibatis2.dao.elements.DeleteByPrimaryKeyMethodGenerator;
+import org.apache.ibatis.ibator.generator.ibatis2.dao.elements.InsertMethodGenerator;
+import org.apache.ibatis.ibator.generator.ibatis2.dao.elements.InsertSelectiveMethodGenerator;
+import org.apache.ibatis.ibator.generator.ibatis2.dao.elements.SelectByExampleWithBLOBsMethodGenerator;
+import org.apache.ibatis.ibator.generator.ibatis2.dao.elements.SelectByExampleWithoutBLOBsMethodGenerator;
+import org.apache.ibatis.ibator.generator.ibatis2.dao.elements.SelectByPrimaryKeyMethodGenerator;
+import org.apache.ibatis.ibator.generator.ibatis2.dao.elements.UpdateByExampleParmsInnerclassGenerator;
+import org.apache.ibatis.ibator.generator.ibatis2.dao.elements.UpdateByExampleSelectiveMethodGenerator;
+import org.apache.ibatis.ibator.generator.ibatis2.dao.elements.UpdateByExampleWithBLOBsMethodGenerator;
+import org.apache.ibatis.ibator.generator.ibatis2.dao.elements.UpdateByExampleWithoutBLOBsMethodGenerator;
+import org.apache.ibatis.ibator.generator.ibatis2.dao.elements.UpdateByPrimaryKeySelectiveMethodGenerator;
+import org.apache.ibatis.ibator.generator.ibatis2.dao.elements.UpdateByPrimaryKeyWithBLOBsMethodGenerator;
+import org.apache.ibatis.ibator.generator.ibatis2.dao.elements.UpdateByPrimaryKeyWithoutBLOBsMethodGenerator;
+import org.apache.ibatis.ibator.generator.ibatis2.dao.templates.AbstractDAOTemplate;
+import org.apache.ibatis.ibator.internal.rules.IbatorRules;
+import org.apache.ibatis.ibator.internal.util.StringUtility;
+import org.apache.ibatis.ibator.internal.util.messages.Messages;
+
+/**
+ * 
+ * @author Jeff Butler
+ *
+ */
+public class DAOGenerator extends AbstractGeneratorImpl implements JavaGenerator {
+    
+    private AbstractDAOTemplate daoTemplate;
+    private boolean generateForJava5;
+
+    public DAOGenerator(AbstractDAOTemplate daoTemplate, boolean generateForJava5) {
+        super();
+        this.daoTemplate = daoTemplate;
+        this.generateForJava5 = generateForJava5;
+    }
+    
+    public List<CompilationUnit> getCompilationUnits() {
+        FullyQualifiedTable table = introspectedTable.getFullyQualifiedTable();
+        progressCallback.startSubTask(Messages.getString("Progress.14", table.toString()));
+        TopLevelClass topLevelClass = getTopLevelClassShell();
+        Interface interfaze = getInterfaceShell();
+        
+        addCountByExampleMethod(topLevelClass, interfaze);
+        addDeleteByExampleMethod(topLevelClass, interfaze);
+        addDeleteByPrimaryKeyMethod(topLevelClass, interfaze);
+        addInsertMethod(topLevelClass, interfaze);
+        addInsertSelectiveMethod(topLevelClass, interfaze);
+        addSelectByExampleWithBLOBsMethod(topLevelClass, interfaze);
+        addSelectByExampleWithoutBLOBsMethod(topLevelClass, interfaze);
+        addSelectByPrimaryKeyMethod(topLevelClass, interfaze);
+        addUpdateByExampleParmsInnerclass(topLevelClass, interfaze);
+        addUpdateByExampleSelectiveMethod(topLevelClass, interfaze);
+        addUpdateByExampleWithBLOBsMethod(topLevelClass, interfaze);
+        addUpdateByExampleWithoutBLOBsMethod(topLevelClass, interfaze);
+        addUpdateByPrimaryKeySelectiveMethod(topLevelClass, interfaze);
+        addUpdateByPrimaryKeyWithBLOBsMethod(topLevelClass, interfaze);
+        addUpdateByPrimaryKeyWithoutBLOBsMethod(topLevelClass, interfaze);
+        
+        List<CompilationUnit> answer = new ArrayList<CompilationUnit>();
+        if (ibatorContext.getPlugins().daoImplementationGenerated(topLevelClass, introspectedTable)) {
+            answer.add(topLevelClass);
+        }
+        
+        if (ibatorContext.getPlugins().daoInterfaceGenerated(interfaze, introspectedTable)) {
+            answer.add(interfaze);
+        }
+
+        return answer;
+    }
+    
+    protected TopLevelClass getTopLevelClassShell() {
+        FullyQualifiedJavaType interfaceType = introspectedTable.getDAOInterfaceType();
+        FullyQualifiedJavaType implementationType = introspectedTable.getDAOImplementationType();
+        
+        CommentGenerator commentGenerator = ibatorContext.getCommentGenerator();
+        
+        FullyQualifiedTable table = introspectedTable.getFullyQualifiedTable();
+        TopLevelClass answer = new TopLevelClass(implementationType);
+        answer.setVisibility(JavaVisibility.PUBLIC);
+        answer.setSuperClass(daoTemplate.getSuperClass());
+        answer.addImportedType(daoTemplate.getSuperClass());
+        answer.addSuperInterface(interfaceType);
+        answer.addImportedType(interfaceType);
+
+        for (FullyQualifiedJavaType fqjt : daoTemplate.getImplementationImports()) {
+            answer.addImportedType(fqjt);
+        }
+        
+        commentGenerator.addJavaFileComment(answer);
+
+        // add constructor from the template
+        answer.addMethod(daoTemplate.getConstructorClone(commentGenerator,
+                implementationType, table));
+
+        // add any fields from the template
+        for (Field field : daoTemplate.getFieldClones(commentGenerator, table)) {
+            answer.addField(field);
+        }
+
+        // add any methods from the template
+        for (Method method : daoTemplate.getMethodClones(commentGenerator, table)) {
+            answer.addMethod(method);
+        }
+        
+        return answer;
+    }
+    
+    protected Interface getInterfaceShell() {
+        Interface answer = new Interface(introspectedTable.getDAOInterfaceType());
+        answer.setVisibility(JavaVisibility.PUBLIC);
+
+        String rootInterface = introspectedTable.getTableConfigurationProperty(PropertyRegistry.ANY_ROOT_INTERFACE);
+        if (rootInterface == null) {
+            rootInterface = ibatorContext.getDaoGeneratorConfiguration().getProperty(PropertyRegistry.ANY_ROOT_INTERFACE);
+        }
+        
+        if (StringUtility.stringHasValue(rootInterface)) {
+            FullyQualifiedJavaType fqjt = new FullyQualifiedJavaType(rootInterface);
+            answer.addSuperInterface(fqjt);
+            answer.addImportedType(fqjt);
+        }
+
+        for (FullyQualifiedJavaType fqjt : daoTemplate.getInterfaceImports()) {
+            answer.addImportedType(fqjt);
+        }
+
+        ibatorContext.getCommentGenerator().addJavaFileComment(answer);
+
+        return answer;
+    }
+    
+    protected void addCountByExampleMethod(TopLevelClass topLevelClass, Interface interfaze) {
+        if (introspectedTable.getRules().generateCountByExample()) {
+            DAOElementGenerator methodGenerator = new CountByExampleMethodGenerator(generateForJava5);
+            initializeAndExecuteGenerator(methodGenerator, topLevelClass, interfaze);
+        }
+    }
+    
+    protected void addDeleteByExampleMethod(TopLevelClass topLevelClass, Interface interfaze) {
+        if (introspectedTable.getRules().generateDeleteByExample()) {
+            DAOElementGenerator methodGenerator = new DeleteByExampleMethodGenerator();
+            initializeAndExecuteGenerator(methodGenerator, topLevelClass, interfaze);
+        }
+    }
+    
+    protected void addDeleteByPrimaryKeyMethod(TopLevelClass topLevelClass, Interface interfaze) {
+        if (introspectedTable.getRules().generateDeleteByPrimaryKey()) {
+            DAOElementGenerator methodGenerator = new DeleteByPrimaryKeyMethodGenerator();
+            initializeAndExecuteGenerator(methodGenerator, topLevelClass, interfaze);
+        }
+    }
+    
+    protected void addInsertMethod(TopLevelClass topLevelClass, Interface interfaze) {
+        if (introspectedTable.getRules().generateInsert()) {
+            DAOElementGenerator methodGenerator = new InsertMethodGenerator();
+            initializeAndExecuteGenerator(methodGenerator, topLevelClass, interfaze);
+        }
+    }
+    
+    protected void addInsertSelectiveMethod(TopLevelClass topLevelClass, Interface interfaze) {
+        if (introspectedTable.getRules().generateInsertSelective()) {
+            DAOElementGenerator methodGenerator = new InsertSelectiveMethodGenerator();
+            initializeAndExecuteGenerator(methodGenerator, topLevelClass, interfaze);
+        }
+    }
+    
+    protected void addSelectByExampleWithBLOBsMethod(TopLevelClass topLevelClass, Interface interfaze) {
+        if (introspectedTable.getRules().generateSelectByExampleWithBLOBs()) {
+            DAOElementGenerator methodGenerator = new SelectByExampleWithBLOBsMethodGenerator(generateForJava5);
+            initializeAndExecuteGenerator(methodGenerator, topLevelClass, interfaze);
+        }
+    }
+    
+    protected void addSelectByExampleWithoutBLOBsMethod(TopLevelClass topLevelClass, Interface interfaze) {
+        if (introspectedTable.getRules().generateSelectByExampleWithoutBLOBs()) {
+            DAOElementGenerator methodGenerator = new SelectByExampleWithoutBLOBsMethodGenerator(generateForJava5);
+            initializeAndExecuteGenerator(methodGenerator, topLevelClass, interfaze);
+        }
+    }
+    
+    protected void addSelectByPrimaryKeyMethod(TopLevelClass topLevelClass, Interface interfaze) {
+        if (introspectedTable.getRules().generateSelectByPrimaryKey()) {
+            DAOElementGenerator methodGenerator = new SelectByPrimaryKeyMethodGenerator();
+            initializeAndExecuteGenerator(methodGenerator, topLevelClass, interfaze);
+        }
+    }
+    
+    protected void addUpdateByExampleParmsInnerclass(TopLevelClass topLevelClass, Interface interfaze) {
+        IbatorRules ibatorRules = introspectedTable.getRules();
+        if (ibatorRules.generateUpdateByExampleSelective()
+                || ibatorRules.generateUpdateByExampleWithBLOBs()
+                || ibatorRules.generateUpdateByExampleWithoutBLOBs()) {
+            DAOElementGenerator methodGenerator = new UpdateByExampleParmsInnerclassGenerator();
+            initializeAndExecuteGenerator(methodGenerator, topLevelClass, interfaze);
+        }
+    }
+    
+    protected void addUpdateByExampleSelectiveMethod(TopLevelClass topLevelClass, Interface interfaze) {
+        if (introspectedTable.getRules().generateUpdateByExampleSelective()) {
+            DAOElementGenerator methodGenerator = new UpdateByExampleSelectiveMethodGenerator();
+            initializeAndExecuteGenerator(methodGenerator, topLevelClass, interfaze);
+        }
+    }
+    
+    protected void addUpdateByExampleWithBLOBsMethod(TopLevelClass topLevelClass, Interface interfaze) {
+        if (introspectedTable.getRules().generateUpdateByExampleWithBLOBs()) {
+            DAOElementGenerator methodGenerator = new UpdateByExampleWithBLOBsMethodGenerator();
+            initializeAndExecuteGenerator(methodGenerator, topLevelClass, interfaze);
+        }
+    }
+    
+    protected void addUpdateByExampleWithoutBLOBsMethod(TopLevelClass topLevelClass, Interface interfaze) {
+        if (introspectedTable.getRules().generateUpdateByExampleWithoutBLOBs()) {
+            DAOElementGenerator methodGenerator = new UpdateByExampleWithoutBLOBsMethodGenerator();
+            initializeAndExecuteGenerator(methodGenerator, topLevelClass, interfaze);
+        }
+    }
+    
+    protected void addUpdateByPrimaryKeySelectiveMethod(TopLevelClass topLevelClass, Interface interfaze) {
+        if (introspectedTable.getRules().generateUpdateByPrimaryKeySelective()) {
+            DAOElementGenerator methodGenerator = new UpdateByPrimaryKeySelectiveMethodGenerator();
+            initializeAndExecuteGenerator(methodGenerator, topLevelClass, interfaze);
+        }
+    }
+    
+    protected void addUpdateByPrimaryKeyWithBLOBsMethod(TopLevelClass topLevelClass, Interface interfaze) {
+        if (introspectedTable.getRules().generateUpdateByPrimaryKeyWithBLOBs()) {
+            DAOElementGenerator methodGenerator = new UpdateByPrimaryKeyWithBLOBsMethodGenerator();
+            initializeAndExecuteGenerator(methodGenerator, topLevelClass, interfaze);
+        }
+    }
+    
+    protected void addUpdateByPrimaryKeyWithoutBLOBsMethod(TopLevelClass topLevelClass, Interface interfaze) {
+        if (introspectedTable.getRules().generateUpdateByPrimaryKeyWithoutBLOBs()) {
+            DAOElementGenerator methodGenerator = new UpdateByPrimaryKeyWithoutBLOBsMethodGenerator();
+            initializeAndExecuteGenerator(methodGenerator, topLevelClass, interfaze);
+        }
+    }
+    
+    protected void initializeAndExecuteGenerator(DAOElementGenerator methodGenerator, TopLevelClass topLevelClass, Interface interfaze) {
+        methodGenerator.setDAOTemplate(daoTemplate);
+        methodGenerator.setIbatorContext(ibatorContext);
+        methodGenerator.setIntrospectedTable(introspectedTable);
+        methodGenerator.setProgressCallback(progressCallback);
+        methodGenerator.setWarnings(warnings);
+        methodGenerator.addImplementationElements(topLevelClass);
+        methodGenerator.addInterfaceElements(interfaze);
+    }
+
+    public int getNumberOfSubtasks() {
+        return 1;
+    }
+}

Added: ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/dao/elements/CountByExampleMethodGenerator.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/dao/elements/CountByExampleMethodGenerator.java?rev=703569&view=auto
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/dao/elements/CountByExampleMethodGenerator.java (added)
+++ ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/dao/elements/CountByExampleMethodGenerator.java Fri Oct 10 13:08:10 2008
@@ -0,0 +1,104 @@
+/*
+ *  Copyright 2008 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.generator.ibatis2.dao.elements;
+
+import java.util.Set;
+import java.util.TreeSet;
+
+import org.apache.ibatis.ibator.api.FullyQualifiedTable;
+import org.apache.ibatis.ibator.api.dom.java.FullyQualifiedJavaType;
+import org.apache.ibatis.ibator.api.dom.java.Interface;
+import org.apache.ibatis.ibator.api.dom.java.JavaVisibility;
+import org.apache.ibatis.ibator.api.dom.java.Method;
+import org.apache.ibatis.ibator.api.dom.java.Parameter;
+import org.apache.ibatis.ibator.api.dom.java.TopLevelClass;
+import org.apache.ibatis.ibator.generator.ibatis2.XmlConstants;
+
+/**
+ * 
+ * @author Jeff Butler
+ *
+ */
+public class CountByExampleMethodGenerator extends DAOElementGeneratorBaseImpl {
+
+    private boolean generateForJava5;
+    
+    public CountByExampleMethodGenerator(boolean generateForJava5) {
+        super();
+        this.generateForJava5 = generateForJava5;
+    }
+
+    public void addImplementationElements(TopLevelClass topLevelClass) {
+        Set<FullyQualifiedJavaType> importedTypes = new TreeSet<FullyQualifiedJavaType>();
+        Method method = getMethodShell(importedTypes);
+        FullyQualifiedTable table = introspectedTable.getFullyQualifiedTable();
+
+        // generate the implementation method
+        StringBuilder sb = new StringBuilder();
+
+        sb.append("Integer count = (Integer)  "); //$NON-NLS-1$
+        sb.append(daoTemplate.getQueryForObjectMethod(table
+                .getSqlMapNamespace(),
+                XmlConstants.COUNT_BY_EXAMPLE_STATEMENT_ID, "example")); //$NON-NLS-1$
+        method.addBodyLine(sb.toString());
+
+        if (generateForJava5) {
+            method.addBodyLine("return count;"); //$NON-NLS-1$
+        } else {
+            method.addBodyLine("return count.intValue();"); //$NON-NLS-1$
+        }
+        
+        if (ibatorContext.getPlugins().daoCountByExampleMethodGenerated(method, topLevelClass, introspectedTable)) {
+            topLevelClass.addImportedTypes(importedTypes);
+            topLevelClass.addMethod(method);
+        }
+    }
+
+    public void addInterfaceElements(Interface interfaze) {
+        if (getExampleMethodVisibility() == JavaVisibility.PUBLIC) {
+            Set<FullyQualifiedJavaType> importedTypes = new TreeSet<FullyQualifiedJavaType>();
+            Method method = getMethodShell(importedTypes);
+            
+            if (ibatorContext.getPlugins().daoCountByExampleMethodGenerated(method, interfaze, introspectedTable)) {
+                interfaze.addImportedTypes(importedTypes);
+                interfaze.addMethod(method);
+            }
+        }
+    }
+
+    private Method getMethodShell(Set<FullyQualifiedJavaType> importedTypes) {
+        FullyQualifiedTable table = introspectedTable.getFullyQualifiedTable();
+        FullyQualifiedJavaType type = introspectedTable.getExampleType();
+        importedTypes.add(type);
+
+        Method method = new Method();
+        method.setVisibility(getExampleMethodVisibility());
+        method.setReturnType(FullyQualifiedJavaType.getIntInstance());
+        method.setName(getDAOMethodNameCalculator()
+                .getCountByExampleMethodName(introspectedTable));
+        method.addParameter(new Parameter(type, "example")); //$NON-NLS-1$
+
+        for (FullyQualifiedJavaType fqjt : daoTemplate.getCheckedExceptions()) {
+            method.addException(fqjt);
+            importedTypes.add(fqjt);
+        }
+
+        ibatorContext.getCommentGenerator().addGeneralMethodComment(method,
+                table);
+
+        return method;
+    }
+}

Added: ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/dao/elements/DAOElementGenerator.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/dao/elements/DAOElementGenerator.java?rev=703569&view=auto
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/dao/elements/DAOElementGenerator.java (added)
+++ ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/dao/elements/DAOElementGenerator.java Fri Oct 10 13:08:10 2008
@@ -0,0 +1,32 @@
+/*
+ *  Copyright 2008 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.generator.ibatis2.dao.elements;
+
+import org.apache.ibatis.ibator.api.dom.java.Interface;
+import org.apache.ibatis.ibator.api.dom.java.TopLevelClass;
+import org.apache.ibatis.ibator.generator.AbstractGenerator;
+import org.apache.ibatis.ibator.generator.ibatis2.dao.templates.AbstractDAOTemplate;
+
+/**
+ * 
+ * @author Jeff Butler
+ *
+ */
+public interface DAOElementGenerator extends AbstractGenerator {
+    void setDAOTemplate(AbstractDAOTemplate abstractDAOTemplate);
+    void addInterfaceElements(Interface interfaze);
+    void addImplementationElements(TopLevelClass topLevelClass);
+}

Added: ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/dao/elements/DAOElementGeneratorBaseImpl.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/dao/elements/DAOElementGeneratorBaseImpl.java?rev=703569&view=auto
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/dao/elements/DAOElementGeneratorBaseImpl.java (added)
+++ ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/dao/elements/DAOElementGeneratorBaseImpl.java Fri Oct 10 13:08:10 2008
@@ -0,0 +1,98 @@
+/*
+ *  Copyright 2008 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.generator.ibatis2.dao.elements;
+
+import org.apache.ibatis.ibator.api.DAOMethodNameCalculator;
+import org.apache.ibatis.ibator.api.dom.java.JavaVisibility;
+import org.apache.ibatis.ibator.config.PropertyRegistry;
+import org.apache.ibatis.ibator.generator.AbstractGeneratorImpl;
+import org.apache.ibatis.ibator.generator.ibatis2.dao.templates.AbstractDAOTemplate;
+import org.apache.ibatis.ibator.internal.DefaultDAOMethodNameCalculator;
+import org.apache.ibatis.ibator.internal.ExtendedDAOMethodNameCalculator;
+import org.apache.ibatis.ibator.internal.IbatorObjectFactory;
+import org.apache.ibatis.ibator.internal.util.StringUtility;
+import org.apache.ibatis.ibator.internal.util.messages.Messages;
+
+/**
+ * 
+ * @author Jeff Butler
+ *
+ */
+public abstract class DAOElementGeneratorBaseImpl extends AbstractGeneratorImpl implements DAOElementGenerator {
+    
+    protected AbstractDAOTemplate daoTemplate;
+    private DAOMethodNameCalculator dAOMethodNameCalculator;
+    private JavaVisibility exampleMethodVisibility;
+
+    public DAOElementGeneratorBaseImpl() {
+        super();
+    }
+
+    public void setDAOTemplate(AbstractDAOTemplate abstractDAOTemplate) {
+        this.daoTemplate = abstractDAOTemplate;
+    }
+    
+    public DAOMethodNameCalculator getDAOMethodNameCalculator() {
+        if (dAOMethodNameCalculator == null) {
+            String type = ibatorContext.getDaoGeneratorConfiguration().getProperty(
+                    PropertyRegistry.DAO_METHOD_NAME_CALCULATOR);
+            if (StringUtility.stringHasValue(type)) {
+                if ("extended".equalsIgnoreCase(type)) { //$NON-NLS-1$
+                    type = ExtendedDAOMethodNameCalculator.class.getName();
+                } else if ("default".equalsIgnoreCase(type)) { //$NON-NLS-1$
+                    type = DefaultDAOMethodNameCalculator.class.getName();
+                }
+            } else {
+                type = DefaultDAOMethodNameCalculator.class.getName();
+            }
+            
+            try {
+                dAOMethodNameCalculator = (DAOMethodNameCalculator)
+                    IbatorObjectFactory.createObject(type);
+            } catch (Exception e) {
+                dAOMethodNameCalculator = new DefaultDAOMethodNameCalculator();
+                warnings.add(Messages.getString("Warning.17", type, e.getMessage())); //$NON-NLS-1$
+            }
+        }
+        
+        return dAOMethodNameCalculator;
+    }
+    
+    public JavaVisibility getExampleMethodVisibility() {
+        if (exampleMethodVisibility == null) {
+            String type = ibatorContext.getDaoGeneratorConfiguration().getProperty(
+                    PropertyRegistry.DAO_EXAMPLE_METHOD_VISIBILITY);
+            if (StringUtility.stringHasValue(type)) {
+                if ("public".equalsIgnoreCase(type)) { //$NON-NLS-1$
+                    exampleMethodVisibility = JavaVisibility.PUBLIC;
+                } else if ("private".equalsIgnoreCase(type)) { //$NON-NLS-1$
+                    exampleMethodVisibility = JavaVisibility.PRIVATE;
+                } else if ("protected".equalsIgnoreCase(type)) { //$NON-NLS-1$
+                    exampleMethodVisibility = JavaVisibility.PROTECTED;
+                } else if ("default".equalsIgnoreCase(type)) { //$NON-NLS-1$
+                    exampleMethodVisibility = JavaVisibility.DEFAULT;
+                } else {
+                    exampleMethodVisibility = JavaVisibility.PUBLIC;
+                    warnings.add(Messages.getString("Warning.16", type)); //$NON-NLS-1$
+                }
+            } else {
+                exampleMethodVisibility = JavaVisibility.PUBLIC;
+            }
+        }
+        
+        return exampleMethodVisibility;
+    }
+}