File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes MainTain Session in swing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "MainTain Session in swing" Watch "MainTain Session in swing" New topic

MainTain Session in swing

johny sill

Joined: Jul 08, 2006
Posts: 27

How to maintain user session in swing,

I want to maintain session about user,

Thanks in advance

Aditya Jha
Ranch Hand

Joined: Aug 25, 2003
Posts: 227

I had developed a pattern for this. What you can use is a singleton object of a class encapsultaing java.util.Hashtable to act as session. Please note that this object could be singleton per JVM (if the app is running once only for one user) or singleton per user-frame (when the app is supposed to maintain several users at a time; although such situations will be rare).

You could also extend from Hashtable instead of encapsulating it to save on writing a number of wrapper methods, delegating individual tasks to the super class. However, encapsulating gives you one distinct advantage (particularly if you're not using Generics). You can statically decide on the data-type of keys and values in your session (String, String or String, Object etc.).

Think on these lines and post again if stuck somewhere.
I agree. Here's the link:
subject: MainTain Session in swing
It's not a secret anymore!