I’m trying to understand how Java objects behave in a Domino environment and am wondering what happens when you use singletons (a singleton is a Java object that’s constructed in such a way that only one instance will ever exist within the JVM).
Say I have a singleton in database 1, use getInstance() on it. The object is created in the JVM and from there on each time I use the getInstance() method the same object is returned.
Now I copy that class over to database 2 and use getInstance() in that database too. Which object is being returned? The one that I originally created in database 1 or the new one from database 2?
I’ve done a test and as jjtbsomhorst suggests, there indeed will be two separate singletons.
XPage
SingletonTest.xsp:Java class:
The XPage and Java class copied to another database with a slightly modified
whoamistring produce a different output. So the singletons are not shared between databases.