Introduction to Spring MVC Framework
At the beginning of the century Java EE was called J2EE, and it was a heavy and over-engineered standard. Programming EJBs was difficult and required writing a lot of boilerplate code. Java annotations had not been invented yet. Having a Java container that would take care of multi-threading, transactions, persistence, and security was nice, but developers needed a lighter container and a simpler programming model.
Rod Johnson, a talented software engineer, wrote a book titled Expert One-on-One J2EE Design and Development, which was published by Wrox at the end of 2002. A year later the book’s code samples and development recommendations were released as the Spring Framework.
The Spring Framework is a Java container that provides a living space for an application’s objects, wired to each other in a loosely coupled way in XML configuration. This loose coupling comes at a price, though — configuration files are quite large in size.
Spring Framework was built based on the inversion of control (IoC) principle: The container is responsible for the instantiation and location of the objects. IoC is also known as the Hollywood principle: “Don’t call us, we’ll call you.”
Instead of having a class called Customer reach out to some container’s registry trying to find an Order, under the Spring Framework the container would use a system of callbacks to instantiate the Order and inject it into the instance of the Customer object. This is an ...