• 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
  • Paul Clapham
  • Ron McLeod
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Jj Roberts
  • Al Hobbs
  • Piet Souris

singleton in spring bean

 
Ranch Hand
Posts: 1325
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
what is mean spring beans are singleton?
 
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
By default all beans in Spring are singletons. To have a bean which will not be instantiated as a singleton, use singleton="false" in the configuration of the bean.

Your gains with Singleton injection
So, when using Singleton injection these are your gains:

* Reduced configuration and less code (inject once use everywhere)
* Injected Singletons can be used in classes that are not part of the beanwiring chain
* Static methods can use injected Singletons
* Injected Singletons can serve as beanwiring starting points
* Increased productivity (instant usage of injected code)
 
Ranch Hand
Posts: 69
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Remember that this singleton is for that spring factory only. There can be following possibilities:
- Another bean with same name in a different factory.
- bean with different name and same class
- an object instantiated of the same class outside the factory.

This singleton is different from what we understand as singleton pattern. For a discussion see at Spring Beans section at Spring Tutorial
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic