亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? servletcacheadministrator.java

?? oscache-2.4.1-full
?? JAVA
?? 第 1 頁 / 共 2 頁
字號:
/*
 * Copyright (c) 2002-2003 by OpenSymphony
 * All rights reserved.
 */
package com.opensymphony.oscache.web;

import com.opensymphony.oscache.base.*;
import com.opensymphony.oscache.base.events.CacheEventListener;
import com.opensymphony.oscache.base.events.ScopeEvent;
import com.opensymphony.oscache.base.events.ScopeEventListener;
import com.opensymphony.oscache.base.events.ScopeEventType;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import java.io.Serializable;

import java.util.*;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import javax.servlet.jsp.PageContext;

/**
 * A ServletCacheAdministrator creates, flushes and administers the cache.
 * <p>
 * This is a "servlet Singleton". This means it's not a Singleton in the traditional sense,
 * that is stored in a static instance. It's a Singleton _per web app context_.
 * <p>
 * Once created it manages the cache path on disk through the oscache.properties
 * file, and also keeps track of the flush times.
 *
 * @author <a href="mailto:mike@atlassian.com">Mike Cannon-Brookes</a>
 * @author <a href="mailto:tgochenour@peregrine.com">Todd Gochenour</a>
 * @author <a href="mailto:fbeauregard@pyxis-tech.com">Francois Beauregard</a>
 * @author <a href="mailto:abergevin@pyxis-tech.com">Alain Bergevin</a>
 * @author <a href="&#109;a&#105;&#108;&#116;&#111;:chris&#64;swebtec.&#99;&#111;&#109;">Chris Miller</a>
 * @version        $Revision: 463 $
 */
public class ServletCacheAdministrator extends AbstractCacheAdministrator implements Serializable {
    private static final transient Log log = LogFactory.getLog(ServletCacheAdministrator.class);

    /**
    * Constants for properties read/written from/to file
    */
    private final static String CACHE_USE_HOST_DOMAIN_KEY = "cache.use.host.domain.in.key";
    private final static String CACHE_KEY_KEY = "cache.key";

    /**
    * The default cache key that is used to store the cache in context.
    */
    private final static String DEFAULT_CACHE_KEY = "__oscache_cache";

    /**
    * Constants for scope's name
    */
    public final static String SESSION_SCOPE_NAME = "session";
    public final static String APPLICATION_SCOPE_NAME = "application";

    /**
    * The suffix added to the cache key used to store a 
    * ServletCacheAdministrator will be stored in the ServletContext
    */
    private final static String CACHE_ADMINISTRATOR_KEY_SUFFIX = "_admin";

    /**
    * The key under which an array of all ServletCacheAdministrator objects 
    * will be stored in the ServletContext
    */
    private final static String CACHE_ADMINISTRATORS_KEY = "__oscache_admins";

    /**
    * Key used to store the current scope in the configuration. This is a hack
    * to let the scope information get passed through to the DiskPersistenceListener,
    * and will be removed in a future release.
    */
    public final static String HASH_KEY_SCOPE = "scope";

    /**
    * Key used to store the current session ID in the configuration. This is a hack
    * to let the scope information get passed through to the DiskPersistenceListener,
    * and will be removed in a future release.
    */
    public final static String HASH_KEY_SESSION_ID = "sessionId";

    /**
    * Key used to store the servlet container temporary directory in the configuration.
    * This is a hack to let the scope information get passed through to the
    * DiskPersistenceListener, and will be removed in a future release.
    */
    public final static String HASH_KEY_CONTEXT_TMPDIR = "context.tempdir";

    /**
    * The string to use as a file separator.
    */
    private final static String FILE_SEPARATOR = "/";

    /**
    * The character to use as a file separator.
    */
    private final static char FILE_SEPARATOR_CHAR = FILE_SEPARATOR.charAt(0);

    /**
    * Constant for Key generation.
    */
    private final static short AVERAGE_KEY_LENGTH = 30;

    /**
    * Usable caracters for key generation
    */
    private static final String m_strBase64Chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";

    /**
    * Map containing the flush times of different scopes
    */
    private Map flushTimes;

    /**
     * Required so we can look up the app scope cache without forcing a session creation.
     */
    private transient ServletContext context;

    /**
    * Key to use for storing and retrieving Object in contexts (Servlet, session).
    */
    private String cacheKey;

    /**
    *  Set property cache.use.host.domain.in.key=true to add domain information to key
    *  generation for hosting multiple sites.
    */
    private boolean useHostDomainInKey = false;

    /**
    *        Create the cache administrator.
    *
    *        This will reset all the flush times and load the properties file.
    */
    private ServletCacheAdministrator(ServletContext context, Properties p) {
        super(p);
        config.set(HASH_KEY_CONTEXT_TMPDIR, context.getAttribute("javax.servlet.context.tempdir"));

        flushTimes = new HashMap();
        initHostDomainInKey();
        this.context = context;
    }

    /**
    * Obtain an instance of the CacheAdministrator
    *
    * @param context The ServletContext that this CacheAdministrator is a Singleton under
    * @return Returns the CacheAdministrator instance for this context
    */
    public static ServletCacheAdministrator getInstance(ServletContext context) {
        return getInstance(context, null);
    }

    /**
     * Obtain an instance of the CacheAdministrator for the specified key
     *
     * @param context The ServletContext that this CacheAdministrator is a Singleton under
     * @param key the cachekey or admincachekey for the CacheAdministrator wanted
     * @return Returns the CacheAdministrator instance for this context, or null if no
     * CacheAdministrator exists with the key supplied
     */
     public static ServletCacheAdministrator getInstanceFromKey(ServletContext context, String key) {
    	 // Note we do not bother to check if the key is null because it mustn't.
         if (!key.endsWith(CACHE_ADMINISTRATOR_KEY_SUFFIX)) {
        	 key = key + CACHE_ADMINISTRATOR_KEY_SUFFIX;
         }
         return (ServletCacheAdministrator) context.getAttribute(key);
     }

    /**
    * Obtain an instance of the CacheAdministrator
    *
    * @param context The ServletContext that this CacheAdministrator is a Singleton under
    * @param p the properties to use for the cache if the cache administrator has not been
    * created yet. Once the administrator has been created, the properties parameter is
    * ignored for all future invocations. If a null value is passed in, then the properties
    * are loaded from the oscache.properties file in the classpath.
    * @return Returns the CacheAdministrator instance for this context
    */
    public synchronized static ServletCacheAdministrator getInstance(ServletContext context, Properties p)
    {
    	String adminKey = null; 
    	if (p!= null) {
    		adminKey = p.getProperty(CACHE_KEY_KEY);
    	}
    	if (adminKey == null) {
    		adminKey = DEFAULT_CACHE_KEY;
    	}
		adminKey += CACHE_ADMINISTRATOR_KEY_SUFFIX;

        ServletCacheAdministrator admin = (ServletCacheAdministrator) context.getAttribute(adminKey);

        // First time we need to create the administrator and store it in the
        // servlet context
        if (admin == null) {
            admin = new ServletCacheAdministrator(context, p);
            Map admins = (Map) context.getAttribute(CACHE_ADMINISTRATORS_KEY);
            if (admins == null) {
            	admins = new HashMap();
            }
            admins.put(adminKey, admin);
            context.setAttribute(CACHE_ADMINISTRATORS_KEY, admins);
            context.setAttribute(adminKey, admin);

            if (log.isInfoEnabled()) {
                log.info("Created new instance of ServletCacheAdministrator with key "+adminKey);
            }

            admin.getAppScopeCache(context);
        }

        if (admin.context == null) {
            admin.context = context;
        }

        return admin;
    }

    /**
    * Shuts down all servlet cache administrators. This should usually only 
    * be called when the controlling application shuts down.
    */
    public static void destroyInstance(ServletContext context)
    {
        ServletCacheAdministrator admin;
        Map admins = (Map) context.getAttribute(CACHE_ADMINISTRATORS_KEY);
        if (admins != null)
        {
        	Set keys = admins.keySet();
        	Iterator it = keys.iterator();
        	while (it.hasNext())
        	{
        		String adminKey = (String) it.next();
        		admin = (ServletCacheAdministrator) admins.get( adminKey );
        		if (admin != null)
        		{
                    // Finalize the application scope cache
                    Cache cache = (Cache) context.getAttribute(admin.getCacheKey());
                    if (cache != null) {
                    	admin.finalizeListeners(cache);
                        context.removeAttribute(admin.getCacheKey());
                        context.removeAttribute(adminKey);
                        cache = null;
                        if (log.isInfoEnabled()) {
                            log.info("Shut down the ServletCacheAdministrator "+adminKey);
                        }
                    }
                    admin = null;
        		}
        	}
        	context.removeAttribute(CACHE_ADMINISTRATORS_KEY);
        }
    }


    /**
    * Grabs the cache for the specified scope
    *
    * @param request The current request
    * @param scope The scope of this cache (<code>PageContext.APPLICATION_SCOPE</code>
    * or <code>PageContext.SESSION_SCOPE</code>)
    * @return The cache
    */
    public Cache getCache(HttpServletRequest request, int scope) {
        if (scope == PageContext.APPLICATION_SCOPE) {
            return getAppScopeCache(context);
        }

        if (scope == PageContext.SESSION_SCOPE) {
            return getSessionScopeCache(request.getSession(true));
        }

        throw new RuntimeException("The supplied scope value of " + scope + " is invalid. Acceptable values are PageContext.APPLICATION_SCOPE and PageContext.SESSION_SCOPE");
    }

    /**
    * A convenience method to retrieve the application scope cache

    * @param context the current <code>ServletContext</code>
    * @return the application scope cache. If none is present, one will
    * be created.
    */
    public Cache getAppScopeCache(ServletContext context) {
        Cache cache;
        Object obj = context.getAttribute(getCacheKey());

        if ((obj == null) || !(obj instanceof Cache)) {
            if (log.isInfoEnabled()) {
                log.info("Created new application-scoped cache at key: " + getCacheKey());
            }

            cache = createCache(PageContext.APPLICATION_SCOPE, null);
            context.setAttribute(getCacheKey(), cache);
        } else {
            cache = (Cache) obj;
        }

        return cache;
    }

    /**
    * A convenience method to retrieve the session scope cache
    *
    * @param session the current <code>HttpSession</code>
    * @return the session scope cache for this session. If none is present,
    * one will be created.
    */
    public Cache getSessionScopeCache(HttpSession session) {
        Cache cache;
        Object obj = session.getAttribute(getCacheKey());

        if ((obj == null) || !(obj instanceof Cache)) {
            if (log.isInfoEnabled()) {
                log.info("Created new session-scoped cache in session " + session.getId() + " at key: " + getCacheKey());
            }

            cache = createCache(PageContext.SESSION_SCOPE, session.getId());
            session.setAttribute(getCacheKey(), cache);
        } else {
            cache = (Cache) obj;
        }

        return cache;
    }

    /**
    * Get the cache key from the properties. Set it to a default value if it
    * is not present in the properties
    *
    * @return The cache.key property or the DEFAULT_CACHE_KEY
    */
    public String getCacheKey() {
        if (cacheKey == null) {
            cacheKey = getProperty(CACHE_KEY_KEY);

            if (cacheKey == null) {
                cacheKey = DEFAULT_CACHE_KEY;
            }
        }

        return cacheKey;
    }

    /**
    * Set the flush time for a specific scope to a specific time
    *
    * @param date  The time to flush the scope
    * @param scope The scope to be flushed
    */
    public void setFlushTime(Date date, int scope) {
        if (log.isInfoEnabled()) {
            log.info("Flushing scope " + scope + " at " + date);
        }

        synchronized (flushTimes) {
            if (date != null) {
                // Trigger a SCOPE_FLUSHED event
                dispatchScopeEvent(ScopeEventType.SCOPE_FLUSHED, scope, date, null);
                flushTimes.put(new Integer(scope), date);
            } else {
                logError("setFlushTime called with a null date.");
                throw new IllegalArgumentException("setFlushTime called with a null date.");
            }
        }
    }

    /**
    * Set the flush time for a specific scope to the current time.
    *
    * @param scope The scope to be flushed
    */
    public void setFlushTime(int scope) {
        setFlushTime(new Date(), scope);
    }

    /**
    *        Get the flush time for a particular scope.
    *
    *        @param        scope        The scope to get the flush time for.
    *        @return A date representing the time this scope was last flushed.
    *        Returns null if it has never been flushed.
    */
    public Date getFlushTime(int scope) {
        synchronized (flushTimes) {
            return (Date) flushTimes.get(new Integer(scope));
        }
    }

    /**
    * Retrieve an item from the cache
    *
    * @param scope The cache scope
    * @param request The servlet request
    * @param key The key of the object to retrieve
    * @param refreshPeriod The time interval specifying if an entry needs refresh
    * @return The requested object
    * @throws NeedsRefreshException
    */
    public Object getFromCache(int scope, HttpServletRequest request, String key, int refreshPeriod) throws NeedsRefreshException {

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产大陆a不卡| 久久成人精品无人区| 麻豆freexxxx性91精品| 欧美在线影院一区二区| 久久久99久久| 美女在线视频一区| 亚洲日本在线a| 99久久国产综合色|国产精品| 久久美女艺术照精彩视频福利播放 | 欧美精品一区二区三区在线播放| 中文字幕人成不卡一区| 成人免费观看男女羞羞视频| 国产精品日日摸夜夜摸av| 成人av免费在线观看| 亚洲女与黑人做爰| 欧美午夜在线观看| 麻豆精品新av中文字幕| 一区二区三区日韩| 欧美日韩欧美一区二区| 美女在线一区二区| 亚洲mv在线观看| 欧美妇女性影城| 麻豆精品在线视频| 日韩vs国产vs欧美| 欧美韩日一区二区三区| 色婷婷精品久久二区二区蜜臀av| 亚洲激情欧美激情| 精品国产91洋老外米糕| 91精品国产色综合久久不卡蜜臀| 久久99精品久久久久久久久久久久| 久久午夜色播影院免费高清| 日本丶国产丶欧美色综合| 奇米色一区二区| 国产精品三级电影| 国产精品免费久久久久| 欧美国产日本视频| 国产欧美一区二区精品久导航| 色妞www精品视频| 99久久精品国产精品久久| 91社区在线播放| 精品影视av免费| 美腿丝袜亚洲综合| 国产一区二区在线电影| 亚洲精品国产无套在线观| 日韩一区有码在线| 亚洲欧美激情视频在线观看一区二区三区| 久久奇米777| 国产精品色一区二区三区| 亚洲国产成人一区二区三区| 国产精品欧美一区二区三区| 亚洲视频在线观看三级| 亚洲一区二区欧美日韩| 久久精品一区蜜桃臀影院| 国产午夜精品理论片a级大结局 | 久久综合资源网| 久久久综合精品| 国产精品伦一区| 亚洲精品乱码久久久久久| 香蕉久久一区二区不卡无毒影院| 午夜成人在线视频| 亚洲欧美激情小说另类| 亚洲自拍都市欧美小说| 天天操天天干天天综合网| 国产综合一区二区| 日本vs亚洲vs韩国一区三区二区 | 蜜桃久久精品一区二区| 国产精品一二三| 麻豆国产欧美一区二区三区| 激情久久五月天| 9人人澡人人爽人人精品| 国产呦精品一区二区三区网站| 国产成人精品一区二| 99国产欧美久久久精品| 欧美久久久影院| 久久久精品国产免大香伊| 亚洲色图.com| 激情伊人五月天久久综合| 成人av网址在线| 欧美疯狂性受xxxxx喷水图片| 欧美精品一区二区三区高清aⅴ| 国产精品久久午夜夜伦鲁鲁| 国产清纯美女被跳蛋高潮一区二区久久w | 日本欧美久久久久免费播放网| 国产在线精品视频| 91成人在线精品| 久久一区二区三区四区| 夜夜嗨av一区二区三区网页| 久久福利资源站| 91碰在线视频| 久久一区二区视频| 午夜精彩视频在线观看不卡| 国产+成+人+亚洲欧洲自线| 国内偷窥港台综合视频在线播放| 91蜜桃视频在线| 精品精品欲导航| 欧美一区午夜视频在线观看| 国产精品免费免费| 久久国产精品99久久久久久老狼| 91老师片黄在线观看| 久久久久青草大香线综合精品| 亚洲综合久久av| 国产精品资源站在线| 欧美群妇大交群中文字幕| 欧美精品一二三四| 亚洲天堂2016| 国产精品一区久久久久| 欧美一区二视频| 亚洲国产视频直播| 麻豆国产一区二区| 欧美日韩高清影院| 一区二区三区加勒比av| 国产91精品一区二区麻豆亚洲| 欧美一卡二卡在线| 亚洲图片一区二区| 91极品美女在线| **性色生活片久久毛片| 国产精品66部| 久久久午夜精品| 蜜桃一区二区三区在线| 7799精品视频| 久久理论电影网| 黄网站免费久久| 日韩欧美一区二区久久婷婷| 中文字幕 久热精品 视频在线| 激情都市一区二区| 精品久久久久久久久久久久久久久久久| 偷窥少妇高潮呻吟av久久免费| 在线免费观看日韩欧美| 亚洲日本电影在线| 91日韩精品一区| 一区二区欧美精品| 在线国产电影不卡| 亚洲国产乱码最新视频| 欧美日免费三级在线| 香蕉加勒比综合久久 | 久久精品在这里| 国产一区视频网站| 国产女人水真多18毛片18精品视频 | 五月婷婷综合网| 欧美日韩国产高清一区二区 | 国产精品国模大尺度视频| 国产sm精品调教视频网站| 日本一区二区免费在线观看视频| 久久狠狠亚洲综合| 久久精品亚洲精品国产欧美kt∨| 国产一区二区久久| 国产精品丝袜久久久久久app| av不卡免费电影| 亚洲一区二区在线免费观看视频| 欧美色图激情小说| 日本欧美加勒比视频| 精品嫩草影院久久| 国产成人自拍网| 国产精品对白交换视频| 91官网在线观看| 裸体歌舞表演一区二区| 国产欧美1区2区3区| 国产成人鲁色资源国产91色综 | 色天天综合久久久久综合片| 亚洲综合久久久| 日韩欧美的一区二区| 国产成人综合视频| 亚洲精品五月天| 欧美一区二区三区在| 国产一区二区影院| 一区二区三区在线视频免费 | 久久精品99国产精品| 中文字幕欧美日本乱码一线二线| 99热精品一区二区| 天天综合网天天综合色| 久久亚洲免费视频| 91精品91久久久中77777| 麻豆精品视频在线观看免费| 国产精品美女久久久久aⅴ| 欧美在线观看一二区| 狠狠色伊人亚洲综合成人| 亚洲特黄一级片| 欧美一区二区观看视频| 成人app网站| 蜜臀久久99精品久久久画质超高清| 久久精品一区二区三区av | 国产欧美精品在线观看| 欧美日韩不卡一区二区| 国产不卡在线视频| 天天影视网天天综合色在线播放| 中文无字幕一区二区三区| 欧美色中文字幕| 丁香桃色午夜亚洲一区二区三区| 亚洲va在线va天堂| 亚洲三级在线看| 久久久精品免费免费| 91麻豆精品国产91久久久久久| 风间由美一区二区三区在线观看| 婷婷中文字幕综合| 亚洲免费在线电影| 国产日韩亚洲欧美综合| 91精品国产手机| 欧美撒尿777hd撒尿| jlzzjlzz国产精品久久| 国产露脸91国语对白|