View Javadoc

1   // ========================================================================
2   // Copyright (c) 2004-2009 Mort Bay Consulting Pty. Ltd.
3   // ------------------------------------------------------------------------
4   // All rights reserved. This program and the accompanying materials
5   // are made available under the terms of the Eclipse Public License v1.0
6   // and Apache License v2.0 which accompanies this distribution.
7   // The Eclipse Public License is available at 
8   // http://www.eclipse.org/legal/epl-v10.html
9   // The Apache License v2.0 is available at
10  // http://www.opensource.org/licenses/apache2.0.php
11  // You may elect to redistribute this code under either of these licenses. 
12  // ========================================================================
13  
14  package org.eclipse.jetty.server;
15  
16  import javax.servlet.http.HttpServletRequest;
17  import javax.servlet.http.HttpSession;
18  
19  import org.eclipse.jetty.util.component.LifeCycle;
20  
21  /** Session ID Manager.
22   * Manages session IDs across multiple contexts.
23   * 
24   *
25   */
26  /* ------------------------------------------------------------ */
27  /**
28   * 
29   *
30   */
31  public interface SessionIdManager extends LifeCycle
32  {
33      /**
34       * @param id The session ID without any cluster node extension
35       * @return True if the session ID is in use by at least one context.
36       */
37      public boolean idInUse(String id);
38      
39      /**
40       * Add a session to the list of known sessions for a given ID.
41       * @param session The session
42       */
43      public void addSession(HttpSession session);
44      
45      /**
46       * Remove session from the list of known sessions for a given ID.
47       * @param session
48       */
49      public void removeSession(HttpSession session);
50      
51      /**
52       * Call {@link HttpSession#invalidate()} on all known sessions for the given id.
53       * @param id The session ID without any cluster node extension
54       */
55      public void invalidateAll(String id);
56      
57      /**
58       * @param request
59       * @param created
60       * @return
61       */
62      public String newSessionId(HttpServletRequest request,long created);
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
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  }