一、程序入口
1、目前项目中的ibatis是结合spring一起使用,采用spring的文件配置。
<bean id="sqlMapClient"class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
<propertyname="configLocation"value="classpath:/sql-map-config.xml"/>
<propertyname="dataSource"ref="dataSource"/>
</bean>
configLocation为ibatis配置文件路径,dataSource为数据源。
二、解析用到的主要类介绍
1、NodeletParser——该类主要负责将XML文件通过JAXP的方式转为Document对象,并且递归逐层解析。
2、SqlMapConfigParser——该类主要负责解析ibatis的sqlmapconfig配置文件。
3、SqlMapParser——该类主要负责解析ibatis的sqlmap文件,对parameterMap,resultMap,sql等标签主要解析。
4、SqlStatementParser——该类主要负责解析ibatis的sqlmap文件,对insert、delete、update、select标签主要解析。
5、BaseParser——SqlMapConfigParser、SqlMapParser、SqlStatementParser均继承了此类,该类中的内部类Variables保存了上述3个类 解析文件后生成的对象。