LS2J allows multiple instances of a singleton class?

Hi all,I am trying to use a Singleton Java class at multiple locations (Database script, Actions, etc). The problem I have is that multiple instances of the singleton class are instantiated ! However, my singleton has been triple-checked and should not be instantiable more than once. I can provide the code if needed.

More precisely : I use the singleton to set a flag in it in Database script / Initialize, and then I try to access that flag when an action is triggered in the form (Calendar Preferences). The singleton constructor is launched a first time when the database starts, and a second time when I click on the action in the form. And of course, the flag is not set when I try to access it from the form, since its a new instance of the class.

Now, is there some kind of scoped JVM or something I don’t know about preventing the use of a Java singleton ?

Here is how I call my singleton methods :

    Dim mySession As JAVASESSION

Set mySession = New JavaSession()

Dim jclass As JAVACLASS



Set jclass = mySession.getClass("SingletonObject")

Dim 	jobj As JavaObject

Set jobj = jclass.getSingletonObject()



Call jobj.setMessage("myFlag")

I wanted to look at the javaconn extension, but its a compiled dll so no luch there.

Thanks for any assistance !

Alexis

Subject: Re: LS2J allows multiple instances of a singleton class ? [SOLVED]

Replying to myself for archive’s sake.It seems like ls2j uses a special class loader that loads a distinct instance of a given class in each JavaSession. or in a similar scope. This can give multiple instances of the same class, and when asking for the Singleton instance, I get a unique object of a non-unique class.

The way to have a class loaded only once is by using JavaUserClasses in notes.ini. You specify the path of your .class and there you go. You have to compile your java with an external compiler though (make sure you compile with the appropriate Java version for your version of Notes).

If anyone has a detailed explanation of this behavior, you can contact me at balexis a-t gmail d o t com. Thanx!