This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Dependency Injection with setter injection ?

 
Raza Mohd
Ranch Hand
Posts: 247
Java MyEclipse IDE MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi All,

I am new to Spring . I was going through An article on spring injection dependency. I read following thing.

in case of Constructor Injection the dependencies are handed over at the time of object instantiation of the dependent objects whereas In case of Setter/Mutator Injection the dependencies are injected after the dependent object has already been created


If i have a Interface IUserService . Code is like that.



then please make me clear that is userService is a dependent component??
And let me know that who create the dependent object In context of following article.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Spring handles object instantiation for either constructor or setter injection.
 
Raza Mohd
Ranch Hand
Posts: 247
Java MyEclipse IDE MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok So, is userService in my case is the dependent component?

and does Spring first creates the object then injects the dependency for the dependent object?
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Raza Mohd wrote:ok So, is userService in my case is the dependent component?

I don't know what that term means in this context.
and does Spring first creates the object then injects the dependency for the dependent object?

What do you think?
 
Raza Mohd
Ranch Hand
Posts: 247
Java MyEclipse IDE MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think it first creates the object !
as we are calling a method findUser() without instantiating UserService class with implements IUserService.
how can a method be called without object.

it clears that Spring container manages the object instntiation .
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic