节点文献

基于Spring+Hibernate的开发方法研究及实例

The Research and Instance of a Development Method Based on Spring+Hibermate

【作者】 刘壮

【导师】 房至一;

【作者基本信息】 吉林大学 , 计算机系统结构, 2005, 硕士

【摘要】 J2EE 标准是以Java 语言为基础的许多概念,编程标准和专门为电子商务软件和企业级应用软件问题改进的技术手段的标准集合。目前主流厂商提供了各种服务,集成到一起成为开发电子商务和企业级应用系统的平台,该平台提供的解决方案中业务逻辑层由EJB机制完成,但该解决方案逐渐出现一些不足,主要有编程和架构规范在一定程度上限制程序的开发;EJB 机制对代码具有一定侵入性;组件重用和系统升级不很方便;持久化方面,JDBC 设计代码量大,不利于维护;对于企业级应用软件的快速开发的需求特点并不适合;成本昂贵等等。本文集成运用了两个开源软件产品Spring和Hibernate,设计开发一个项目管理系统,目的在于解决EJB机制在解决企业级应用软件开发中遇到的问题。并且将EJB 和Spring+Hibernate 的解决方案做了比较,重点比较持久化处理,事务处理,调用服务的方式等方面。其中Spring是基于IoC 和AOP 的轻量级容器,Hibernate 是ORM 工具。二者分别负责系统的业务逻辑层和持久化层的工作。该项目管理系统起到验证这种开发方法的作用。实验结果表明本文实现的项目管理系统解决了以上几个问题,运行性能良好。由于IoC,AOP,ORM 三种设计思想的杰出表现,所以应该与J2EE平台的优势部分相结合,屏弃不足的地方,构造更好的电子商务和企业级应用软件的解决方案。

【Abstract】 At present, the Java technologies which come from Java open resources community prevails day by day, and they are mostly the improvements of some previous ones’drawbacks. There are some technologies with such characteristics replace them, including expensive cost, less invasion generally needed by industy, less lightweight and easier to test. In this paper, I will introduce three ideas by which we can develop enterprise software without EJB, and I will research a new method to develop enterprise application software based on Spring+Hibernate. The result shows we can easily and quickly develop an enterprise application which has the advantage over actual technology of high degree of reusing component. Then I develop a project management system(pms) to test the method. The pms has good performances and suits to the point of view of most enterprisese application. IoC means that container controls the relationship between each component, but in traditional way, it is controlled by program code directly. Definition of the IoC is that the control power is given from program code to outside container. The transformation of the control power is also called inversion. Definition of the DI is that container in the runtime determines the dependency relationship of components, just as containers inject some dependency relationship into the component dynamically. IoC mode can delay the realization of the interface, and realize them according to need. Just like an empty mold, inject gypsum to them in the case of necessary, and make a model in this way, so, the realization of control interface is called “injection”. AOP is extending of OOP, AOP pursues the decoupling between the caller and the called, and it is also a realization of this target. AOP mainly aims at aspects of the business processing to pick up, what it faces is some step or stage in the business processing, in order to obtain the low-coupling effect among every part during logic process. ORM means Object Relational Mapping, which is a persistent data method at bottom layer. Then we use the popular lightweight container Spring, which greatly supports these two core technologies, and establish a method to develop enterprise application software system assistant by Hibernate. It meets the point of view of most enterprise. It provides more flexible function of service shift and easier reusability. When the environment changes, business logic needn’t modify, only need changing configuration files and the whole system runs well. The key concept of Spring is IoC, it behaves that high layer component does not depend on low layer component, component depends on abstract but not the implement of abstract, application program does not depend on container, but container serves application program. In this way, in order to make the reliance minimum and improve the reused of components, the developer can finish the dependency injection among the subassemblies. Spring is a low invasion framework and the component in Spring does not realize itself in Spring in fact, it makes component, even framework, easy to be integrated. Another importance of Spring is to the support of AOP, AOP frame is a sub-framework which Spring framework supports. Hibernate is a kind of ORM in essence. The above POJO reflected here is the semanteme of Object layer of ORM, but mapping file is the relative ligament between object and relational date, in the Hibernate, mapping files usually make ".hbm.xml" as the suffix.Then we introduce the process and method to configure Hibernate. The implementation of pms includes 4 layers according to the responsibility. There are Presentation, Persistence, Business and EIS. Each layer has specific responsibility in its program processing without having the same function with others layers, and each layer should be different with others, but interfaces are needed between two layers. We create domain objects first. First of all, we should determine which objects need persistence and which ones will offer to business logic and the ones are used to display the interface; Secondly, the configuration of the Persistency Layer and the definition of OR mappings for Hibernate; And thirdly, the definition of the Business Objects. After, we will connect them with Spring; At last, we provide Spring with a Persistency Layer from which we know how can it communicate with Business Service Layer and how to deal with the exception thrown by other layers. Especially, the most important part in the system is ACH.xml. It is a bus through which beans can be organized together to finish program processing. We used MS SQL server and Jbuilder9 as IDE in our development. Tomcat5 is used as application server to detect the access port of the IE6.0. Through experiment the system meets point of the view of enterprise applicetion and realizes flexible Multi-layers architecture, furthermore brings a light-weighted, low invasion, high reusability of components.

【关键词】 J2EEEJBSpringHibernate
  • 【网络出版投稿人】 吉林大学
  • 【网络出版年期】2006年 03期
  • 【分类号】TP311.52
  • 【被引频次】50
  • 【下载频次】871
节点文献中: