• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

MainTain Session in swing

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

How to maintain user session in swing,

I want to maintain session about user,

Thanks in advance

Bye
 
Ranch Hand
Posts: 227
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Every time you till, you lose 30% of your organic matter. But this tiny ad is durable:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic