Spring Framework Introduction

Spring is a light-weight IoC (Inversion of Control) Container and AOP (Aspect-oriented Programming) framework. Spring makes easier the development, testing and deployment of Java enterprise applications. Spring comes with its own MVC components that can be used in MVC Web based applications. It provides support for all Java development applications; to list a few, Hibernate, Web services, Struts, JSF (JavaServer Faces), AJAX and JPA (Java Persistence Architecture API) and other frameworks.

Light-weight container

Unlike old J2EE containers (Servlet & JSP container runs in a web server, EJB container runs in Application Server), Spring container can run on standalone JVM (no server dependencies exist to run the container). Servlet, JSP and EJB containers are heavyweight containers as they depend on underlying operating system for execution. Spring container is known as lightweight because it can run at command-prompt without depending on other containers.

Just like any other container, Spring container provides services of which two are explained below.

i) Resource Management Service

Creating and removing objects: Spring container can create single object for any number of client requests and such objects are called as Singleton. Also it can create separate objects for each client request. Such objects are called as Prototype objects.

ii) Life cycle Service

LS: LS means one method invokes after object creation and one method invokes before object destruction. Such methods are predefined in old J2EE containers such as init() and destroy() methods of Servlet. But, Spring permits to create user-defined life cycle methods that can be called in place of pre-defined life cycle methods. Just we need to mention them in Spring configuration file.

Why Spring container is called as IoC container?

In addition to providing standard container services, Spring container additionally does Dependency Injection also. Because of Dependency Injection (which is opposite principle to Dependency Lookup), it is called as IoC container. The meaning of dependency injection and its types will be known in the first program.

Spring is open-source framework developed by Rod Johnson and the latest 3.0 version was released on 23-06-2011). Spring 3.0 framework was released with major features supporting Java 5. Spring 3.0 version supports Web services. EL (Expression Language), AspectJ and Spring Object/XML mapping (oxm).

Features of Spring 3.0 Framework

  • Java 5 Support: Spring 3.0 core API is compatible with JDK 5 or higher versions. Spring 3.0 provides support to annotation-based configuration, JDK 5 features such as generics and varargs etc. Spring 3.0 is all compatible with EE5.
  • Expression language – Spring Expression Language (SpEL): Programmers can make use of Spring 3.0 expression language. The Spring EL is useful while defining XML and Annotation based beans.
  • Support for Comprehensive REST Webservices: Spring 3.0 supports REST Web services. The acronym REST stands for Representational State Transfer, which basically means that each unique URL is a representation of some object.
  • Java EE 6 Support: Spring 3.0 framework supports many features of EE 6 such as JPA 2.0 (Java Persistence API) and JSF 2.0.
  • Annotation based formatting support: Spring comes with Annotation based formatting support.

Spring comes with many modules of which two are very important – Core module (provides dependency injection (IoC) and AOP module (adds extra effects like separating business logic from services).

Leave a Comment

Your email address will not be published.