Spring framework is a java platform, that provides comprehensive infrastructure support for developing java-based enterprise application. Spring handles java application’s complexities and enables you to focus on your core business development. It provides libraries for handling lots of common functionality so that you do not invent the wheel again. Spring enables you to build you enterprise level application from plain java objects (Pojo).
Spring framework is highly decupled and has many modules that can be used together or as individual as per user’s need.
Benefits of Using Spring Framework for your next assignment:
1. Spring frameworks is very lightweight framework
2. It enables developers to develop large scale applications using POJOs only and removes dependencies on EJB containers or application containers, only servlet containers are sufficient for running spring-based application.
3. It is enables developers to keep object loosely coupled and handle complete life cycle of objects itself.
4. Reduces lots of boiler plate code.
5. Spring provides a consistent transaction management interface that can scale down to a local transaction and scale up to global transactions (using JTA)
And many more…
Spring Modules: Spring framework, provides more than 20 modules, some of them are shown in below figure.
These modules are grouped into Core Container, Data Access/Integration, Web, AOP (Aspect Oriented Programming), Instrumentation, and Test etc.
Some important modules of Spring Framework:
· Core Container: Core container is consisting of four modules: Core, Beans, Context, Expression Language.
o Core and Beans: The Core and Beans modules provide a basics infrastructure or fundamental building blocks for any Spring Application. It includes IOC and DI features. It uses factory patter for creating beans (Spring managed pojo objects). BeanFactory is factory pattern implementation that is responsible for objects for your classes in your application. It removes the programmatic logic for managing object’s life cycle. You can rely on Spring for the same.
o Context:Context module is build on the top of Core and Beans module. Context module is responsible to provide an access interface for beans managed by Core and Beans modules. he Context module inherits its features from the Beans module and adds support for internationalization (using, for example, resource bundles), event-propagation, resource-loading, and the transparent creation of contexts by, for example, a servlet container. The Context module also supports Java EE features such as EJB, JMX, and basic remoting. The ApplicationContext interface is the focal point of the Context module.
o Expression Language: This module provides a powerful expression language for querying and manipulating an object graph at runtime. It is an extension of the unified expression language (unified EL) as specified in the JSP 2.1 specification. The language supports setting and getting property values, property assignment, method invocation, accessing the context of arrays, collections and indexers, logical and arithmetic operators, named variables, and retrieval of objects by name from Spring's IoC container. It also supports list projection and selection as well as common list aggregations.
· Data Access and Integration: The Data Access/Integration layer consists of the JDBC, ORM, OXM, JMS and Transaction modules. It enables you to connect with data sources, like database, or java messaging services etc. It brings data into your application and persist data back to the data source.
· Web: The Web layer consists of the Web, Web-Servlet, Web-Struts, and Web-Portlet modules. Spring's Web module provides basic web-oriented integration features such as multipart file-upload functionality and the initialization of the IoC container using servlet listeners and a web-oriented application context. It also contains the web-related parts of Spring's remoting support.
· AOP: Stands for Aspect Oriented Programming. Spring's AOP module provides an AOP Alliance-compliant aspect-oriented programming implementation allowing you to define, for example, method-interceptors and pointcuts to cleanly decouple code that implements functionality that should be separated.
· Test:The Test module supports the testing of Spring components with JUnit or TestNG. It provides consistent loading of Spring ApplicationContexts and caching of those contexts. It also provides mock objects that you can use to test your code in isolation.
Dependency Injection (IOC): DI or dependency injection and IOC (Inversion of Control) are fundamental concepts of Spring. I would say these concepts and their implementation has a big role in spring’s popularity. Every java application will have multiple classes and there would be some relation among them. Some classes will be dependent on some other classes. So, injection of one reference into any other is called injection the dependencies. Although the Java platform provides a wealth of application development functionality, it lacks the means to organize the basic building blocks into a coherent whole, leaving that task to architects and developers. True, you can use design patterns such as Factory, Abstract Factory, Builder, Decorator, and Service Locator to compose the various classes and object instances that make up an application. However, these patterns are simply that: best practices given a name, with a description of what the pattern does, where to apply it, the problems it addresses, and so forth. Patterns are formalized best practices that you must implement yourself in your application.
IOC is a very generic term or concept that ask you to invert the control. That means in throwing the responsibility of doing something to someone else. Yes, that interesting. In Spring, what we are inverting and how we are achieving is Dependency Injection. So, DI is a concrete implementation or realization of IOC, So IOC is achieved through DI. The Spring Framework Inversion of Control (IoC) component addresses this concern by providing a formalized means of composing disparate components into a fully working application ready for use. The Spring Framework codifies formalized design patterns as first-class objects that you can integrate into your own application.
This is just an introductory article for giving you a very basic idea about Spring. In Our next article we create “Hello World” web application using spring MVC and will discuss spring beans in detail.
No comments:
Post a Comment