• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to create new Bean instance every time

 
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would like that every time that I'll perform :
SpringUtil.lookupComponent("myObject")
I spring will create new instance of this object

I set this bean in the relevant xml file as: scope="prototype"
but still spring created new instance on the first time and from then, every time that the same bean performed again
SpringUtil.lookupComponent("myObject") spring didn't generate new instance but returned the same old "MyObject" does anyone know why and how I can
force the lookup command to generate new instance for me.

I also saw in Spring documentation that the definition of scope prototype is:

Scopes a single bean definition to any number of object instances.


Which means that Spring doesn't necesseraly generate new instance every time that the same parent bean requires it.

 
Ranch Hand
Posts: 1936
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Could you please to post the code of SpringUtil?
 
Guy Roth
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your help!

the problem was indeed in our internal code of SpringUtil (I though that SpringUtil is Springs original code and not our invention)

so That's it. It is clear now

 
Hong Anderson
Ranch Hand
Posts: 1936
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the update.
reply
    Bookmark Topic Watch Topic
  • New Topic