• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

in spring application, no any "new" operator for create instance?

 
peter tong
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I see many spring tutorial and they said about dependency injection, but is it in a spring application, there is no any "new" operator used?
as in local variable, still need to use "new" keyword, is it?
 
Ayan mallick
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think in spring new operator we use when inside a singleton bean we want to use any bean which we want fresh with every request.for example say inside a controller bean we want a form bean to display a form.
controller bean is singleton so only once it will be formed. but form bean needs to be created with every request because user data is going to change state of that form bean.

I think in this scenario instead of using dependency injection we use new operator.


Thanks

Ayan
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic