Results 1 to 2 of 2

Thread: design strategy question

  1. #1

    Default 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. #2
    Join Date
    Aug 2004
    Location
    San Mateo, CA
    Posts
    1,265

    Default

    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.
    Rod Johnson - GM, SpringSource Division, VMware
    http://www.springsource.com
    Spring From the Source

Similar Threads

  1. A design question
    By thenakedsingularity in forum Architecture
    Replies: 10
    Last Post: Oct 25th, 2005, 11:15 AM
  2. Strategy design pattern and Spring
    By lalle in forum Architecture
    Replies: 7
    Last Post: Oct 17th, 2005, 01:42 PM
  3. design question: passing context
    By Alarmnummer in forum Management
    Replies: 0
    Last Post: Oct 3rd, 2005, 01:20 PM
  4. Bean design question
    By egervari in forum Container
    Replies: 1
    Last Post: May 12th, 2005, 12:43 PM
  5. Replies: 6
    Last Post: Oct 8th, 2004, 02:21 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •