View Javadoc

1   //
2   //  ========================================================================
3   //  Copyright (c) 1995-2013 Mort Bay Consulting Pty. Ltd.
4   //  ------------------------------------------------------------------------
5   //  All rights reserved. This program and the accompanying materials
6   //  are made available under the terms of the Eclipse Public License v1.0
7   //  and Apache License v2.0 which accompanies this distribution.
8   //
9   //      The Eclipse Public License is available at
10  //      http://www.eclipse.org/legal/epl-v10.html
11  //
12  //      The Apache License v2.0 is available at
13  //      http://www.opensource.org/licenses/apache2.0.php
14  //
15  //  You may elect to redistribute this code under either of these licenses.
16  //  ========================================================================
17  //
18  
19  package org.eclipse.jetty.server;
20  
21  import javax.servlet.http.HttpServletRequest;
22  import javax.servlet.http.HttpSession;
23  
24  import org.eclipse.jetty.util.component.LifeCycle;
25  
26  /** Session ID Manager.
27   * Manages session IDs across multiple contexts.
28   */
29  public interface SessionIdManager extends LifeCycle
30  {
31      /**
32       * @param id The session ID without any cluster node extension
33       * @return True if the session ID is in use by at least one context.
34       */
35      public boolean idInUse(String id);
36      
37      /**
38       * Add a session to the list of known sessions for a given ID.
39       * @param session The session
40       */
41      public void addSession(HttpSession session);
42      
43      /**
44       * Remove session from the list of known sessions for a given ID.
45       * @param session
46       */
47      public void removeSession(HttpSession session);
48      
49      /**
50       * Call {@link HttpSession#invalidate()} on all known sessions for the given id.
51       * @param id The session ID without any cluster node extension
52       */
53      public void invalidateAll(String id);
54      
55      /**
56       * @param request
57       * @param created
58       * @return the new session id
59       */
60      public String newSessionId(HttpServletRequest request,long created);
61      
62      
63      
64      public String getWorkerName();
65      
66      
67      /* ------------------------------------------------------------ */
68      /** Get a cluster ID from a node ID.
69       * Strip node identifier from a located session ID.
70       * @param nodeId
71       * @return the cluster id
72       */
73      public String getClusterId(String nodeId);
74      
75      /* ------------------------------------------------------------ */
76      /** Get a node ID from a cluster ID and a request
77       * @param clusterId The ID of the session
78       * @param request The request that for the session (or null)
79       * @return The session ID qualified with the node ID.
80       */
81      public String getNodeId(String clusterId,HttpServletRequest request);
82      
83      
84      /* ------------------------------------------------------------ */
85      /** Change the existing session id.
86      * 
87      * @param oldClusterId
88      * @param oldNodeId
89      * @param request
90      */
91      public void renewSessionId(String oldClusterId, String oldNodeId, HttpServletRequest request);    
92  
93      
94  }