⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 defaultticketregistry.java

📁 CAS在Tomcat中实现单点登录项目,单点登录(Single Sign On , 简称 SSO )是目前比较流行的服务于企业业务整合的解决方案之一
💻 JAVA
字号:
/* * Copyright 2007 The JA-SIG Collaborative. All rights reserved. See license * distributed with this file and available online at * http://www.ja-sig.org/products/cas/overview/license/ */package org.jasig.cas.ticket.registry;import java.util.Collection;import java.util.Collections;import java.util.Map;import java.util.concurrent.ConcurrentHashMap;import org.jasig.cas.ticket.Ticket;import org.springframework.util.Assert;/** * Implementation of the TicketRegistry that is backed by a ConcurrentHashMap. *  * @author Scott Battaglia * @version $Revision: 42053 $ $Date: 2007-06-10 09:17:55 -0400 (Sun, 10 Jun 2007) $ * @since 3.0 */public final class DefaultTicketRegistry extends AbstractTicketRegistry {    /** A HashMap to contain the tickets. */    private final Map<String, Ticket> cache;        public DefaultTicketRegistry() {        this.cache = new ConcurrentHashMap<String, Ticket>();    }        /**     * Creates a new, empty registry with the specified initial capacity, load     * factor, and concurrency level.     *      * @param initialCapacity - the initial capacity. The implementation     * performs internal sizing to accommodate this many elements.     * @param loadFactor - the load factor threshold, used to control resizing.     * Resizing may be performed when the average number of elements per bin     * exceeds this threshold.     * @param concurrencyLevel - the estimated number of concurrently updating     * threads. The implementation performs internal sizing to try to     * accommodate this many threads.     */    public DefaultTicketRegistry(int initialCapacity, final float loadFactor, final int concurrencyLevel) {        this.cache = new ConcurrentHashMap<String, Ticket>(initialCapacity, loadFactor, concurrencyLevel);    }        /**     * @throws IllegalArgumentException if the Ticket is null.     */    public void addTicket(final Ticket ticket) {        Assert.notNull(ticket, "ticket cannot be null");        if (log.isDebugEnabled()) {            log.debug("Added ticket [" + ticket.getId() + "] to registry.");        }        this.cache.put(ticket.getId(), ticket);    }    public Ticket getTicket(final String ticketId) {        if (ticketId == null) {            return null;        }        if (log.isDebugEnabled()) {            log.debug("Attempting to retrieve ticket [" + ticketId + "]");        }        final Ticket ticket = this.cache.get(ticketId);        if (ticket != null) {            log.debug("Ticket [" + ticketId + "] found in registry.");        }        return ticket;    }    public boolean deleteTicket(final String ticketId) {        if (ticketId == null) {            return false;        }        if (log.isDebugEnabled()) {            log.debug("Removing ticket [" + ticketId + "] from registry");        }        return (this.cache.remove(ticketId) != null);    }    public Collection<Ticket> getTickets() {        return Collections.unmodifiableCollection(this.cache.values());    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -