• 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

A process safe question on Spring

 
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
We have a class at work with a main method that is run from a UNIX shell script. From what I understand it runs fine if it is started once but has problems if 2 of them are running at the same time.

The class might be something like this:



As you can see the class uses Spring for dependency injection.

The question is, if two MainClass objects are running at the same time on the same server will Spring inject the same AnotherClass object (scoped as a Singleton) into both MainClass objects that are running?

Would the two MainClass objects be running in their own JVM so Spring would inject a unique AnotherClass object into each of them?

I'm not sure how this would work. Any suggestions?

Thank You.
 
Ranch Hand
Posts: 123
Firefox Browser Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The 2 runs will be in their own jvms, having their own Spring contexts, thereby having their own AnotherClass Spring-singleton instances.
 
Ray Clark
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you Kathleen. That confirms what was going on with my program.

Thanks.
 
reply
    Bookmark Topic Watch Topic
  • New Topic