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 public interface SessionIdManager extends LifeCycle 25 { 26 /** 27 * @param id The session ID without any cluster node extension 28 * @return True if the session ID is in use by at least one context. 29 */ 30 public boolean idInUse(String id); 31 32 /** 33 * Add a session to the list of known sessions for a given ID. 34 * @param session The session 35 */ 36 public void addSession(HttpSession session); 37 38 /** 39 * Remove session from the list of known sessions for a given ID. 40 * @param session 41 */ 42 public void removeSession(HttpSession session); 43 44 /** 45 * Call {@link HttpSession#invalidate()} on all known sessions for the given id. 46 * @param id The session ID without any cluster node extension 47 */ 48 public void invalidateAll(String id); 49 50 /** 51 * @param request 52 * @param created 53 * @return the new session id 54 */ 55 public String newSessionId(HttpServletRequest request,long created); 56 57 public String getWorkerName(); 58 59 60 /* ------------------------------------------------------------ */ 61 /** Get a cluster ID from a node ID. 62 * Strip node identifier from a located session ID. 63 * @param nodeId 64 * @return the cluster id 65 */ 66 public String getClusterId(String nodeId); 67 68 /* ------------------------------------------------------------ */ 69 /** Get a node ID from a cluster ID and a request 70 * @param clusterId The ID of the session 71 * @param request The request that for the session (or null) 72 * @return The session ID qualified with the node ID. 73 */ 74 public String getNodeId(String clusterId,HttpServletRequest request); 75 76 }