Wednesday, June 18, 2008

Spring Framework

For More CLick ME

Introduction:

The content of this document is not a detailed description on Spring or Hibernate. This document contains how we have used Spring and Hibernate in our project. I have shared most of the learning experiences I have gathered during execution of the project here. Those who have some prior knowledge on J2EE framework would be able to understand these. Our project got executed using JBoss-3.2 server and Hibernate as back end. We have developed our codes in Eclipse-3 platform using Spring framework.

Finally the war file was deployed in Linux and it was platform independent.

Spring’s MVC Architecture:

Spring’s MVC framework is designed based on Dispatcher Servlet which dispatches requests to respective request-handlers better known as controllers. Spring can bind any object as a command object which will be available directly in the controller class. To do any validation of the form objects, you need a validation class which is provided by this framework.

After validation, if you want to send some data to the JSP that can be done via referenceData method. The controller class returns a view name (the JSP name) and a model Map. The model contains all the bean names and corresponding objects you need to send to the view. View names and it’s location is resolved via view Resolver bean provided in the XML mapping.

Features of Spring:

• Clear separation of roles – controller, validator, command object, form object, model object, Dispatcher Servlet, handler mapping, view resolver etc. separate objects for each role.

• Powerful and straightforward configuration, easy referencing across contexts of both framework and application classes as beans.

• Separate controllers for different scenarios – plain, form, wizard, simple, multiaction.

• Customizable binding and validation – binding of any object is possible along with validation after submission of form.

• Customizable handler/controller mapping and view resolver – can handle simple requests via URLs or even can intercept a URL, and view resolvers help to locate the actual path of views.

• Map model transfer – transfer of any number of objects is possible via model object, no need to set them as request attributes.

• Supports Theme and JSTL tags with or without Spring tags.

Dispatcher Servlet:

Spring's web MVC framework is a request-driven web MVC framework, designed around a servlet that dispatches requests to controllers and offers other functionality facilitating the development of web applications. Spring's DispatcherServlet does that.The Spring DispatcherServlet has a couple of special beans it uses, in order to be able to process requests and render the appropriate views. These beans are included in the Spring framework and can be configured in the WebApplicationContext, just as any other bean would be configured. Right now, we'll just mention some of them.

For most of the beans, defaults are provided so you don't have to worry about configuring them.

• handler mappings – for matching the URL and send them to a controllers

• controllers – the actual controller beans

• view resolver – to find the exact location of the view (JSP)

• theme resolver – capable of resolving themes for the application

• handlerexceptionresolver – offers functionality to map different exceptions


For More CLick ME

0 comments: