Announcement Announcement Module
No announcement yet.
design strategy question Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • design strategy question

    i use to develop my web-apps using struts, i created a singleton to hold all the logged user, so that i can check for double login and report current logged users. There was one thing thats very useful to me, the SessionListener, wherein i trap session expiration w/c in turn removes the user from the list of my singleton class.

    now the problem is how will i design this using Spring MVC.

    in struts after i initialized my singleton class i could just do a UserList.add(), UserList.remove(), UserList.getUsers(), etc from anywhere/from any java class of my application and will get the correct data & functionality.

    whats the proper way to design this in Spring? pls help me.

    .... thanks a lot again in advance. you guys have been very helpful in my transition from struts to spring.

  • #2
    Write the user tracking service as a normal object, configure it with Spring and inject it where it's needed. For example, you could inject it into a superclass Spring MVC controller.

    I would not recommend the traditional Singleton approach, regardless of whether you use Spring. It typically creates testing difficulties, for example.