| |
GeekInterview.com > Interview Questions > J2EE > Spring
| Print | |
Question: dependency injection
Answer: what is dependency injection ?? |
| June 06, 2008 02:38:04 |
#4 |
| aparna210 |
Member Since: June 2008 Total Comments: 2 |
RE: dependency injection |
Objects can be injected through setter or constructor. Dependency Injection means we can inject all the dependenciess to ur object in the xml file.
For example in order to establish connection ,Connection object needs datasource object.
So in the xml file first we declare a bean for DataSource ,in that we give parameters for connecting to database like url username passwordetc We delare another bean named Connection in which the above declared datasource object is injected through setter or constructor.
So at the time of startup the container reads the xml file. ann all the required objects are created without the developer explicitly creating objects. |
| |
Back To Question | |