Spring 3.0 IOC Walk-Through
Take a quick recap of Spring 3.0 IOC concepts.This article will help people who has knowledge on Spring 3.0 IOC and wants to quickly walk through the spring concepts.It could also help interviews.
Introduction to dependence injection and loose coupling.
What is loose coupling ?
The components of your application should assume as little as possible about other components. A loose coupled system is more flexible to enhance,and on the other hand a tightly coupled system is hard to enhance or lacks flexibility.
How does a programmer achieve loose coupling in Java without using Spring ?
In Java programming to the interfaces, increases loose coupling.For an example List is an interface and the implementation classes are ArrayList, LinkedList and Vector. While writing code that uses these implementation classes, rather writing code like ArrayList al=new ArrayList() , it is better to write List list=new ArrayList(). This way we can enhance loose coupling.
What is DI or Dependency Injection ?
In OOP an object never stands alone , ie it needs or composed of certain other objects. The less the Composing object knows about the composed object is called loosely coupled system.But it is not possible to have no dependency or zero couple system. So , a Dependency Injection is a technique is OOP to resolve dependency between composed and composing object.
- What is the difference between DI ( Dependency Injection ) and IOC ( Inversion Of Control ) ?
What is the difference between Dependacy pull and dependacy push ?
Introduction To Spring
What is Spring ?
Spring is a lightweight container and a framework provides your application to achieve loose coupling.It provides API to interact with the components managed by the container.
Why they call Spring is a light weight container, What is the significance of light weight ?
While we did not have Spring in place, we used to use the concept of Service Locator ( a form of IOC, also known as Dependency lookup) to locate our business components. And these business components ( For Ex: EJB) were made avaialable to the consumer by the application server like JBoss, WebLogic etc. These servers are needed when our business objects are in client server environment, But what if our applications are not client server based ?. In this case application server are not useable and if ever can made usable, these are really big Java applications. Bad that we had to kill a mosquito by a cannon. Thanks to Spring which is much less in size and can be used in a desktop application, and the same code can be exposed as business component even in client/server environment.
What is Bean in Spring's context ?
What is Bean Factory ?
A BeanFactory is responsible for managing components and their dependencies