title: Java Session Implementation
body: <p>I am developing a multiplayer online game. I have the following issue:</p>
  
  <p>When the user breaks his/her connection with the server, he needs to reconnect. At the first connection, during registration, the registration module produces a special ResponseDispatcher which holds the reference to the connection Channel. But if the user logs out, this Channel becomes invalid. Even though I can detect the problem and clean up resources, I have to store the reference to the registration module and Connection module to the game module, in order to renew the Channel when the user authorises and reconnects again. This creates a lot of interdependencies among modules and it gets really hard to maintain. </p>
  
  <p>What I need is something like an HttpSession in Servlet Container, so that I can get the references to my channel and session resources from all modules of my server. </p>
  
  <p>How is HttpSession implemented in Servlet? Is it a global hashmap storing all JSESSIONID, from which the container determines which attribute map to return? If it is a global sysmbol table, will it hit the performance (even though the time is O(1) for hashMap, there might be session modifications so it probably has to be synchronized)? </p>
  
  <p>PS. Maybe some recommendations of design patterns for this case would also do.</p>