• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Liutauras Vilda
Sheriffs:
  • Tim Cooke
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Ron McLeod
  • Ganesh Patekar
  • salvin francis
Bartenders:
  • Tim Holloway
  • Carey Brown
  • Stephan van Hulst

Singleton Java Class V/S Spring Singleton  RSS feed

 
Ranch Hand
Posts: 381
2
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I understand that

A Java program written as Singleton means 1 instance per JVM per class loader

Spring Singleton is 1 instance per Spring Container.

So, I was just wondering if is it possible to have two Spring Containers in a Spring MVC application? If yes, then how? And, if we have 2 containers does that mean 2 separate JVMs?
 
Vaibhav Gargs
Ranch Hand
Posts: 381
2
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please share your inputs.
 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The interface org.springframework.context.ApplicationContext represents the Spring IoC container and is responsible for instantiating, configuring, and assembling the aforementioned beans. The container gets its instructions on what objects to instantiate, configure, and assemble by reading configuration metadata. The configuration metadata is represented in XML, Java annotations, or Java code.

 
Bartender
Posts: 20125
103
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure I'd use the term "Spring Container". Spring actually works using a Factory. And yes, there's no real reason why you couldn't have multiple Spring factories within a single application, but it could get very messy.

On the other hand, I know a case where there are multiple Spring factories operating in a single JVM every day: A web application server, for example. Or an OSGi container. In both of these cases, one JVM hosts multiple applications, each with its own classpath. Since Spring is not provided by the container, it's up to the application to manage Spring and thus each Spring-based application in the container would have its own factory managing its own inventory of Spring Beans.
 
It's a beautiful day in this neighborhood - Fred Rogers. Tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
https://coderanch.com/t/704633/RavenDB-Open-Source-NoSQL-Database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!