This essay has been submitted by a student. This is not an example of the work written by our professional essay writers.
Spring frame work was introduced in the year 2003 by Rod Johnson as a simple framework intended to provide an easy way to wire application components together which has grown into an alternative platform to the traditional full-stack Enterprise Java platform (Java EE). It provides comprehensive infrastructure for developing java applications. It includes features such as support for transactions, security, messaging, remoting, Web Services, persistence etc., normally found on expensive or heavyweight full-stack application servers. It handles the infrastructure so that the developer can focus on the application.
Spring Framework is implemented completely in Java and runs on a J2SE platform unlike EJB 3.0 which requires a Java EE container. This makes it easy to test applications in a standalone environment. The Spring platform follows plain Java programming model. It provides enterprise services to a POJO at runtime using XML configuration files, as opposed to creating a bean in Java EE. Its flexible XML or annotation based configuration, support for Aspect Oriented Programming, and powerful Enterprise Service layer abstractions and functionality gives it a number of benefits when compared to traditional Java EE. Applications written targeting at Spring has less code and reduced complexity. It allows greatly increased portability across multiple environments, greater code re-usability, and makes it much easier to test application code.
Unlike single-tier frameworks like Struts or Hibernate, Spring Framework consists of several modules which provide a range of services for building web applications, front-end applications etc., and helps to structure whole applications in a consistent, productive manner, pulling together best-of-breed single-tier frameworks to create a coherent architecture.
Spring Framework is much simpler than other Java EE solutions. Spring allows building applications from POJO (Plain Old Java Object) that do not need to implement special interfaces or be aware of container lifecycle. At the same time, it gives the possibility to use more sophisticated services like transaction support, database access, security etc. These objects can be configured using the Inversion of Control principle which allows the developers to rely on the container to create, write and manage objects instead of wiring them together. This provides loose coupling between the objects. Also, by using Spring test support classes it is possible to make an integration test with ease. This approach significantly simplifies a unit testing. Spring core feature like Dependency Injection makes applicationâ€™s modules more independent from each other.
Spring Framework can be logically broken down into two major types of functionalities.
At the heart of spring is the kernel. It is responsible for configuring application components, managing the invocation pipeline request serviced by those components and enhancing the components in an application.
The enterprise layer consisting of Spring extension mechanisms such as namespace handlers, post-processors that provide functionality and abstraction around enterprise features such as data access, transactions, messaging, remoting and a number of others.
Fig 1: Runtime overview of Spring Framework
The Spring kernel consists of the core Spring container which plays the fundamental role of managing application components, the Aspect Oriented Programming which manages the invocation of component operations, resource loading runtime and event subsystem.
The Spring container is the core engine that drives component configuration and management. It is responsible for making sure that the objects receive any dependencies they need and hence is called Dependency Injection or inversion of control container. The Spring managed objects, called beans, are typically configured using XML configuration files and/or annotations contained within the class itself. The Spring container provides the runtime context for an application called Application Context. There can be multiple Application Contexts in a single application. It must be created before any application components are created. It may be constructed explicitly through user code or using one of the Springâ€™s bootstrapping mechanisms such as DispatcherServlet for a web application. It adapts itself to the runtime environment by installing a suitable resource loading implementation. It also discovers and registers the namespace handlers which enable the core container to understand the XML schema configuration files and translate the elements and attributes into runtime components. The application context will fail if there is an error in detecting and registering the namespace handlers.
The next critical tasks after bootstrapping are to determine which applications components need to be created, how they have to be configured, and the supporting services they need. The configuration information often comes from multiple sources like multiple XML files. These sources are identified during the bootstrapping phase. Also, additional configuration metadata sources can be specified in the configuration files to supplement them. The component scanning facility in Spring sources additional configuration metadata by scanning resources on the class path. The registered namespace handlers and other metadata handlers process the configuration sources to determine the set of application and infrastructure components to be instantiated. They produce a set of component definition objects that represent the desired application configuration. Services from the enterprise services layer may have registered one or more post processors that iterate over the component definitions to augment them.
This ensures that the application â€œblueprintâ€Â is successfully created in memory and is ready for realization as fully functioning application objects in the next phase.