📄 userrightscache.java
字号:
/******************************************************************************* * Copyright (C) 2002, 2003 * ingenieurbuero fuer innovative informationstechnik (iiit) * Dipl.-Ing. Joerg Beckmann, Dortmund, Germany * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * or look at http://www.gnu.org/copleft/lesser.html. * * version $Id: UserRightsCache.java,v 1.5 2003/04/13 21:13:38 joerg Exp $ ******************************************************************************/package de.iiit.access.common.cache;import de.iiit.cache.*;/** This cache is used by the CachePlugin * @version $Revision: 1.5 $ $Date: 2003/04/13 21:13:38 $ */public class UserRightsCache extends GenericTimeoutCache{ /** CVS Version Tag */ private static final String vcid = "$Id: UserRightsCache.java,v 1.5 2003/04/13 21:13:38 joerg Exp $"; int invalidationTimeout; /** Creates a new instance of UserRightsCache */ public UserRightsCache() { this(-1, 1800000, 10000); } /** Creates a new instance of UserRightsCache * @param lruTimeout after this period of time an unused cache for a specific user will * be deleted. */ public UserRightsCache(int lruTimeout) { this(lruTimeout, 1800000, 10000); } /** Creates a new instance of UserRightsCache * @param lruTimeout after this period of time an unused cache for a specific user will * be deleted. It does not make any sense to set this timeout * higher than the invalidation timeout. * @param invalidationTimeout after this period of time any elements in the cache will * be ignored to assure that changes in the rights will be recognized. * @param sleeptime The time to sleep between to runs of the cache cleaner. */ public UserRightsCache(int lruTimeout, int invalidationTimeout, int sleeptime) { super(lruTimeout, sleeptime); this.invalidationTimeout = invalidationTimeout; } /** Adds the result of one expression to the cache of the user. * @param user The name of the user * @param expression The expression * @param isAllowed The result of the expression */ public void addUserRight(String user, String expression, boolean isAllowed) { RightsCache rc; try { rc = (RightsCache) getElement(user); } catch(CacheFaultException e) { rc = new RightsCache(invalidationTimeout); addElement(user, rc); } rc.addRight(expression, isAllowed); } /** Retrieves the result of an expression from the cache. * @param user The name of the user for whom the result is needed. * @param expression The expression * @throws CacheFaultException if the result is not found in the cache * @return the result of the expression */ public boolean getUserRight(String user, String expression) throws CacheFaultException { RightsCache rc = (RightsCache) getElement(user); return rc.getRight(expression); }}/** * $Log: UserRightsCache.java,v $ * Revision 1.5 2003/04/13 21:13:38 joerg * Copyright statements changed to LGPL * * Revision 1.4 2003/04/13 20:16:41 joerg * Package structure modified * * Revision 1.3 2003/01/01 21:04:17 joerg * Copyright-Statement aktualisiert * * Revision 1.2 2002/12/22 20:45:12 joerg * shutdown()-Methode eingebaut * * Revision 1.1 2002/12/19 15:24:23 joerg * Reparatur des CVS-Repositories * * Revision 1.4 2002/12/09 19:29:17 joerg * Versionsdaten in allen JavaDoc-Klassenbeschreibungen ergaenzt * * Revision 1.3 2002/12/09 16:32:26 joerg * JavaDoc Kommentare ergaenzt * * Revision 1.2 2002/11/19 20:22:52 joerg * Das invalidationTimeout fuer den RightsCache kann jetzt auch * beim Anlegen des Caches gesetzt werden. * * Revision 1.1 2002/11/02 18:23:32 joerg * Klasse verschoben ins Package 'cache' * * Revision 1.1 2002/11/01 21:36:47 joerg * Version mit funktionierenden 1st-level Cache * */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -