Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 30-10-2009
Member
 
Join Date: Sep 2009
Posts: 131
Single instance of singleton for all JVMs

My program runs under JBoss 5. I have a singleton that is used by my classes ejb and my classes "normal" (no class inherit the singleton, they only use it). The problem is that I have two jvm: one that turns the ejb container and one that turns my program. I have two instances of the singleton, one for each JVM. How can there be only one instance of singleton, common to both jvm?
Reply With Quote
  #2  
Old 30-10-2009
Member
 
Join Date: Nov 2008
Posts: 1,192
Re: Single instance of singleton for all JVMs

Can not have the same instance of 2 different JVMs. However, you should create a jvm 'server' and the other jvm's can come to connect it to retrieve the common singleton. It's because the general objective of a singleton is to make sure that only one instance of a specific object type exists.
Reply With Quote
  #3  
Old 30-10-2009
Member
 
Join Date: Sep 2009
Posts: 131
Re: Single instance of singleton for all JVMs

And through RMI? I tried to get the singleton by RMI: I create the singleton on the JVM or there are my EJBs, and my client seeks the jvm and obtains the singleton by rmi. But that does not solve the problem: it seems to be a copy of the singleton that I received. The singleton that I received in my jvm via rmi client did not even reference the singleton of the jvm jboss (where there are EJBs), and when I change the values of the singleton in jboss jvm, these changes does not affect the singleton of my jvm client.

Is there a way (shared memory?) for a singleton shared by several JVMs, so that changes in the singleton are visible in all these JVMs?
Reply With Quote
  #4  
Old 30-10-2009
Member
 
Join Date: Nov 2008
Posts: 1,221
Re: Single instance of singleton for all JVMs

Quote:
Originally Posted by KANAN14 View Post
Is there a way (shared memory?) for a singleton shared by several JVMs, so that changes in the singleton are visible in all these JVMs?
And why get a reference of Singleton? If a singleton is the singleton "master", that is to say, one of the JVM is the JVM "master", why not ask what you need as a service, a "get" command or an "update" command, and then use the synchronized method within the singleton "master"?
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Single instance of singleton for all JVMs"
Thread Thread Starter Forum Replies Last Post
Exception Handling in Singleton Bottlenecked Software Development 6 20-09-2010 09:14 PM
Running Multiple Instance of single application on Mac OS MaCiNToSHeR Operating Systems 6 26-08-2009 11:05 PM
Singleton in AS2 Allen young Software Development 3 24-06-2009 10:14 AM
How to create single instance application using c++ Mahendra varma Software Development 3 26-05-2009 05:10 PM
What is a Singleton in java? Bhim Software Development 3 02-03-2009 08:18 PM


All times are GMT +5.5. The time now is 02:28 PM.