org.apache.ibatis.ibator.plugins
Class SqlMapConfigPlugin

java.lang.Object
  extended by org.apache.ibatis.ibator.api.IbatorPluginAdapter
      extended by org.apache.ibatis.ibator.plugins.SqlMapConfigPlugin
All Implemented Interfaces:
IbatorPlugin

public class SqlMapConfigPlugin
extends IbatorPluginAdapter

This plugin generates an SqlMapConfig file containing sqlMap entries for SQL maps generated by ibator. This demonstrates hooking into the ibator code generation lifecycle and generating additional XML files.

This plugin accepts three properties:

Note: targetPackage and targetProject follow the same rules as the targetPackage and targetProject values on the sqlMapGenerator configuration element.

Author:
Jeff Butler

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.apache.ibatis.ibator.api.IbatorPlugin
IbatorPlugin.ModelClassType
 
Field Summary
 
Fields inherited from class org.apache.ibatis.ibator.api.IbatorPluginAdapter
ibatorContext, properties
 
Constructor Summary
SqlMapConfigPlugin()
           
 
Method Summary
 java.util.List<GeneratedXmlFile> contextGenerateAdditionalXmlFiles()
          This method can be used to generate any additional XML file needed by your implementation.
 boolean sqlMapGenerated(GeneratedXmlFile sqlMap, IntrospectedTable introspectedTable)
          This method is called when the SqlMap file has been generated.
 boolean validate(java.util.List<java.lang.String> warnings)
          This method is called after all the setXXX methods are called, but before any other method is called.
 
Methods inherited from class org.apache.ibatis.ibator.api.IbatorPluginAdapter
contextGenerateAdditionalJavaFiles, contextGenerateAdditionalJavaFiles, contextGenerateAdditionalXmlFiles, daoCountByExampleMethodGenerated, daoCountByExampleMethodGenerated, daoDeleteByExampleMethodGenerated, daoDeleteByExampleMethodGenerated, daoDeleteByPrimaryKeyMethodGenerated, daoDeleteByPrimaryKeyMethodGenerated, daoImplementationGenerated, daoInsertMethodGenerated, daoInsertMethodGenerated, daoInsertSelectiveMethodGenerated, daoInsertSelectiveMethodGenerated, daoInterfaceGenerated, daoSelectByExampleWithBLOBsMethodGenerated, daoSelectByExampleWithBLOBsMethodGenerated, daoSelectByExampleWithoutBLOBsMethodGenerated, daoSelectByExampleWithoutBLOBsMethodGenerated, daoSelectByPrimaryKeyMethodGenerated, daoSelectByPrimaryKeyMethodGenerated, daoUpdateByExampleSelectiveMethodGenerated, daoUpdateByExampleSelectiveMethodGenerated, daoUpdateByExampleWithBLOBsMethodGenerated, daoUpdateByExampleWithBLOBsMethodGenerated, daoUpdateByExampleWithoutBLOBsMethodGenerated, daoUpdateByExampleWithoutBLOBsMethodGenerated, daoUpdateByPrimaryKeySelectiveMethodGenerated, daoUpdateByPrimaryKeySelectiveMethodGenerated, daoUpdateByPrimaryKeyWithBLOBsMethodGenerated, daoUpdateByPrimaryKeyWithBLOBsMethodGenerated, daoUpdateByPrimaryKeyWithoutBLOBsMethodGenerated, daoUpdateByPrimaryKeyWithoutBLOBsMethodGenerated, getIbatorContext, getProperties, initialized, modelBaseRecordClassGenerated, modelExampleClassGenerated, modelFieldGenerated, modelGetterMethodGenerated, modelPrimaryKeyClassGenerated, modelRecordWithBLOBsClassGenerated, modelSetterMethodGenerated, setIbatorContext, setProperties, sqlMapCountByExampleElementGenerated, sqlMapDeleteByExampleElementGenerated, sqlMapDeleteByPrimaryKeyElementGenerated, sqlMapDocumentGenerated, sqlMapExampleWhereClauseElementGenerated, sqlMapInsertElementGenerated, sqlMapInsertSelectiveElementGenerated, sqlMapResultMapWithBLOBsElementGenerated, sqlMapResultMapWithoutBLOBsElementGenerated, sqlMapSelectByExampleWithBLOBsElementGenerated, sqlMapSelectByExampleWithoutBLOBsElementGenerated, sqlMapSelectByPrimaryKeyElementGenerated, sqlMapUpdateByExampleSelectiveElementGenerated, sqlMapUpdateByExampleWithBLOBsElementGenerated, sqlMapUpdateByExampleWithoutBLOBsElementGenerated, sqlMapUpdateByPrimaryKeySelectiveElementGenerated, sqlMapUpdateByPrimaryKeyWithBLOBsElementGenerated, sqlMapUpdateByPrimaryKeyWithoutBLOBsElementGenerated
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SqlMapConfigPlugin

public SqlMapConfigPlugin()
Method Detail

validate

public boolean validate(java.util.List<java.lang.String> warnings)
Description copied from interface: IbatorPlugin
This method is called after all the setXXX methods are called, but before any other method is called. This allows the plugin to determine whether it can run or not. For example, if the plugin requires certain properties to be set, and the properties are not set, then the plugin is invalid and will not run.

Parameters:
warnings - add strings to this list to specify warnings. For example, if the plugin is invalid, you should specify why. Warnings are reported to users after the completion of the ibator run.
Returns:
true if the plugin is in a valid state. Invalid plugins will not be called

contextGenerateAdditionalXmlFiles

public java.util.List<GeneratedXmlFile> contextGenerateAdditionalXmlFiles()
Description copied from interface: IbatorPlugin
This method can be used to generate any additional XML file needed by your implementation. This method is called once, after all other XML files have been generated.

Specified by:
contextGenerateAdditionalXmlFiles in interface IbatorPlugin
Overrides:
contextGenerateAdditionalXmlFiles in class IbatorPluginAdapter
Returns:
a List of GeneratedXmlFiles - ibator will persist these files with the other files from this run of ibator.

sqlMapGenerated

public boolean sqlMapGenerated(GeneratedXmlFile sqlMap,
                               IntrospectedTable introspectedTable)
Description copied from interface: IbatorPlugin
This method is called when the SqlMap file has been generated.

Specified by:
sqlMapGenerated in interface IbatorPlugin
Overrides:
sqlMapGenerated in class IbatorPluginAdapter
Parameters:
sqlMap - the generated file (containing the file name, package name, and project name)
introspectedTable - ibator's class containing information about the table as introspected from the database
Returns:
true if the sqlMap should be generated, false if the generated sqlMap should be ignored. In the case of multiple plugins, the first plugin returning false will disable the calling of further plugins.