Design Pattern
  • Introduction
  • What is singleton?
  • factory method design pattern
  • loose coupling VS tight coupling
  • Proxy pattern
  • abstracFactory
  • OOA & OOD
  • Decorator Design Pattern
  • Iterator Design Pattern
  • The Observer Pattern
  • Spring Singleton VS Java Singleton
Powered by GitBook
On this page

Was this helpful?

Spring Singleton VS Java Singleton

PreviousThe Observer Pattern

Last updated 5 years ago

Was this helpful?

Java singleton class is per classloader and Spring's singleton is per application context.

It is important to remember that your singleton beans should not store any state information. Because the bean instance created once will be shared across all the threads that are requesting for that spring bean. If you inject an object to spring’s singleton bean, it is wired only once and it never get refreshed. It is ideal to make all the controllers as the singleton beans and value objects as the prototype beans.

An Interview Question on Spring Singletons - DZone Javadzone.com
Difference Between Java Singleton and Spring SingletonJavaBeat
Difference Between Java Singleton and Spring SingletonJavaBeat
Logo
Logo
Logo