从上一篇源代码阅读看,这hibernate套的还真是有点深,这次主要看一下他的启动过程
// configures settings from hibernate.cfg.xml
Configuration cfg=new Configuration().configure();
sessionFactory = cfg.buildSessionFactory();
先初始化Configuration 对象,这个类里保存运行时的配置信息,
protected Map<String, PersistentClass> classes;
protected Map<String, String> imports;
protected Map<String, Collection> collections;
protected Map<String, Table> tables;
protected List<AuxiliaryDatabaseObject> auxiliaryDatabaseObjects;
protected Map<String, NamedQueryDefinition> namedQueries;
protected Map<String, NamedSQLQueryDefinition> namedSqlQueries;
protected Map<String, ResultSetMappingDefinition> sqlResultSetMappings;
protected Map<String, TypeDef> typeDefs;
protected Map<String, FilterDefinition> filterDefinitions;
protected Map<String, FetchProfile> fetchProfiles;
protected Map tableNameBinding;
protected Map columnNameBindingPerTable;
protected List<SecondPass> secondPasses;
protected List<Mappings.PropertyReference> propertyReferences;
protected Map<ExtendsQueueEntry, ?> extendsQueue;
protected Map<String, SQLFunction> sqlFunctions;
解析获得session factory里面的配置信息
private void parseSessionFactory(Element sfNode, String name) {
Iterator elements = sfNode.elementIterator();
while ( elements.hasNext() ) {
Element subelement = (Element) elements.next();
String subelementName = subelement.getName();
if ( "mapping".equals( subelementName ) ) {
parseMappingElement( subelement, name );
}
else if ( "class-cache".equals( subelementName ) ) {
String className = subelement.attributeValue( "class" );
Attribute regionNode = subelement.attribute( "region" );
final String region = ( regionNode == null ) ? className : regionNode.getValue();
boolean includeLazy = !"non-lazy".equals( subelement.attributeValue( "include" ) );
setCacheConcurrencyStrategy( className, subelement.attributeValue( "usage" ), region, includeLazy );
}
else if ( "collection-cache".equals( subelementName ) ) {
String role = subelement.attributeValue( "collection" );
Attribute regionNode = subelement.attribute( "region" );
final String region = ( regionNode == null ) ? role : regionNode.getValue();
setCollectionCacheConcurrencyStrategy( role, subelement.attributeValue( "usage" ), region );
}
else if ( "listener".equals( subelementName ) ) {
parseListener( subelement );
}
else if ( "event".equals( subelementName ) ) {
parseEvent( subelement );
}
}
}
这里主要看下对mapping 节点的处理
private XmlDocument add(InputSource inputSource, Origin origin) {
XmlDocument metadataXml = MappingReader.INSTANCE.readMappingDocument( entityResolver, inputSource, origin );
add( metadataXml );
return metadataXml;
}
这里的 metadataXml 实际上是一个mapping文件的对象,包含了一个hbm.xml里面的配置信息。建立相应的pojo类是在build session factory的时候,
分享到:
相关推荐
Spring源代码解析(二):IoC容器在Web容器中的启动 Spring源代码解析(三):Spring JDBC Spring源代码解析(四):Spring MVC Spring源代码解析(五):Spring AOP获取Proxy Spring源代码解析(六):Spring声明式事务...
Spring源代码解析2:IoC容器在Web容器中的启动;Spring源代码解析3:Spring JDBC ; Spring源代码解析4:Spring MVC ;Spring源代码解析5:Spring AOP获取Proxy;Spring源代码解析6:Spring声明式事务处理 ; ...
Spring源代码解析2:IoC容器在Web容器中的启动.doc Spring源代码解析3:Spring JDBC .doc Spring源代码解析4:Spring MVC .doc Spring源代码解析5:Spring AOP获取Proxy .doc Spring源代码解析6:Spring声明式事务...
2.1.3 Hibernate配置和启动 2.1.4 运行和测试应用程序 2.2 启动Java Persistence项目 2.2.1 使用Hibernate Annotations 2.2.2 使用Hibernate EntityManager 2.2.3 引入EJB组件 2.2.4 切换...
Spring源代码分析(三):Spring JDBC Spring源代码解析(四):Spring MVC Spring源代码解析(五):Spring AOP获取Proxy Spring源代码解析(六):Spring声明式事务处理 Spring源代码解析(七):Spring AOP中对拦截器...
10.4.2 视图解析 10.5 Spring的控制器(Controller) 10.5.1 Controller接口 10.5.2 命令控制器(BaseCommandController) 10.5.3 表单控制器(SimpleFormController) 10.5.4 多动作控制器(MultiActionController...
10.4.2 视图解析 10.5 Spring的控制器(Controller) 10.5.1 Controller接口 10.5.2 命令控制器(BaseCommandController) 10.5.3 表单控制器(SimpleFormController) 10.5.4 多动作控制器(MultiActionController...
Spring源代码解析(二):ioc容器在Web容器中的启动 3.Spring源代码解析(三):Spring JDBC 4.Spring源代码解析(四):Spring MVC 5.Spring源代码解析(五):Spring AOP获取Proxy 6. Spring源代码解析(六):Spring...
10.4.2 视图解析 10.5 Spring的控制器(Controller) 10.5.1 Controller接口 10.5.2 命令控制器(BaseCommandController) 10.5.3 表单控制器(SimpleFormController) 10.5.4 多动作控制器(MultiActionController...
Spring源代码分析(三):Spring JDBC.doc Spring源代码解析(四):Spring MVC.doc Spring源代码解析(五):Spring AOP获取Proxy.doc Spring源代码解析(六):Spring声明式事务处理.doc Spring源代码解析(七):Spring...
Spring源代码解析2:IoC容器在Web容器中的启动;Spring源代码解析3:Spring JDBC ; Spring源代码解析4:Spring MVC ;Spring源代码解析5:Spring AOP获取Proxy;Spring源代码解析6:Spring声明式事务处理 ; ...
hibernate_mapping 这个项目文件,是我把这其中的hibernate单独另外拿出来对hibernate进行讲解分析,这个项目文件与物流的项目没有具体关系,只是对hibernate的一个案例分析,运行的话每一个包下都有main主函数,...
5.3.1 网站启动测试 20 5.3.2 测试用户登录模块 20 5.3.3 测试修改密码模块 21 5.3.4 测试存款管理模块 21 5.3.5 测试取款管理模块 21 第6章 总结与展望 22 6.1 总结 22 6.2 展望 22 参考文献 23 (5)取款...
- hibernate_mapping 这个项目文件,是我把这其中的hibernate单独另外拿出来进行对hibernate的讲解分析,这个项目文件与物流的项目没有具体关系。 - img 用于有关项目的功能截图存放文件 - test 这个文件是当时我...
JProfiler 是一款高性能、无侵入的 Java 性能监控神器,可以快速启动并提供丰富的性能分析功能。它适用于各种 Java 应用程序,包括服务化架构下的应用程序。JProfiler 可以帮助您监控服务的运行情况,例如当前 QPS、...
Eclipse开发入门与项目实践 Eclipse开发入门与项目实践 源代码 Eclipse开发入门与项目实践 源代码 Eclipse开发入门与项目实践 源代码 第一部分 开发入门 第1章 Eclipse概述及开发环境搭建 2 1.1 Eclipse概述 2...
Java二进制IO类与文件复制操作实例,好像是一本书的例子,源代码有的是独立运行的,与同目录下的其它代码文件互不联系,这些代码面向初级、中级Java程序员。 Java访问权限控制源代码 1个目标文件 摘要:Java源码,...
目前主要功能有java工程和Tomcat工程, 包,类的创建和保存,java代码和jsp页面的编辑,会有方便的辅助对话框,显示相关的函数和属性,jsp页面 的有更好的编辑辅助对话框可以少输入很多代码,Tomcat工程的自动部署和启动,...
76.2. 如何设定的weblogic的热启动模式(开发模式)与产品发布模式? 86 76.3. 如何启动时不需输入用户名与密码? 86 76.4. 在weblogic管理制台中对一个应用域(或者说是一个网站,Domain)进行jms及ejb或连接池等相关信息...