View Javadoc

1   //========================================================================
2   //Copyright 2004-2008 Mort Bay Consulting Pty. Ltd.
3   //------------------------------------------------------------------------
4   //Licensed under the Apache License, Version 2.0 (the "License");
5   //you may not use this file except in compliance with the License.
6   //You may obtain a copy of the License at 
7   //http://www.apache.org/licenses/LICENSE-2.0
8   //Unless required by applicable law or agreed to in writing, software
9   //distributed under the License is distributed on an "AS IS" BASIS,
10  //WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11  //See the License for the specific language governing permissions and
12  //limitations under the License.
13  //========================================================================
14  
15  package org.mortbay.jetty;
16  
17  import javax.servlet.http.HttpServletRequest;
18  import javax.servlet.http.HttpSession;
19  
20  import org.mortbay.component.LifeCycle;
21  
22  /** Session ID Manager.
23   * Manages session IDs across multiple contexts.
24   * @author gregw
25   *
26   */
27  /* ------------------------------------------------------------ */
28  /**
29   * @author gregw
30   *
31   */
32  public interface SessionIdManager extends LifeCycle
33  {
34      /**
35       * @param id The session ID without any cluster node extension
36       * @return True if the session ID is in use by at least one context.
37       */
38      public boolean idInUse(String id);
39      
40      /**
41       * Add a session to the list of known sessions for a given ID.
42       * @param session The session
43       */
44      public void addSession(HttpSession session);
45      
46      /**
47       * Remove session from the list of known sessions for a given ID.
48       * @param session
49       */
50      public void removeSession(HttpSession session);
51      
52      /**
53       * Call {@link HttpSession#invalidate()} on all known sessions for the given id.
54       * @param id The session ID without any cluster node extension
55       */
56      public void invalidateAll(String id);
57      
58      /**
59       * @param request
60       * @param created
61       * @return
62       */
63      public String newSessionId(HttpServletRequest request,long created);
64      
65      public String getWorkerName();
66      
67      
68      /* ------------------------------------------------------------ */
69      /** Get a cluster ID from a node ID.
70       * Strip node identifier from a located session ID.
71       * @param nodeId
72       * @return
73       */
74      public String getClusterId(String nodeId);
75      
76      /* ------------------------------------------------------------ */
77      /** Get a node ID from a cluster ID and a request
78       * @param clusterId The ID of the session
79       * @param request The request that for the session (or null)
80       * @return The session ID qualified with the node ID.
81       */
82      public String getNodeId(String clusterId,HttpServletRequest request);
83      
84  }