001/* 002 * This library is part of OpenCms - 003 * the Open Source Content Management System 004 * 005 * Copyright (c) Alkacon Software GmbH & Co. KG (http://www.alkacon.com) 006 * 007 * This library is free software; you can redistribute it and/or 008 * modify it under the terms of the GNU Lesser General Public 009 * License as published by the Free Software Foundation; either 010 * version 2.1 of the License, or (at your option) any later version. 011 * 012 * This library is distributed in the hope that it will be useful, 013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 015 * Lesser General Public License for more details. 016 * 017 * For further information about Alkacon Software GmbH & Co. KG, please see the 018 * company website: http://www.alkacon.com 019 * 020 * For further information about OpenCms, please see the 021 * project website: http://www.opencms.org 022 * 023 * You should have received a copy of the GNU Lesser General Public 024 * License along with this library; if not, write to the Free Software 025 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 026 */ 027 028package org.opencms.main; 029 030import org.opencms.util.CmsUUID; 031 032import java.util.List; 033 034/** 035 * This interface is used to define the session storage implementation provider.<p> 036 * 037 * @since 6.5.5 038 */ 039public interface I_CmsSessionStorageProvider { 040 041 /** 042 * Validates all session info objects removing any session that have became invalidated.<p> 043 */ 044 void validate(); 045 046 /** 047 * Returns the stored session info object with the given id.<p> 048 * 049 * @param sessionId the id to lookup 050 * 051 * @return the stored session info object, or <code>null</code> if not found 052 */ 053 CmsSessionInfo get(CmsUUID sessionId); 054 055 /** 056 * Returns all current stored session info objects.<p> 057 * 058 * @return all current stored session info objects 059 */ 060 List<CmsSessionInfo> getAll(); 061 062 /** 063 * Returns all current stored session info objects for the given user.<p> 064 * 065 * @param userId the id of the user to retrieve the session info objects for 066 * 067 * @return all current stored session info objects for the given user 068 */ 069 List<CmsSessionInfo> getAllOfUser(CmsUUID userId); 070 071 /** 072 * Returns the current number of stored session info objects.<p> 073 * 074 * @return the current number of stored session info objects, or zero if empty 075 */ 076 int getSize(); 077 078 /** 079 * Initializes the storage.<p> 080 * 081 * @throws CmsInitException if initialization fails 082 */ 083 void initialize() throws CmsInitException; 084 085 /** 086 * Stores the given session info object.<p> 087 * 088 * @param sessionInfo the session info object to be stored 089 * 090 * @return the session info object previously stored with the same session id, or <code>null</code> if none 091 */ 092 CmsSessionInfo put(CmsSessionInfo sessionInfo); 093 094 /** 095 * Removes the stored session info object identified by the given session id.<p> 096 * 097 * @param sessionId the id that identifies the stored session info object to remove 098 * 099 * @return the removed cached entry or <code>null</code> if none 100 */ 101 CmsSessionInfo remove(CmsUUID sessionId); 102 103 /** 104 * Last cleanup possibility.<p> 105 * 106 * @throws Exception if something goes wrong 107 */ 108 void shutdown() throws Exception; 109}