Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

A process safe question on Spring

 
Ray Clark
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • 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.
 
Kathleen Angeles
Ranch Hand
Posts: 123
Firefox Browser Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Thank you Kathleen. That confirms what was going on with my program.

Thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic