spring集成ibatis,涉及到的一些核心类

近期研究了下spring集成ibatis,涉及到的一些核心类,下面一个图大体的描述了这些类之间的一些关系:


1、ibatis通过SqlMapClient接口提供了访问数据库的相关操作。Spring的org.springframework.orm.ibatis.SqlMapClientFactoryBean类,负责创建SqlMapClient实体,具体的创建代码如下:

protected SqlMapClient buildSqlMapClient(
			Resource[] configLocations, Resource[] mappingLocations, Properties properties)
			throws IOException {

		if (ObjectUtils.isEmpty(configLocations)) {
			throw new IllegalArgumentException("At least 1 'configLocation' entry is required");
		}

		SqlMapClient client = null;
		SqlMapConfigParser configParser = new SqlMapConfigParser();
		for (int i = 0; i < configLocations.length; i++) {
			InputStream is = configLocations[i].getInputStream();
			try {
				client = configParser.parse(is, properties);
			}
			catch (RuntimeException ex) {
				throw new NestedIOException("Failed to parse config resource: " + configLocations[i], ex.getCause());
			}
		}

		if (mappingLocations != null) {
			SqlMapParser mapParser = SqlMapParserFactory.createSqlMapParser(configParser);
			for (int i = 0; i < mappingLocations.length; i++) {
				try {
					mapParser.parse(mappingLocations[i].getInputStream());
				}
				catch (NodeletException ex) {
					throw new NestedIOException("Failed to parse mapping resource: " + mappingLocations[i], ex);
				}
			}
		}

		return client;
	}
2、从上面的代码可以看出,ibatis通过SqlMapConfigParser类的parse方法,解析对应的XML配置文件,从而构造出SqlMapClient的实体。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
spring-core.jar(必须):这个jar 文件包含Spring 框架基本的核心工具Spring 其它组件要都要使用到这个包里的,是其它组件的基本核心,当然你也可以在自己的应用系统中使用这些工具。 外部依赖Commons Logging, (Log4J)。 spring-beans.jar(必须):这 个jar 文件是所有应用都要用到的,它包含访问配置文件、创建和管理bean 以及进行Inversion of Control / Dependency Injection(IoC/DI)操作相关的所有。如果应用只需基本的IoC/DI 支持,引入spring-core.jar 及spring-beans.jar 文件就可以了。 外部依赖spring-core,(CGLIB)。 spring-aop.jar(必须):这个jar 文件包含在应用中使用Spring 的AOP 特性时所需的和源码级元数据支持。使用基于AOP 的Spring特性,如声明型事务管理(Declarative Transaction Management),也要在应用里包含这个jar包。 外部依赖spring-core, (spring-beans,AOP Alliance, CGLIB,Commons Attributes)。 spring-context.jar(必须):这个jar 文件在基础IOC功能上为Spring 核心提供了大量扩展服务,此外还提供许多企业级服务的支持,有邮件服务、任务调度、JNDI定位,EJB集成、远程访问、缓存以及多种视图层框架的支持。可以找到使用Spring ApplicationContext特性时所需的全部,JDNI 所需的全部,instrumentation组件以及校验Validation 方面的相关。 外部依赖spring-beans, (spring-aop)。 spring-jdbc.jar(必须) :这个jar 文件包含对Spring 对JDBC 数据访问进行封装的所有。 外部依赖spring-beans,spring-dao。 spring-web.jar(必须) :这个jar 文件包含Web 应用开发时,用到Spring 框架时所需的核心,包括自动载入Web Application Context 特性的、Struts 与JSF 集成、文件上传的支持、Filter 和大量工具辅助。 外部依赖spring-context, Servlet API, (JSP API, JSTL, Commons FileUpload, COS)。 spring-webmvc.jar :这个jar 文件包含Spring MVC 框架相关的所有。包含国际化、标签、Theme、视图展现的FreeMarker、JasperReports、Tiles、Velocity、XSLT相关。包括框架的Servlets,Web MVC框架,控制器和视图支持。当然,如果你的应用使用了独立的MVC 框架,则无需这个JAR 文件里的任何。 外部依赖spring-web, (spring-support,Tiles,iText,POI)。 spring-aspects.jar :提供对AspectJ的支持,以便可以方便的将面向方面的功能集成进IDE中,比如Eclipse AJDT。 spring-context-support.jar:Spring context的扩展支持,用于MVC方面。 spring-expression.jar:Spring表达式语言。 spring-instrument.jar:Spring对服务器的代理接口 spring-instrument-tomcat.jar:Spring对tomcat连接池的集成 spring-jms.jar:为简化jms api的使用而做的简单封装。 外部依赖spring-beans,spring-dao,JMS API。 spring-orm.jar:整合第三方的orm实现,如hibernate,ibatis,jdo以及spring 的jpa实现 spring-oxm.jar:Spring对于object/xml映射的支持,可以让JAVA与XML之间来回切换 spring-messaging.jar: spring-test.jar:对JUNIT等测试框架的简单封装 spring-tx.jar:为JDBC、Hibernate、JDO、JPA等提供的一致的声明式和编程式事务管理。 spring-webmvc-portlet.jar:Spring MVC的增强 spring-websocket.jar:

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值