1   package org.mortbay.jetty;
2   
3   import javax.servlet.http.HttpServletRequest;
4   import javax.servlet.http.HttpSession;
5   
6   import org.mortbay.component.LifeCycle;
7   
8   /** Session ID Manager.
9    * Manages session IDs across multiple contexts.
10   * @author gregw
11   *
12   */
13  /* ------------------------------------------------------------ */
14  /**
15   * @author gregw
16   *
17   */
18  public interface SessionIdManager extends LifeCycle
19  {
20      /**
21       * @param id The session ID without any cluster node extension
22       * @return True if the session ID is in use by at least one context.
23       */
24      public boolean idInUse(String id);
25      
26      /**
27       * Add a session to the list of known sessions for a given ID.
28       * @param session The session
29       */
30      public void addSession(HttpSession session);
31      
32      /**
33       * Remove session from the list of known sessions for a given ID.
34       * @param session
35       */
36      public void removeSession(HttpSession session);
37      
38      /**
39       * Call {@link HttpSession#invalidate()} on all known sessions for the given id.
40       * @param id The session ID without any cluster node extension
41       */
42      public void invalidateAll(String id);
43      
44      /**
45       * @param request
46       * @param created
47       * @return
48       */
49      public String newSessionId(HttpServletRequest request,long created);
50      
51      public String getWorkerName();
52      
53      
54      /* ------------------------------------------------------------ */
55      /** Get a cluster ID from a node ID.
56       * Strip node identifier from a located session ID.
57       * @param nodeId
58       * @return
59       */
60      public String getClusterId(String nodeId);
61      
62      /* ------------------------------------------------------------ */
63      /** Get a node ID from a cluster ID and a request
64       * @param clusterId The ID of the session
65       * @param request The request that for the session (or null)
66       * @return The session ID qualified with the node ID.
67       */
68      public String getNodeId(String clusterId,HttpServletRequest request);
69      
70  }