Search This Blog

Tuesday, November 27, 2007

What Is Spring?

In the world of technology so may frame-works are coming and it’s a big question in front of us that which one is better.To solve this query I tried explaining frame-work in short. So, let’s start with Spring frame-workSpring is an open-source framework, and to Put simply, Spring is alightweight inversion of control and aspect-oriented containerframework.Okay, that’s not so simple a description. But it does summarizewhat Spring does. To make more sense of Spring, let’s break this description down:■ Lightweight—Spring is lightweight in terms of both size and overhead.The entire Spring framework can be distributed in a single JAR file thatweighs in at just over 1 MB. And the processing overhead required bySpring is negligible. What’s more, Spring is nonintrusive: objects in aSpring-enabled application typically have no dependencies on Springspecificclasses.

■ Inversion of control—Spring promotes loose coupling through a techniqueknown as inversion of control (IoC). When IoC is applied, objects are passivelygiven their dependencies instead of creating or looking for dependentobjects for themselves. You can think of IoC as JNDI in reverse—instead of an object looking up dependencies from a container, the containergives the dependencies to the object at instantiation without waitingto be asked.

■ Aspect-oriented—Spring comes with rich support for aspect-oriented programmingthat enables cohesive development by separating applicationbusiness logic from system services (such as auditing and transaction management).Application objects do what they’re supposed to do—performbusiness logic—and nothing more. They are not responsible for (or evenaware of) other system concerns, such as logging or transactional support.

■ Container—Spring is a container in the sense that it contains and managesthe life cycle and configuration of application objects. You can configurehow your each of your beans should be created—either create one singleinstance of your bean or produce a new instance every time one is neededbased on a configurable prototype—and how they should be associatedwith each other. Spring should not, however, be confused with traditionallyheavyweight EJB containers, which are often large and cumbersometo work with.

■ Framework—Spring makes it possible to configure and compose complexapplications from simpler components. In Spring, application objects arecomposed declaratively, typically in an XML file. Spring also providesmuch infrastructure functionality (transaction management, persistenceframework integration, etc.), leaving the development of application logicto you.All of these attributes of Spring enable you to write code that is cleaner, moremanageable, and easier to test. They also set the stage for a variety of subframeworkswithin the greater Spring framework.