Hi,
With a singleton:

class MyState {
  // State variables, accessor methods
}

class MyStateManager {
  private static MyStateManager instance;
  private Map states;
  private MyStateManager() {
    states = Collections.syncronizedMap(new HashMap());
  }
  public static synchronized MyStateManager getInstance() {
    if(instance == null) {
      instance = new MyStateManager();
    }
    return instance;
  }
  public MyState getState(String uniqueId) {
    MyState result = (MyState) states.get(uniqueId);
    if(result == null) {
      result = new MyState();
      states.put(uniqueId, result);
    }
    return result;
  }
  public void setState(String uniqueId, MyState state) {
    states.put(uniqueId, state);
  }
}

That's it, a classic singleton pattern usage.  The semantics can be
altered slightly, e.g. if you want to be the one creating the states
instead of the singleton, or if you want to make some of the private
fields above protected as a better design for extension, but this is a
simple enough example and the above semantics are modeled after
HttpSessions.

Yoav Shapira
Millennium Research Informatics


>-----Original Message-----
>From: tom ly [mailto:[EMAIL PROTECTED]
>Sent: Tuesday, April 06, 2004 11:33 AM
>To: [EMAIL PROTECTED]
>Subject: How can I maintain state with Axis webservice in Tomcat?
>
>I've got multiple instance of a presentation front end sending requests
to
>multiple instances of  the component I'm building.  I know about using
>cookies for state management, but it won't work with our case because
we
>don't connect to any client web browser.  The front end does provide a
>unique id that is persistent throughout the lifecycle of the request.
How
>can I use this unique id as the unique identifier so that I can manage
>state within AXIS web services.
>
>
>---------------------------------
>Do you Yahoo!?
>Yahoo! Small Business $15K Web Design Giveaway - Enter today



This e-mail, including any attachments, is a confidential business communication, and 
may contain information that is confidential, proprietary and/or privileged.  This 
e-mail is intended only for the individual(s) to whom it is addressed, and may not be 
saved, copied, printed, disclosed or used by anyone else.  If you are not the(an) 
intended recipient, please immediately delete this e-mail from your computer system 
and notify the sender.  Thank you.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to