Wednesday, September 22, 2010

Singleton Class in Development Mode

I'm not sure if this is because of the GWT plugin, but maybe you guys
know...

I have a Singleton class which I use to store the user authentication.
But When I reload my page (with F5) the singleton is reloaded, as if
the VM is restarted.

public class AuthenticationManager {

private static final AuthenticationManager m_instance = new
AuthenticationManager();

private boolean m_authenticated = false;

private AuthenticationManager() {
System.out.println("AuthenticationManager Constructor");
}

public static AuthenticationManager getInstance() {
return m_instance;
}

public boolean isAuthenticated() {
return m_authenticated;
}

public boolean authenticate(String uid, String pwd) {
if (uid != null && uid.trim().length() > 0) {
if (pwd != null && pwd.trim().length() > 0) {
return (m_authenticated = true);
}
}
return false;
}
}

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment