Professional Documents
Culture Documents
Department of Computer Technology, Veermata Jijabai Technological Institute,Matunga, Mumbai, India Head of Department of Computer Technology, Veermata Jijabai Technological Institute, Matunga, Mumbai, India
1,2,3
Abstract - This paper presents the concept of the Spring framework which is widely used in making enterprise wide applications along with other frameworks. Spring framework insists that ordinary java beans can be used with slight modifications to them. This framework is used within J2EE architecture to make it easier to develop large scale java applications. This paper presents the architecture overview of spring framework along with the features of the framework that have made the framework useful for using it along with struts and hibernate. The integration of various frameworks for an E-commerce system such as university system has also been discussed in the paper. The Spring MVC framework as an important part is also discussed along with struts mvc. This paper has a proposed architecture for a website based system using the integration of Spring, Hibernate and Struts framework. Keywords - AOP, Dispatcher, E-commerce, Hibernate, Integration, IoC, JavaEE, Mapping file, MVC, Spring, Struts
The architecture of spring consists of seven modules which can be shown as follows [2]: The core container Spring context Spring AOP Spring DAO Spring ORM Spring Web Module Spring MVC framework b. Features of Spring framework Spring is a free and open source framework that offers a lot of functions to developers and programmers. It was created by Rod Johnson and Juergen Hoeller jointly. The most important features of it are the Inversion of Control, Aspect oriented programming and Spring MVC. Spring has its own MVC framework that can be used with other frameworks or can be used alone. The Aspect oriented programming, IoC and MVC are the important features that facilitates the development of an enterprise applications. Aspect oriented Programming: Taking the help of AOP the various concerns present in a system can be easily separated out. Aspects can be transaction, logging and security. In Spring aspects are bundled together with the help of spring configuration file which is a xml file and coding is well modularized. [10] Example: consider the example of hotel booking system.
I.
INTRODUCTION
In todays world, with the introduction of information technology and communication media many of the companies use frameworks for making the development of their applications easier. The business today demands web applications to advertise its company so it is very important to take care of the architecture used in development of the application. Framework can be considered as a set of functions helping the developers in creating the applications. The Spring Framework is an application type framework that helps to customize java applications effectively. Even though JavaEE is widely used, it has some limitations such as reusability of code is very less, heavy development burden present [1], [5]. Spring framework when used with JavaEE makes the development easier. Spring is a layered architecture so whenever an Ecommerce system is developed using spring it has clear separation of the layers. Because of its layered architecture it allows users to select about which of its components users can use. II. a. RELATED W ORK
203
The same system with the help of AOP feature of spring can be drawn as follows: All the three functionalities are provided to all the three services which can be showed as below: [6]
Fig 4 Handling of request using Spring MVC Fig 3 Approach using AOP
d.
Inversion of Control: In the IoC instead application calling the framework, it is the framework that calls the components specified by an application. The dependencies are injected dynamically at run time by the container of Spring. c. Spring MVC model The Spring Framework has its own MVC model. The major components of Spring MVC are as follows [3]:
Struts MVC framework The application has central controller- a heart of framework struts (ActionServlet), which mediates between all requests and separate them to individual objects. Those objects are the bridge between the application model and assigned to it request. The model presents the application state. If the state is changed, control will be forwarded to the given view. This, to what view the control will be forwarded, is the most frequently specified in the mapping file. [31]
204
Control flow between components: [31] 1. Request is called by client, which chose some action in a given interface, displayed on the screen. 2. This request is received by ActionServlet (the application controller), which after checking in the mapping file transmits it to the proper Action class. 3. Action class does specific operations in the model. 4. After the task for the model is completed Action class returns control to ActionServlet controller. Data is returned by Action contain forward key. 5. On the basis of the mentioned key and a mapping file ActionServlet calls the appropriate view, which displays a requests result. e. Integration of Spring and Hibernate Spring can be easily integrated with the ORM tool such as Hibernate with the help of xml file. The xml for the mapping can be described as below: <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">${hibernate.dialect}</prop> <prop key="hibernate.show_sql">${hibernate.show_sql} </prop> <prop key="hibernate.connection.pool_size">${hibernate.connect ion.pool_size} </prop> </props> </property>
205
Hibernate framework: This persistence framework reduces the complexity, difficulty while manipulating the JDBC and SQL data. It maps Java classes to database tables efficiently. It is mainly associated with databases [3], [4]. The Structure of Hibernate can be shown as below [2]:
Integration of Struts, Spring and Hibernate Struts, Spring and Hibernate frameworks can be combined easily to make an efficient and complex Ecommerce applications such as web sites. The struts framework has an efficient MVC that can help in developing the presentation tier of the website. The Spring framework can provide help in handling the business logic of the website. The Hibernate framework can used in handling the website data present in the system and help in storing and retrieving the data to and from database of any kind respectively. It works effectively with DB2, MySQL, PostgreSQl, Oracle 11g.
A. Web presentation layer The web presentation layer can be easily handled by the struts web framework. It has the responsibility for handling user requests and forwarding the responses back to client/users. It provides users with the views such as Jsp, HTML documents. [34]
206
The above explains the struts configuration file and the action mapping associated with it. B. Business Logic Layer The business logic layer is taken care by the spring framework. The main features of this framework are the IoC and AOP which are used for handling the business logic. It is also used in handling the interaction with the database layer i.e. Hibernate persistence layer with the help of its Spring DAO component. [34]
The above hibernate configuration file explains the connection name, the username and password used to connect the database the mapping resource. There can be different types of hibernate configuration files based on the type of database being used such as MySQL, Oracle 11g, DB2. III. P ROPOSED SYSTEM
The above xml file explains that the bean id is transaction manager and property specified is sessionFactory. C. Data Persistence layer The data persistence layer can be easily handled using the hibernate framework. This framework makes data connectivity easier by removing the tedious JDBC connection error handling mechanisms. This layer is being called as business logic layer. This layer handles interaction with the database (DBMS) to retrieve and store data related to website. The Hibernate executes the object mapping by XML document. [34]
The Spring framework described above which has a multitier architecture can be effectively used with many other frameworks such as Struts which can be used for web presentation layer and can be easily integrated with Hibernate persistence framework which is a powerful database connectivity layer. Although spring has its own MVC layer it can easily interoperate with the presentation tier of Struts i.e. Struts mvc. The proposed system here can be considered here with the help of a website such as that of a University management system wherein students can enroll for a course and can also avail the e-learning facility provided by the university. Students can also download papers, research papers. It can generally have three layers i.e. presentation layer, business layer and database layer.
207
The above architecture can be explained as follows in terms of model, view and controller and databases as follows: a) View- Presentation Layer The view means how data/result is being presented to the students either in the form of table, charts, graphs etc. This layer is being handled by the struts framework. It provides various views such as JSP, HTML. The university system can be efficiently developed by using the struts framework as web presentation layer. Benefits of Struts MVC are as follows1. Configuration is centralized- The mapping that has to be done is present in the XML configuration file. This allows loose coupling so changes can be made and effect of the changes can be found by just editing a single xml file. 2. Form Validation- Struts provide strong validation of the form which can be applied to the registration form of the students who wish to enroll for a course. This feature is present by default in the struts framework. The main functions of the presentation/view layer are as follows1) Whenever students register by filling a form it has to do form validation, collect the form data and display result required by the students using various views either in graphical manner or pie chart, bar graphs.
The proposed architecture for the university case study consisting of the three layers is as follows:
2) It is responsible for forwarding the request to the business layer (spring framework) and also collects responses from the business layer which does business processing and displays it to the students.
208
Spring framework is a powerful framework for building enterprise wide java applications. It can also be easily integrated with some other frameworks such as struts and hibernate frameworks for developing efficient enterprise wide java applications thereby reducing the coupling and clear separation of layers so easy to understand. Due to the lightweight feature of Spring framework it is easy to use. It can easily work with a simple web server such as Tomcat that can also be used during integration of spring with other frameworks. Considering the current scenario wherein there is struts2 framework that can be used only for web tier; spring framework that provides all layers can be used effectively for all the three tiers to build an efficient enterprise application. The Spring framework can be easily integrated with any other ORM tool such as Hibernate with the help of XML mapping and also with iBATIS. With the help of combination of Spring, Struts and Hibernate we can develop powerful enterprise wide java applications. Hibernate also provides caching technology for fast retrieval of data from databases thus improving the performance of the system.
There are many architectural benefits of Spring framework when integrated with other frameworks. They can be described as follows [3]:
209
[2]
[3]
[4]
[13]
[14]
[15] [16]
[17]
210