Ed Roman introduced the concept of a J2EE singleton via UnicastRemoteObject and registering with RMI and using JNDI to look this up.
Is there any way of extending this to add resiliance? In weblogic specifics clustering would provide this, however is there a pattern for providing this in a vendor independent way?
-
J2EE Singleton (6 messages)
- Posted by: John McRobb
- Posted on: December 12 2000 09:50 EST
Threaded Messages (6)
- J2EE Singleton by Floyd Marinescu on December 12 2000 21:05 EST
- J2EE Singleton by Dave Wolf on December 12 2000 23:46 EST
- J2EE Singleton by Dimitri Rakitine on December 13 2000 04:02 EST
-
J2EE Singleton by John McRobb on December 14 2000 09:09 EST
-
J2EE Singleton by Mark Endras on December 16 2000 11:49 EST
- J2EE Singleton by John McRobb on January 18 2001 08:45 EST
-
J2EE Singleton by Mark Endras on December 16 2000 11:49 EST
-
J2EE Singleton by John McRobb on December 14 2000 09:09 EST
- J2EE Singleton by Dimitri Rakitine on December 13 2000 04:02 EST
-
J2EE Singleton[ Go to top ]
- Posted by: Floyd Marinescu
- Posted on: December 12 2000 21:05 EST
- in response to John McRobb
John,
I moved this thread out of the design patterns section, since you aren't posting a "design pattern", but a question.
take care,
Floyd -
J2EE Singleton[ Go to top ]
- Posted by: Dave Wolf
- Posted on: December 12 2000 23:46 EST
- in response to John McRobb
Im not sure I see where this is any different then having a cluster and the singleton only living on one server in that cluster? The lookup would still find it on the one machine and if an entity bean this would roughly equate to a singleton. Whats the point here?
Where was Ed's pattern posted?
Dave Wolf
Internet Applications Division
Sybase
-
J2EE Singleton[ Go to top ]
- Posted by: Dimitri Rakitine
- Posted on: December 13 2000 04:02 EST
- in response to Dave Wolf
Hrm, I second that - where is the pattern posted? I always thought that using RMI to implement singleton-like functionality is a standard thing to do. -
J2EE Singleton[ Go to top ]
- Posted by: John McRobb
- Posted on: December 14 2000 09:09 EST
- in response to Dimitri Rakitine
http://jsp.java.sun.com/javaone/javaone2000/pdfs/TS-678.pdf
No Statics in EJB
- Need to still have singleton, but networked singleton instead
Solution
- Bind RMI rmeote object to JNDI tree via RMI registry JNDI SPI
- Clients look up singleton via JNDI
public class uniqueGen extendsUnicastRemoteObject
implements Remote {
private static long uniqueID = System.currentTimeMillis();
public static synchronized long getUnique() {
throws RemoteException (
return uniqueID++;
}
Yes we have a singleton but if the instance of weblogic goes down then we loose it unless we use the clustering features. My question is not how to have a singleton but how to make it resiliant.
John -
J2EE Singleton[ Go to top ]
- Posted by: Mark Endras
- Posted on: December 16 2000 23:49 EST
- in response to John McRobb
This question is kind of off topic but applies to your singleton code. Does this code not violate spec. because your are calling a synchronized method from your ejb ????? -
J2EE Singleton[ Go to top ]
- Posted by: John McRobb
- Posted on: January 18 2001 08:45 EST
- in response to Mark Endras
I think the distinction needs to be made as to if your are doing this in the App Server JVM or another JVM. If its another I can see the difference with having to wait for a database lock to become free.
John