The_Research_of_Web_Application_Framework_Based_on_SSH_第1页
The_Research_of_Web_Application_Framework_Based_on_SSH_第2页
The_Research_of_Web_Application_Framework_Based_on_SSH_第3页
The_Research_of_Web_Application_Framework_Based_on_SSH_第4页
全文预览已结束

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

The Research of Web Application Framework Based on SSH Fang Liu, Hongxia Guo School of Computer Science and Technology Wuhan University of Technology Wuhan, China Bo Fu School of Electrical and Electronic Engineering Hubei University of Technology Wuhan, ChinaAbstractBased on the three popular open sources as Struts, Spring and Hibernate (SSH), an integrated framework for e-human resource (E-HR) is proposed in this paper as an effective web application framework. E-HR is generally regarded as a complicated enterprise information system and the proper application framework is supposed to improve the system expansibility and the enterprise competitiveness as well. The presented framework derives from model-driven approach with high usage of code generation tools and application layout templates. It not only separates the presentation layer, business layer and data persistence layer, but also provides a convenient platform for software reuse. Furthermore, it allows for speeding-up development of web applications. By comprehensively analyzing the distinct characteristics of the framework such as scalability, maintainability and less coupling complexity, the specific application of the framework in the file management module of the E-HR system is carried out to further shows the advantages of SSH in software development efficiency. Keywords- Web Application Framework; Struts; Spring; Hibernate; E-HR I. INTRODUCTION The web application project has been receiving great attention in recent years and becomes more pervasive, while the complexity of developing a web application system grows rapidly. Consequently, adopting an accurate, economical and efficient method for web application is more urgent than ever. SSH (Struts, Spring and Hibernate) is expected to be a good framework for solving problems mentioned above. It uses layered structure and provides a good integrated framework for Web applications at all levels in minimizing the Interlayer coupling and increasing the efficiency of development. Compared with the traditional human resource scheme, the e-human resource (E-HR) supplies more advanced techniques in daily transaction management, administrative management and appreciation service. Faced with such large-scale web application, the conventional framework is buffered for the complex presentation and logical processing. In this paper, the research of web application framework based on SSH is brought forward and applied to construct an e-HR system. The basic theory of SSH framework is introduced in Section II. In Section III, the structure of SSH for E-HR is explained in detail. Results from the application analysis are reported. Finally, conclusions are obtained in Section IV. II. STRUTS+SPRING+HIBERNATE FRAMEWORK A. The Characteristics of Struts, Spring and Hibernate Model-View-Controller (MVC) is a popular design pattern. It divides the interactive system in three components and each of them specializes in one task. The model contains the application data and manages the core functionality. The visual display of the model and the feedback to the users are managed by the view. The controller not only interprets the inputs from the user, but also dominates the model and the view to change appropriately. MVC separates the system functionality from the system interface so as to enhance the system scalability and maintainability. Struts 1 is a typical MVC frame, and it also contains the three aforementioned components. The model level is composed of JavaBean and EJB components. The controller is realized by action and ActionServlet, and the view layer consists of JSP files. The central controller controls the action execution that receives a request and redirects this request to the appropriate module controller. Subsequently, the module controller processes the request and returns results to the central controller using a JavaBean object, which stores any object to be presented in the view layer by including an indication to module views that must be presented. The central controller redirects the returned JavaBean object to the main view that displays its information. Fig. 1 describes the Struts frame structure. Struts focuses on reducing the coupling between performance and logic, while takes less attention to the relevance between business layer and persistence layer. Figure 1. Struts frame structure. 2008 International Seminar on Business and Information Management978-0-7695-3560-9/08 $25.00 2008 IEEEDOI 10.1109/ISBIM.2008.209169Spring 2 is a lightweight J2EE application development framework, which uses the model of Inversion of Control (IoC) to separate the actual application from the Configuration and dependent regulations of the application. Committed to J2EE application at all levels of the solution, Spring is not attempting to replace the existing framework, but rather “welding” the object of J2EE application at all levels together through the POJO management. In addition, developers are free to choose Spring framework for some or all, since Spring modules are not totally dependent. As a major business-level detail, Spring employs the idea of delay injection to assemble code for the sake of improving the scalability and flexibility of built systems. Thus, the systems achieve a centralized business processing and reduction of code reuse through the Spring AOP module. Hibernate 3 is a data persistence framework, and the core technology is the object / relational database mapping (ORM). Hibernate is generally considered as a bridge between Java applications and the relational database, owing to providing durable data services for applications and allowing developers to use an object-oriented approach to the management and manipulation of relational database. Furthermore, it furnishes an object-oriented query language- HQL, so that operations are conveniently performed in the manner of a class of objects, examples and attributes. Responsible for the mapping between the major categories of Java and the relational database, Hibernate is essentially a middleware providing database services. It supplies durable data services for applications by utilizing databases and several profiles, such as hibernate properties and XML Mapping etc. B. The Structure of SSH Framework The developed integrated framework in this paper provides the appropriate integration strategy for web application at all levels by combining the characteristics of these three frameworks and the layered idea of Web applications, which reduces the coupling degree in each layer of the system and has the system easier for maintenance and extension. 1)The presentation layer (UI Layer) is mainly achieved by Struts. The process is depicted as that, in the beginning Struts intercepts user requests through ActionSevlet, and then calls the model to deal with requests according the needs, finally the result to users are shown through JSP files. The system is conveniently maintained under such mechanism by separating the data processing and display. At the same time, a Deputy Controller is supplied by Struts to call business logic and other upper treatments. In addition, through the combination of commons-validator.jar, a powerful data checking function is offered to the presentation layer for UI checking. 2)Spring framework is employed to realize the detail of each level in Business layer. By using interface-oriented programming, Spring factory model provides Bean generation and management, which avoids the complicated compling problem between Beans in the form of hard-coded approach. Spring 4 adopts the model of Inversion of Control (IoC) to manage affairs between layers, and therefore the implementation of the object becomes transparent, the coupling between the components business is reduced, and the system compatibility and scalability get obviously improved. For the realization of the seamless connectivity at all levels of the web applications, Spring supports the management on POJO, and moreover, it also controls the implementation of the procedures from the presentation layer to the persistence layer and provides interlayer interaction with interface. 3)Persistence Layer is controlled by Hibernate frame. Through the O/R Mapping, the database objects are mapped into corresponding persistence classes by hibernate and such classes are useful for middle layer 5, 6. The database operations are dominated by the DAO mode, which separates the database operations and business logic. Hibernate supplies a persistent mechanism and query service for java as well 7. This method greatly reduces the development of persistent data programming tasks by translating the Java-type HQL statement into SQL statement, and then completing the data operation with JDBC driver. III. THE STRUCTURE OF SSH FRAMEWORK FOR E-HR E-human resource (E-HR) system offers relevant services for special customers through network. As a large-scale web application project, the E-HR system is made up of different modules. Due to the complex module relations, this paper concerns the employee information management module to describe the web application of SSH on E-HR system. Fig. 2 is the structure of the proposed E-HR system. It shows that JSP is employed as the presentation layer to collect user requests data and business data, web layer utilizes MVC framework to control the interaction between business layer and presentation layer, and business layer is mainly mastered by business logic components with Spring IOC container. DAO layer is composed of various DAO components, which controls the interaction between database access objects and persistence database object. Hibernate persistence layer consists of many PO files, and it achieves the database access under Hibernate Session management. The structure exhibits Spring framework is the core of the system, and MVC Control, Service-level components and DAO components are generated by Spring IOC container, which manage the instances of components. The employee information management module in the presented E-HR system includes staff basic information, family information, contract information and others. The system is expected to provide basic operations on the mentioned information. From the perspective of Web-level, presentation layer just provides the function to display the data, the middle layer is responsible for dealing with users request and updating data in presentation layer, and the database layer stores the information. The middle layer is described in detail as follows. 170 Figure 2. Structure of system. A. Hibernate Layer The database is designed to contain basic tables to store the information mentioned above, such as family, compact, employee and so on. Each table is related with employee table. In this paper, an example is cited to explain how the integrated framework works in the developed system. Information is stored by PO objects in the Hibernate layer, while the correlative relationships between these objects are embodied in *.hbm.xml. Fig.3 lists the main code in Employee.hbm.xml. It points out the primary key in employee and the one-to-many relationship between employee and family. The primary job for hibernate layer is to set up PO objects and corresponding mapping files, but the database operations are left to DAO layer. Figure 3. The main code in Employee.hbm.xml. B. DAO Layer Since each of DAO components is able to complete CRUD operations on database, they are utilized to realize the encapsulation of database access in DAO layer. The implementation of the DAO class relies on the DAO support from Spring, which uses interface defined before. The FamilyDao interface definition is written in Fig. 4. Figure 4. FamilyDao interface definition. In order to run the program, the corresponding configuration is required after depicting the DAO classes. Fig.5 is part of the DAO code. Figure 5. Part of the DAO code. Spring container takes charge of generating and managing components of DAO, and the injection of necessary SessionFactory to DAO components. HibernateDaoSupport class can access database with only one attribute in SessionFactory, however the true database access is implemented by HibernateTemplate. For no components is changed in business in business layer, persistence layer and business layer are separated by DAO layer, especially when the techniques used in persistence layer are required to be replaced. On the other side, the objects in business layer utilize interface-oriented programming technique, and it is needless to care about the implementation details of DAO components. C. Service Layer To carry out the separation between business layer and persistence layer, DAO components are Facade encapsulated by business logic layer components in business layer, and then it is capable of using Dao interface-oriented public interface FamilyDao Family get(Integer Eid); void save(Family family); void update(Family family); void delete(Integer Eid); 171programming. Business logic layer is realized by IOC framework. In the programming, only the dependent business logic components are needed to be declared, and the setter method are subsequently written in terms of dependency injection pattern, while action instantiation is finished in configuration files. Fig.6 displays some of the source code in EmpManagerImpl and applicationContext.xml file. Figure 6. Some of the source code in EmpManagerImpl and applicationContext.xml file. D. Web layer Struts+Spring integration method are used in presentation layer. In this way, all the client requests (*.do) are held up by ActionServlet and transmitted to beans in Spring container. For the sake of avoiding the redundant DelegatingActionProxy instances, the system adopts the DelegatingRequestProcessor integration strategy, which delivers the requests to beans in advance. Action in Struts is required to configure in Struts-config.xml, and the actual configuration is set in Spring container. When the client requests are held up by ActionServlet, they are first allocated to the corresponding Action in Struts-config.xml, and then to the homonymic bean in Spring container. It is the homonymic bean that is the true realized class. The code added in configuration files such as the struts-config.xml file to obtain the family information by implementing functions is described in Fig. 7. Figure 7. Codes added in struts-config.xml file. IV. CONCLUSIONS SSH (Struts, Spring and Hibernate) is considered to have more web applications for its distinct characteristics in that Struts can provide a persistence presetation layer, Spring is regarded as an effective framework to achieve seamless connections between frames, and a sophisticated data persistence

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论