[ieee 2012 ieee 6th international conference on information and automation for sustainability...

6
978-1-4673-1975-1/12/$31.00 ©2012 IEEE ICIAfS’12 Abstract—Enterprise web application development is considered as a major branch in software development industry for last decade. Since electronic solutions provided by web applications are proven to be valuable in terms of efficiency and accuracy, market demand is increased and web application developers are started to move in to more rapid application development frameworks. Therefore, numbers of rapid application development frameworks are newly introduced. Object/Relational mapping mechanisms are considered to be acting a major role in this arena and even though these frameworks are capable of reducing considerable time and effort in software development, new software development frameworks are introduced day by day in order to provide better software engineering solutions. Since simplicity of development and amount of time it takes for the development are key areas to be considered in this matter, application development frameworks are now more focused on providing high-level interfaces which can reduce the development time. This paper describes an Object/Relational mapping framework which is built on Java Server Pages server scripting technology. Framework is built to provide a high- level interface for accessing data persistence layer of a web application, when Hibernate Object/Relational mapping mechanism is implemented in data persistence layer. The framework is consisted with a JSP tag library and it contains JSP based custom tags which are capable of manipulating application’s underlying data source. I. INTRODUCTION Enterprise web application development has been one of the most important areas of software product development industry for last decade. Many of the world’s leading software engineering companies were able to come up with different kind of tools and techniques to provide engineering solutions to their customers. As a result, in a high level view, different kinds of programming languages and software engineering frameworks were developed to backup the enterprise web applications development. Sun Microsystems and Microsoft Corporation were two of the leading competitors in providing enterprise web application solutions, while many of the open source organizations were not very far behind them in this immeasurable competition. Java Server Pages (JSP) was the initial approach of Sun Microsystems as an enterprise web applications development while Active Server Pages (ASP) acts almost same role by representing Microsoft’s approach [1]. It is true that Sun Microsystems’s JSP represented open source community, but PHP and Ruby on Rails were two other web-server scripting languages which stood next to JSP, as open source products. Along with all these web-server scripting languages, web-frameworks started to find their way in to software industry by making the development much easier to software developers. Most of them were third-party frameworks except the frameworks provided by Microsoft Corporation for their languages. Hibernate is one of the third-party Object/Relational Mapping frameworks developed by an open source community named JBoss, in order to provide data persistence requirements for Java based software applications [2], [3], [4]. The database transactions of storing and retrieving for stand-alone applications, as well as web applications, are supported by Hibernate and even if it equally supports on both platforms, Hibernate is highly being used in medium to large scale enterprise web applications [3]. The framework described in this paper is an approach of enabling data persistence requirements for Java Enterprise Edition’s Java Server Pages (JSP) based small to medium scale enterprise web applications, using the base architecture of Hibernate. The framework consists of a JSP tag library which facilitates JSP page developers to access Data Persistence Layer of an application while staying in Presentation Layer, with no communication with Application/Business Layer. The tag library supports over 30 different JSP tags on this purpose, while providing an ultimate power to JSP page developers in executing any kind of database query against the data store. Section II provides a detailed description of the problem addressed throughout this paper. Goals of the developed framework and framework concepts are defined in Section III and Section IV, while Section V provides a complete Efficient Access to Hibernate Through JSP Powered by a New Tag Library Pubudu Gunawardena 99X Research 99X Technology Colombo, Sri Lanka [email protected] ICIAfS'12 1569624511

Upload: pubudu

Post on 11-Mar-2017

213 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: [IEEE 2012 IEEE 6th International Conference on Information and Automation for Sustainability (ICIAfS) - Beijing, China (2012.09.27-2012.09.29)] 2012 IEEE 6th International Conference

978-1-4673-1975-1/12/$31.00 ©2012 IEEE ICIAfS’12

Abstract—Enterprise web application development is

considered as a major branch in software development industry for last decade. Since electronic solutions provided by web applications are proven to be valuable in terms of efficiency and accuracy, market demand is increased and web application developers are started to move in to more rapid application development frameworks. Therefore, numbers of rapid application development frameworks are newly introduced. Object/Relational mapping mechanisms are considered to be acting a major role in this arena and even though these frameworks are capable of reducing considerable time and effort in software development, new software development frameworks are introduced day by day in order to provide better software engineering solutions. Since simplicity of development and amount of time it takes for the development are key areas to be considered in this matter, application development frameworks are now more focused on providing high-level interfaces which can reduce the development time. This paper describes an Object/Relational mapping framework which is built on Java Server Pages server scripting technology. Framework is built to provide a high-level interface for accessing data persistence layer of a web application, when Hibernate Object/Relational mapping mechanism is implemented in data persistence layer. The framework is consisted with a JSP tag library and it contains JSP based custom tags which are capable of manipulating application’s underlying data source.

I. INTRODUCTION Enterprise web application development has been one of

the most important areas of software product development industry for last decade. Many of the world’s leading software engineering companies were able to come up with different kind of tools and techniques to provide engineering solutions to their customers. As a result, in a high level view, different kinds of programming languages and software engineering frameworks were developed to backup the enterprise web applications development. Sun Microsystems and Microsoft Corporation were two of the leading competitors in providing enterprise web application solutions, while many of the open source organizations were not very far behind them in this immeasurable competition.

Java Server Pages (JSP) was the initial approach of Sun Microsystems as an enterprise web applications development while Active Server Pages (ASP) acts almost same role by representing Microsoft’s approach [1]. It is true that Sun Microsystems’s JSP represented open source community, but PHP and Ruby on Rails were two other web-server scripting languages which stood next to JSP, as open source products. Along with all these web-server scripting languages, web-frameworks started to find their way in to software industry by making the development much easier to software developers. Most of them were third-party frameworks except the frameworks provided by Microsoft Corporation for their languages.

Hibernate is one of the third-party Object/Relational Mapping frameworks developed by an open source community named JBoss, in order to provide data persistence requirements for Java based software applications [2], [3], [4]. The database transactions of storing and retrieving for stand-alone applications, as well as web applications, are supported by Hibernate and even if it equally supports on both platforms, Hibernate is highly being used in medium to large scale enterprise web applications [3].

The framework described in this paper is an approach of enabling data persistence requirements for Java Enterprise Edition’s Java Server Pages (JSP) based small to medium scale enterprise web applications, using the base architecture of Hibernate. The framework consists of a JSP tag library which facilitates JSP page developers to access Data Persistence Layer of an application while staying in Presentation Layer, with no communication with Application/Business Layer. The tag library supports over 30 different JSP tags on this purpose, while providing an ultimate power to JSP page developers in executing any kind of database query against the data store.

Section II provides a detailed description of the problem addressed throughout this paper. Goals of the developed framework and framework concepts are defined in Section III and Section IV, while Section V provides a complete

Efficient Access to Hibernate Through JSP Powered by a New Tag Library

Pubudu Gunawardena 99X Research

99X Technology Colombo, Sri Lanka

[email protected]

ICIAfS'12 1569624511

Page 2: [IEEE 2012 IEEE 6th International Conference on Information and Automation for Sustainability (ICIAfS) - Beijing, China (2012.09.27-2012.09.29)] 2012 IEEE 6th International Conference

description on the framework implementation. Section VI provides a descriptive discussion on the developed framework and its features, while Section VII, Section VIII and Section IX provides details on related work, conclusion and future work respectively.

II. PROBLEM IDENTIFICATION When Hibernate is used as middleware design of

Object/Relational Mapping model, Java Methods are to be used along with application logic to access persistence level data. Extracting and filtering required data to be viewed and storing important data in data store are done using above mentioned Java Methods provided by Hibernate application programming interface (API). In a web application developed on JEE based technology stack which have used JSP as the Presentation mechanism and Hibernate as the Object/Relational Mapping tool, data access requests are generated by Application/Business Layer on behalf of Presentation Layer. In align with Model – View – Controller (MVC) architecture, Presentation Layer acts the role of View while Application/Business Layer and Data Access Layer act the roles of Controller and Model respectively. In a high level view, the View component of application fulfills its data requirements by communicating to Model component through the Controller [5].

A. Data Requirements for Prototype Applications/ Pilot Projects In a prototype development of a large scale enterprise

web application, the requirements are not more focused on the technology stack aspects but on its business requirements. Focusing on large picture of technology architecture will delay the prototype applications since it needs more expert review. In short, prototype applications should be developed in a fast and easy manner.

B. Small to Medium Scale Software Products Where the Architecture Does Not Matter A good architectural design may not always be the rule of

thumb. There are some small to medium scale software products which require one time development instead of re-engineering it time to time [6]. As long as the architecture does not matter and it does not affect the expected performance of proposed software application, it is important to increase the speed of development.

C. Steep Learning Curve for JSP Developers All JSP developers are not familiar with programming

theories. In fact, initially JSP is an achievement of a successful attempt of providing server-side Java language capabilities to HTML page developers [1]. Therefore, the learning curve for Java language is steep for them [7]. It is important to provide them a mechanism of accessing data storage without writing Java programs [5] so that they can store and retrieve data directly from and to data store while

staying in View, with zero communication to Controller. By taking first two scenarios mentioned above in to

account, a conclusion can be made that a mechanism of simplifying the data requirements of View component can provide a solution to the needs of rapid development of small to medium scale software products. On the other hand, as the third scenario describes, JSP’s initial purpose of providing server development capabilities to HTML developers can be enhanced by providing a simplified data access mechanism to JSP developers other than communicating to data storage through Controller and Model.

III. FRAMEWORK GOALS The goals of framework are defined by identifying the

problem. Since developing a prototype of an application or pilot project is done in the initial stage of a project and the purpose of prototype development is to get an in depth view of the final product in terms of business domain and its requirements, more rapid development approach is an ideal solution. As mentioned in Problem Identification section, the prototype development can become slow in terms of time it takes for the development, if the prototypes are developed by focusing on application software architecture. Therefore, one goal of the framework is to provide a simplified interface to developers to access persistence layer data, when using JSP as the presentation layer and Hibernate as the Object/Relational Mapping model, so that prototype applications can be more rapidly developed exclusive of hard and fast rules of MVC model.

At the same time, as mentioned in Problem Identification section, there can be small software products which will need one time development instead of reengineering it time to time. In order to facilitate these types of software applications, framework should provide an overall complete solution by considering all the possibilities of data access needs of an application. In fact, if it is possible to access persistence layer data using the framework, another goal of the framework is to provide a data access interface which is capable of providing all types of database transactions to JSP developer.

On the other hand, since one of the problems discussed above is about steep learning curve of JSP developers in learning programming theories, another framework goal will be to make the framework simpler so that JSP developers can use it with zero knowledge of programming concepts and Hibernate Query Language (HQL) queries.

IV. FRAMEWORK CONCEPTS Taking the framework goals in to consideration, a

decision is taken that the best approach for the framework will be a development of a JSP tag library. This kind of tag library implementation is capable of providing a simple JSP

Page 3: [IEEE 2012 IEEE 6th International Conference on Information and Automation for Sustainability (ICIAfS) - Beijing, China (2012.09.27-2012.09.29)] 2012 IEEE 6th International Conference

page level interface for accessing data persistence layer. Further, the complexity occurs during the use of Hibernate O/R Mapping mechanism is hidden from the JSP developer and amount of programming language concepts needed by the JSP developer will be very low. On the other hand if the tag library is capable of providing JSP tags to perform all four database transactions (Create, Read, Update, and

Delete), JSP developers do not have to be knowledgeable on HQL. Hibernate queries which include database Selections, Restrictions, Projections, Aggregations and Joins can be built with defined JSP tags which accepts certain number of parameters as tag attribute values.

V. IMPLEMENTATION

Fig. 1. Hibernate Architecture - The framework sits between Application Classes and Hibernate Layer

Fig. 1 illustrates a high-level overview of Hibernate architecture and how the developed framework fits into it for the purpose of providing a high-level interface to Application Classes. In the situation of providing functionalities to JSP based web application, Application Classes are considered as JSP pages. The framework sits between Application Classes and Hibernate layer (O/R Mapping layer) by simplifying the use of Hibernate API. All Hibernate API methods are hidden from the developer and instead the JSP tags of tag library are visible to developers so that these tags can be used to perform any kind of database transaction over the data store.

The tags of the tag library are implemented by Simple Tag Handlers API provided in Java Servlet Specification. All three methods available in developing custom tags are taken in to consideration and Simple Tag Handlers are found to be more suitable for the development compared to Classic Tag Handlers, while Tag Files cannot be used to achieve framework requirements [8].

Hibernate Criteria API is used in order to achieve the requirement of accessing data store through Hibernate API. The reason for the selection of Hibernate Criteria API is its capability of building custom database queries through Java language methods in the application run time.

Page 4: [IEEE 2012 IEEE 6th International Conference on Information and Automation for Sustainability (ICIAfS) - Beijing, China (2012.09.27-2012.09.29)] 2012 IEEE 6th International Conference

Fig. 2. Components of a Tag

Fig. 2 illustrates the main components of a tag. As Simple Tag Handlers are the tag handling mechanism of choice, Tag Library Descriptor file is used for the communication between JSP file and Tag Handler Class. Attribute values of a tag are extracted and transferred to Tag Handler Class for further processing. The mapping of attribute values to Tag Handler Class attribute variables are handled by Tag Library Descriptor while Tag Handler Class is responsible for data

persistence transactions. In short, Tag Handler Class will store or retrieve data using Hibernate Criteria API, according to tag’s requirements.

VI. THE DEVELOPED FRAMEWORK The developed framework is consisted with total of thirty

two JSP tags. It is consisted with eight JSP tags which act as parent tags while another twenty four tags are considered as

Page 5: [IEEE 2012 IEEE 6th International Conference on Information and Automation for Sustainability (ICIAfS) - Beijing, China (2012.09.27-2012.09.29)] 2012 IEEE 6th International Conference

child tags. The parent tags can be used with no use of any other tag, where as child tags must be used along a parent tag. In other words, the responsibility of parent tags are to retrieve data as large data sets while child tags are designed to filter that large data set by applying restrictions and

projections. Fig. 3 shows a hierarchy of tags which represents parent-child relationship for tags. The arrow heads are directed to parent tags while opposites represent the child tags which can be used with that particular parent tags.

Fig. 3. Tag Hierarchy

VII. RELATED WORK The defined framework can be compared and contrasted

with an existing web scripting language of ASP.NET. Fig. 4 shows how the defined framework achieves ASP.NET similar capabilities for JSP Hibernate based development environment.

Fig. 4. Developed Framework vs. ASP.NET Data Access Functionality

Page 6: [IEEE 2012 IEEE 6th International Conference on Information and Automation for Sustainability (ICIAfS) - Beijing, China (2012.09.27-2012.09.29)] 2012 IEEE 6th International Conference

Knystautas [9] provides a small tag library which contains total of nine tags, which can be used to manipulate database data while staying inside JSP page. This framework is developed in 2003 using JSP 1.2 and Hibernate 2.1 specifications. The problem found in this tag library is it expects tag users to be knowledgeable on HQL, since HQL queries should be written in tag body and passed to Tag Handler Class along with other tag attributes. This is found as a major drawback in terms of steep learning curve of HQL. In short, the expected simplicity from a tag library is not fully achieved.

A study by Hasegawa et al. [3] describes a JSP tag library implementation for Bioinformatics Website Construction. The purpose of this tag library is to design and port website contents aimed at Bioinformatics.

Even if all these works address the same functionality provided by the framework described in this paper, not one of those are focused on serving JSP developers when Hibernate is used as O/R Mapping mechanism, except Knystautas’s framework, though it has a major drawback of steep learning curve.

VIII. CONCLUSION This paper demonstrated the abilities of a JSP tag library

in facilitating access to data persistence layer of a web based application when Hibernate is used as O/R Mapping mechanism. To the best of my knowledge, this is the first approach of developing a JSP tag library which requires zero knowledge on programming concepts and Hibernate Query Language to use it. In other words, it addresses the area of simplifying a JSP tag library so that JSP developers do not have to be knowledgeable in programming concepts to use the tag library; an area that has not been addressed by any previous work. On the other hand, the framework is a perfect solution for the development of prototype applications/pilot projects, where rapid application development acts a major role. In addition to its simplicity in use, the tag library provides thirty two JSP tags which are capable of completing any kind of CRUD operation, including database table Joins.

Requirement of basic knowledge in the concept of database tables is a limitation of the framework. In other words, in order to use JSP tags to store or retrieve data, JSP developer should have a basic knowledge on how data is saved in database in terms of data tables. The missing support to create sub-queries is another limitation.

One of the special characteristics of the introduced framework is that it does not put any barrier on the traditional method of data persistence, which is through communication of Controller component to Model component of MVC architecture. Instead, the framework allows the direct communication from View component to Model component and therefore application developers still can use the traditional data persistence method while having

the advantage of the new framework. Therefore it is important to highlight that developed framework will not create any limitation on the traditional method of communication of MVC architecture.

IX. FUTURE WORK Since one of the main features of support for building and executing sub-queries over the data source is not implemented in current framework, it can be added to current tag library by enhancing its features. A performance test can be conducted to measure the performance of developed tags, focusing on data retrieval time, data storing time and etc. Reason for this performance test is that it can be another start point for an optimization of current tags in terms of reconstructing them with different system architecture so that tags can perform faster, under databases with large number of data.

REFERENCES [1] H. Bergsten. Java Server Pages. O’Reilly Media, 2003, pp. 1-28 [2] JBoss Community. Relational Persistence for Java and .NET.

[Online]. http://www.hibernate.org/ [3] E. Pugh and J.D. Gradecki. Professional Hibernate. Wiley, 2004, pp.

15-22 [4] C. Bauer and G. King. Java Persistence with Hibernate. Manning,

2009, pp. 4-10 [5] B. Basham et al. “Script-free pages” in Head First Servlets and JSP.

O’Reilly Media, 2004, pp. 341-348 [6] A. Hasegawa et al., “BioTags: A JSP Tag Library for Bioinformatics

Website Construction,” Genome Informatics, Japan, Rep. 553-554, 2002.

[7] Serge Knystautas. Hibtags. [Online]. http://hibtags.lokitech.com/index [8] B. Basham et al. “Custom tags are powerful” in Head First Servlets

and JSP. O’Reilly Media, 2004, pp. 435 [9] B. Basham et al. “When even JSTL is not enough” in Head First

Servlets and JSP. O’Reilly Media, 2004, pp. 489-547