Spring Introduction

Spring framework makes developing enterprise application easier and simple to code, now days Spring working in full swing and now each java application demand Spring. Lets discuss the life of developers without the Spring Framework then will jump into Spring so that we can easily understand the difference and benefit of Spring in an application.

Life without Spring
– I will take my own example, when I was working on my first application for enterprise application, I have to create a component for my application which will be performing the customer management, at that time EJB was on boom, so I have chosen EJB to create this component, to start I have created several classes like Home interface, local interface and bean, additionally i have to create deployment descriptor for the bean created. Now I was afraid since 20+ number of component were still need to be created, so after analyzing and research I got to know about the XDoclet, which helps me in creating my component’s supporting files with some clicks. it would feel like very easy and comfortable to build application.

Now, I have to look into the component’s business logic. After implementing the business logic in component, I was looking to test my logic, I was run the container and verify the test case, but fail to verify due to some issue in code, I change it and again i have to deploy the code and run container again, after so many iterations I felt another problem in our software creation cycle with EJB. Some how I manage to test the all scenarios for the applications and successfully delivered it on time, with so much effort and problems.
I used to compile all my mistakes and problem  faced during the development of application after application delivered. Please see below what I have written:

  1. Discomfort in creating Component’s Multiple supporting files
  2. Testing Slow, Re-starting the Container.

EJB, why to use EJB, only and only service it provide. Otherwise its really very painful to create multiple files. I was so much afraid that I swear not to use EJB in my future application creation, but I was not alone to decide which technology needs to be used, else I was not gonna use it again.

How Spring help?
– Spring helps developer to minimize the effort of creating the an enterprise application, which EJB doesn’t provide the service to developer.  So Spring strives to be deliver the best services to developer which makes Spring developers favorite and simplifying the development model of creating an J2EE enterprise application.
Spring is helping to developer with the given below philosophy:

  1. Designing of an application is more important then underlying technology used.
  2. Loosely coupled design with Interface is a good model.
  3. Code should be easy to test.

What is Spring?
– Spring is an open source framework, written by Rod Jhonson and explain the framework in his book
“Expert One-on-One: J2EE Design and development”. According to Jonson, Spring is created to address to handle the complexity of application.

Spring is a light-weight IOC and AOP container framewok. Now we will check what exactly Spring gonna do to make developer’s life easy, Spring can be characterized into 5 as below:

  1. Light-weight
  2. IOC(Inversion of Control)
  3. Aspect Oriented Programming
  4. Container
  5. Framework.
Light-weight, Spring is a Light-weight framework in both terms either Size or Overhead. an average full application can be consolidated in an single JAR of 1 Mb, Spring has negligible overhead, since it is much loosely coupled with the implementation of IOC concept.

IOC(Inversion of Control), Spring promotes loos coupling between elements through a well known technique of IOC, by applying IOC in Spring Object passively given their dependency rather than creating dependent objects. It works like reverse-JNDI, instead of an object looking up dependencies through container, container provide the dependency to the objects.

Aspect Oriented Programming, This is concept introduced in Spring which separate application’s Business logic with other system related codes(like Transaction, Exception handling and Audit trails) which was applied with business logic till now.

Container, Spring handle and control the objects life cycle, which makes it work like container.

Framework, Spring makes it possible to configure and compose complex application from simpler components. In spring, application objects are composed decoratively, typically in an XML file.

Now Lets talk about Spring Modules, there are below types of modules in Spring:

  1. AOP
  2. O/R Mapping
  3. JDBC and DAO
  4. Web Context and Utility
  5. Application Context
  6. Model-View-Controller Framework
  7. Core Container and Supporting Utilities