Hi all! :-)

I have a port forwarding proxy server that is running as an applet. Because
it is a server that binds to a single port, I cannot/don't want to run
multiple instances of it in the browser : I want to use the Singleton
creational pattern.

Problem : Every time I hit the refresh button on the browser, I get a new
instance of my singleton!?! ... and the old one keeps running. The applet is
loading from the exact same location every time, but for some reason each
instance has its own classloader.

I have set up the proxy class with a static instance variable, a private
constructor and a static getInstance() method. I have also tried placing
static variables in the Applet class to check for existing instances, but
this fails also.

I have been reading everything I can find on Applets and Singleton, but
cannot find a way to enforce the singleton in the applet in IE 6 on Win32
using the latest Java plugin. I'm a server-side guy... I hope there is
someone on this list with enough client-side experience to point me in the
right direction.

Thanks!

~akb

class ProxyNio {
    ....
    private static ProxyNio instance;

    private ProxyNio() .... // constructor
    ....
    protected static ProxyNio getInstance() {

        if (instance == null) {
            return instance = new ProxyNio();
        }
        return instance;
    }
}



_______________________________________________
Juglist mailing list
[EMAIL PROTECTED]
http://trijug.org/mailman/listinfo/juglist_trijug.org

Reply via email to