What is spring framework? - ayushmathur94/DirectQuesAns_Prep GitHub Wiki
What is spring framework?
- Spring framework was designed by Rod Johnson.
- Spring is an open source framework created to address the complexity of enterprise application development.
- The Spring Framework provides a comprehensive programming and configuration model for modern Java-based enterprise applications.
- The key element of Spring is infrastructural support at the application level: spring focuses on "plumbing" of enterprise application so that teams can focus on application level business logic, without unnecessary ties to specific deployment environments.
- It provides extensions for building web applications on top of the Java EE platform.
What are features of Spring ?
Following are few of the features and benefits of using Spring Framework:
1. Lightweight - Spring is light weight when it comes to size and transparency. The basic version of spring framework is around 2mb.
2. Inversion of Control (IOC) - loose coupling is achieved in spring using the technique of Inversion of Control . The objects give their dependencies instead of creating or looking for dependent objects.
3. Container - Spring contains and manages the life-cycle and configuration of application objects.
4. MVC framework - Spring comes with MVC web application framework, built on core spring functionality. This framework is highly configurable via strategy interfaces and accommodates multiple view technologies like JSP, velocity, POI, etc.
5. Transaction Management - Spring framework provides a generic abstraction layer for transaction management. This allowing the developer to add the pluggable transaction managers, and making it easy to demarcate transactions without dealing with low-level issues.
6. JDBC Exception Handling - The JDBC abstraction layer of Spring offers a meaningful exception hierarchy, which simplifies the error handling strategy. Spring provides a convenient API to translate technology-specific exceptions (thrown by JDBC, Hibernate or JDO, etc) into consistent, unchecked exceptions.
7. Integration with Hibernate, JDO and ibatis - Spring provides best integration services with Hibernate, JPA, JDO and ibatis.
Name some of the important Spring Modules?
Spring comprises of seven modules. They are:
1) Spring Core Module: The Spring Core , which is the core component of the Spring framework, provides the IOC container. There are two types of implementations of the Spring container, namely bean factory and application context. Bean Factory is defined using the org. springframework.beans.factory.BeanFactory interface and acts as a container for beans. The bean factory container allows us to decouple the configuration and specification of dependencies from program logic. In spring framework, the bean factory acts as a central IOC container that is responsible for instantiating application objects. It also configures and assembles the dependencies between these objects. There are numerous implementations of the BeanFactory interface. The XMLBeanFactory class is the most common implementation of the BeanFactory interface.
2) Spring Application Context : The Spring Application Context module is based on the core module. The Application Context is spring's advanced container. org.springframework.context.ApplicationContext is an interface of BeanFactory. Similar to BeanFactory , it can load bean definitions, wire beans together and dispense beans upon request. Additionally, it adds more enterprise- specific functionality such as the ability to resolve textual messages from a properties file and the ability to publish events to interested event listeners. It also supports functionalities like internationalization, validation and resource loading etc.
3) Spring AOP Module: Similar to Object - Oriented Programming (OOP), which breaks down the applications into hierarchy of objects, AOP breaks down the programs into aspects or concerns. In Spring AOP, the aspects are regular Spring beans or regular classes annotated with @Aspect annotation. These aspects help in transaction management and logging and failure monitoring of an application.
4) Spring ORM Module: The Spring Framework doesn't have its own ORM implementation. But, it offers integration layers with other popular Object-Relational Mapping tools, such as Hibernate, iBATIS, JDO , etc. Spring ORM supports DAO, which provides a convenient way to build the following DAO-based solutions. a). Simple declarative transaction management b). Transparent exception handling c). Thread safe, lightweight template classes d). DAO support classes e). Resource management
5) Spring DAO module: The DAO package in Spring Framework provides DAO support by using data access technologies like JDBC, Hibernate , JDO, etc. It introduces a JDBC abstraction layer, eliminating the need for providing tedious JDBC coding. It also provides programmatic as well as declarative transaction management classes. Spring DAO package supports heterogeneous Java Database Connectivity and Object Relational mapping, which helps Spring work with several data access technologies. For easy and quick access to database resources, the Spring framework provides abstract DAO base classes. Multiple implementations are available for each data access technology supported by the Spring framework.
6) Spring MVC module: The MVC module of Spring implements the MVC architecture for creating Web applications. It separates the code of model and view components of a Web application. In Spring MVC, when a request is generated from the browser, it first goes to the DispatcherServlet class (Front Controller), which dispatches the request to a controller (SimpleFormController class or AbstractWizardformController class ) using a set of handler mappings. The controller extracts and processes the information embedded in a request and sends the result to the DispatcherServlet class In the form of the model object. Finally, the DispatcherServlet class uses ViewResolver classes to send the results to a view, which displays these result to the users.
7) Spring Web: Spring's Web module provides basic web-oriented integration features, such as multipart file-upload functionality, the initialization of IOC container using Servlet listeners and a web oriented application context. The Web-Socket module of the SpringFramework provides support for Web-Socket. It provides bi-direction communication between server side and client side in web-related applications. The Web-Portlet Spring module insists on implementing MVC in a portlet environment. The functionality of Web-Portlet is same as that of Web-Servlet of Spring.