<<

© November 2015 | IJIRT | Volume 2 Issue 6 | ISSN: 2349-6002

SPRING MVC FRAMEWORK Simran Bhatti Computer Science, Maharishi Dayanand University

ABSTRACT:- : There are a variety of  Aspect-oriented programming: This frameworks used when we need to build web module enables implementing cross- applications. Spring is also one of the web cutting concerns. applications framework. It can be thought of as a  Authentication and authorization: These lead framework because it provides support to are the configurable security processes that various other frameworks such as Struts, support a range of standards, protocols, Hibernate, EJB, JSF etc. The framework can be tools and practices. defined as a structure where we can find solution  Convention over configuration: A rapid of the various technical problems. Spring application development solution for Framework is an application framework and Spring-based enterprise applications. inversion of control container for the Java  Data access: Working with relational platform. The framework's core features can be database management systems on the Java used by any Java application, but there are platform using JDBC and object-relational extensions for building web applications on top of mapping tools and with NoSQL databases. the Java EE platform.  Inversion of control container: Configuration of application components Index Terms: Spring MVC, Inversion of control, and lifecycle management of Java objects, Pojo classes, container, framework. done mainly through .  Messaging: configurative registration of message listener objects for transparent I. INTRODUCTION message-consumption from message is an application queues. framework and inversion of control container for  Model–view–controller: an HTTP- the Java platform. This framework was developed and servlet-based framework providing by Rod Johnson in 2003. It makes the easy hooks for extension and customization for development of Java EE applications. The web applications. framework's core features can be used by any Java  Remote access framework: application, but there are extensions for building configurative RPC-style marshalling of web applications on top of the Java EE platform. The Java objects over networks framework does not impose any supporting RMI, CORBA and HTTP-based specific programming model but it has become protocols. popular in the Java community as an alternative to  Transaction management: unifies several the Enterprise JavaBeans (EJB) model. The Spring transaction management and Framework is also open source which proves to be coordinates transactions for Java objects. an advantage. We can use it for creating a wide  Remote management: configurative variety of web applications. Most of the exposure and management of Java objects organizations use this framework. for local or remote configuration. II. SPRING-Modules  Testing: support classes for writing unit The Spring Framework includes several modules tests and integration tests that provide a wide variety of services. They are:  Spring Core Container: This is the base module of Spring. It provides various spring containers.

IJIRT 142760 290

INTERNATIONAL JOURNAL OF INNOVATIVE RESEARCH IN TECHNOLOGY © November 2015 | IJIRT | Volume 2 Issue 6 | ISSN: 2349-6002

Spring Framework Modules III. Spring-IOC and Dependency Injection These are the that are used to remove dependency from the programming code. They make the code easier to test and maintain. Dependency Injection (DI) is a that removes the dependency from the programming code so that it can be easy to manage and test the application. Dependency Injection makes our programming code loosely coupled. Advantages of Dependency Injection Inversion of control  makes the code loosely coupled so easy to maintain IV. MVC- Design & its Architecture  makes the code easy to test MVC basically stands for the Model View Inversion of Control Controller. It is a software for This provides a consistent means of configuring and implementing user interfaces. It divides a given managing Java objects using reflection. The IOC software application into three different but container is responsible for managing object interconnected parts, so as to separate internal lifecycles of specific objects , creating these objects, representations of information from the ways that calling their initialization methods, and configuring information is presented to or accepted from the these objects by wiring them together. user. IOC makes the code loosely coupled. In such case, It was one of the influential insights in the early there is no need to modify the code if our logic is development of graphical user interfaces, and one of moved to new environment. In Spring framework, the first approaches to describe and implement IOC container is responsible to inject the software constructs in terms of their responsibilities. dependency. We provide metadata to the IOC The three components of the MVC are: - container either by XML file or annotation.  The Model, which encapsulates the application data and in general they will consist of POJO classes.

IJIRT 142760 291

INTERNATIONAL JOURNAL OF INNOVATIVE RESEARCH IN TECHNOLOGY © November 2015 | IJIRT | Volume 2 Issue 6 | ISSN: 2349-6002

 The View is responsible for rendering the V. The Dispatcher Servlet model data and in general it generates The Spring Web model-view-controller (MVC) HTML output that the client's browser can framework is designed around a Dispatcher interpret. Servlet that handles all the HTTP requests and  The Controller is responsible for responses. The entire request processing workflow processing user requests and building of the Spring Web MVC Dispatcher Servlet is appropriate model and passes it to the view depicted in the following diagram: for rendering.

The Spring applications are loosely coupled because Following is the sequence of events corresponding of dependency injection. to an incoming HTTP request to Dispatcher Servlet:  Easy to test  After receiving an HTTP The Dependency Injection makes easier to test the request, Dispatcher Servlet consults the application. The EJB or Struts application require Handler Mapping to call the server to run the application but Spring framework appropriate Controller. doesn't require server.  The Controller takes the request and calls  Lightweight the appropriate service methods based on Spring framework is lightweight because of its the used GET or POST method. The POJO implementation. The Spring Framework service method will set model data based doesn't force the programmer to inherit any class or on defined business logic and returns view implement any . That is why it is said non- name to the Dispatcher Servlet. invasive.  The Dispatcher Servlet will take help  Fast Development from View Resolver to pickup the defined The Dependency Injection feature of Spring view for the request. Framework and it support to various frameworks  Once view is finalized, The Dispatcher makes the easy development of JavaEE application. Servlet passes the model data to the view  Powerful abstraction which is finally rendered on the browser. It provides powerful abstraction to JavaEE specifications such as JMS, JDBC, JPA and JTA. VI. Advantages of Spring Framework  Declarative support  Predefined Templates It provides declarative support for caching, Spring framework provides templates for JDBC, validation, transactions and formatting. Hibernate, JPA etc. technologies. So there is no need to write too much code. It hides the basic steps of VII. References these technologies. [1]https://en.wikipedia.org/wiki/Spring_Framework  Loose Coupling

IJIRT 142760 292

INTERNATIONAL JOURNAL OF INNOVATIVE RESEARCH IN TECHNOLOGY © November 2015 | IJIRT | Volume 2 Issue 6 | ISSN: 2349-6002

[2]http://www.javatpoint.com/spring-3-mvc- tutorial [3]docs.spring.io/spring- framework/docs/current/spring.../mvc.html

IJIRT 142760 293

INTERNATIONAL JOURNAL OF INNOVATIVE RESEARCH IN TECHNOLOGY