ContactUs

Please send your Questions & Answers or Feedback to "mohan@javabook.org"

What is Spring?

Spring performs two major roles for a Java application.

 

First Spring is a container that manages all or some of the objects used by the application. Behind the scenes Spring configures your objects with what they need to in order to perform their roles in the application. If you need a Data Access Object, you ask the Spring container to provide one that is already configured with values for its data source and other properties.

 

Spring is also a framework because it provides libraries of classes that make it easier to accomplish common tasks such as transaction management, database integration, email, and web applications.

 

What does Spring provide ?

Spring is a lightweight framework. Most of your Java classes will have nothing about Spring in their source code.  This means that you can easily transition your application from the Spring framework to something else.  It also means that transferring an existing application to use the Spring framework doesn’t have to mean a complete code rewrite.

All Java applications that consist of multiple classes have inter-dependencies or coupling between classes.  Spring helps us develop applications that minimize the negative effects of coupling and encourages the use of interfaces in application development.  Using interfaces in our applications to specify type helps make our applications easier to maintain and enhance later.

 

The Spring framework helps developers clearly separate responsibilities.  Many Java applications suffer from class bloat – that is a class that has too many responsibilities.  For example a service class that is also logging information about what its doing.  Think of two situations – one is you’ve been told by your supervisor to do your normal work but also to write down everything you do and how long it takes you.  You’d be even busier and less responsive. 

 

A better situation would be you do your normal work, but another person observers what you’re doing and records it and measures how long it took.  Even better would be if you were totally unaware of that other person and that other person was able to also observe and record other people’s work and time. 

What are the modules Spring Provides ?

The Core package is the most fundamental part of the framework and provides the IoC and Dependency Injection features.

The Context package build on the solid base provided by the Core package: it provides a way to access objects in a framework-style manner in a fashion somewhat reminiscent of a JNDI-registry.

The DAO package provides a JDBC-abstraction layer that removes the need to do tedious JDBC coding and parsing of database-vendor specific error codes.

The ORM package provides integration layers for popular object-relational mapping APIs, including JPA, JDO, Hibernate, and iBatis.

Spring's AOP package provides an AOP Alliance-compliant aspect-oriented programming implementation allowing you to define, for example, method-interceptors and pointcuts to cleanly decouple code implementing functionality that should logically speaking be separated.

Spring's Web package provides basic web-oriented integration features, such as multipart file-upload functionality, the initialization of the IoC container using servlet listeners and a web-oriented application context.

Spring's MVC package provides a Model-View-Controller (MVC) implementation for web-applications. Spring's MVC framework is not just any old implementation, it provides a clean separation between domain model code and web forms, and allows you to use all the other features of the Spring Framework.

What are the benefits of Spring Framework?

Not a J2EE container. Doesn’t compete with J2EE app servers. Simply provides alternatives.

POJO-based, non-invasive framework which allows a la carte usage of its components.

Promotes decoupling and reusability 

Reduces coding effort and enforces design discipline by providing out-of-box implicit pattern implementations such as singleton, factory, service locator etc.

Removes common code issues like leaking connections and more

Support for declarative transaction management

Easy integration with third party tools and technologies.

What is Inversion of Control ?

Instead of objects invoking other objects, the dependant objects are added through an external entity/container.

Also known as the Hollywood principle – “don’t call me I will call you”

Dependency injection

Dependencies are “injected” by container during runtime.

Beans define their dependencies through constructor arguments or properties

Prevents hard-coded object creation and object/service lookup.

Loose coupling

Helps write effective unit tests

Related Posts Plugin for WordPress, Blogger...
Flag Counter