PDA

View Full Version : what is the use of the setter dependency injection?



priweb
Mar 1st, 2006, 09:47 AM
What is the use of the dependency setter injection ?

In a database driven app, I retrieve results, use the javabeans set methods to save stuff in javabeans and then call get on it.

What is the use of having something set externally from a xml already ?

Can someone provide an example when the setter injection can be used?

I wouldnt imaginge using it to get usernames, passwords, databaseurl because we use JNDI for that...

Is the dependency setter meant as something additional to web.xml so you dont have to get params from web.xml?

Andreas Senft
Mar 1st, 2006, 12:14 PM
Well, you are talking of model objects here (retrieved from database). Spring is not intended to have these objects in a BeanFactory. Rather the static parts of your application should be wired up in an application context.

I recommend to have a look at the samples that are shipped with spring. That should make things somewhat clearer.

Regards,
Andreas