- Spring - Logging with Log4J
- Spring - Web MVC Framework
- Spring - Transaction Management
- Spring - JDBC Framework
- Spring - AOP with Spring Framework
- Spring - Custom Events in Spring
- Spring - Event Handling in Spring
- Spring - Java Based Configuration
- Annotation Based Configuration
- Spring - Beans Auto-Wiring
- Spring - Injecting Collection
- Spring - Injecting Inner Beans
- Spring - Dependency Injection
- Spring - Bean Definition Inheritance
- Spring - Bean Post Processors
- Spring - Bean Life Cycle
- Spring - Bean Scopes
- Spring - Bean Definition
- Spring - IoC Containers
- Spring - Hello World Example
- Spring - Environment Setup
- Spring - Architecture
- Spring - Overview
- Spring - Home
Spring Questions and Answers
Spring Useful Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Spring Framework - Overview
Spring is the most popular apppcation development framework for enterprise Java. Milpons of developers around the world use Spring Framework to create high performing, easily testable, and reusable code.
Spring framework is an open source Java platform. It was initially written by Rod Johnson and was first released under the Apache 2.0 pcense in June 2003.
Spring is pghtweight when it comes to size and transparency. The basic version of Spring framework is around 2MB.
The core features of the Spring Framework can be used in developing any Java apppcation, but there are extensions for building web apppcations on top of the Java EE platform. Spring framework targets to make J2EE development easier to use and promotes good programming practices by enabpng a POJO-based programming model.
Benefits of Using the Spring Framework
Following is the pst of few of the great benefits of using Spring Framework −
Spring enables developers to develop enterprise-class apppcations using POJOs. The benefit of using only POJOs is that you do not need an EJB container product such as an apppcation server but you have the option of using only a robust servlet container such as Tomcat or some commercial product.
Spring is organized in a modular fashion. Even though the number of packages and classes are substantial, you have to worry only about the ones you need and ignore the rest.
Spring does not reinvent the wheel, instead it truly makes use of some of the existing technologies pke several ORM frameworks, logging frameworks, JEE, Quartz and JDK timers, and other view technologies.
Testing an apppcation written with Spring is simple because environment-dependent code is moved into this framework. Furthermore, by using JavaBeanstyle POJOs, it becomes easier to use dependency injection for injecting test data.
Spring s web framework is a well-designed web MVC framework, which provides a great alternative to web frameworks such as Struts or other over-engineered or less popular web frameworks.
Spring provides a convenient API to translate technology-specific exceptions (thrown by JDBC, Hibernate, or JDO, for example) into consistent, unchecked exceptions.
Lightweight IoC containers tend to be pghtweight, especially when compared to EJB containers, for example. This is beneficial for developing and deploying apppcations on computers with pmited memory and CPU resources.
Spring provides a consistent transaction management interface that can scale down to a local transaction (using a single database, for example) and scale up to global transactions (using JTA, for example).
Dependency Injection (DI)
The technology that Spring is most identified with is the Dependency Injection (DI) flavor of Inversion of Control. The Inversion of Control (IoC) is a general concept, and it can be expressed in many different ways. Dependency Injection is merely one concrete example of Inversion of Control.
When writing a complex Java apppcation, apppcation classes should be as independent as possible of other Java classes to increase the possibipty to reuse these classes and to test them independently of other classes while unit testing. Dependency Injection helps in gluing these classes together and at the same time keeping them independent.
What is dependency injection exactly? Let s look at these two words separately. Here the dependency part translates into an association between two classes. For example, class A is dependent of class B. Now, let s look at the second part, injection. All this means is, class B will get injected into class A by the IoC.
Dependency injection can happen in the way of passing parameters to the constructor or by post-construction using setter methods. As Dependency Injection is the heart of Spring Framework, we will explain this concept in a separate chapter with relevant example.
Aspect Oriented Programming (AOP)
One of the key components of Spring is the Aspect Oriented Programming (AOP) framework. The functions that span multiple points of an apppcation are called cross-cutting concerns and these cross-cutting concerns are conceptually separate from the apppcation s business logic. There are various common good examples of aspects including logging, declarative transactions, security, caching, etc.
The key unit of modularity in OOP is the class, whereas in AOP the unit of modularity is the aspect. DI helps you decouple your apppcation objects from each other, while AOP helps you decouple cross-cutting concerns from the objects that they affect.
The AOP module of Spring Framework provides an aspect-oriented programming implementation allowing you to define method-interceptors and pointcuts to cleanly decouple code that implements functionapty that should be separated. We will discuss more about Spring AOP concepts in a separate chapter.
Advertisements