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

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

?? cachemodel.java

?? 本套系統采用了業界當前最為流行的beanAction組件
?? JAVA
字號:
/*
 *  Copyright 2004 Clinton Begin
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package com.ibatis.sqlmap.engine.cache;

import com.ibatis.common.logging.Log;
import com.ibatis.common.logging.LogFactory;
import com.ibatis.common.resources.Resources;
import com.ibatis.sqlmap.engine.mapping.statement.ExecuteListener;
import com.ibatis.sqlmap.engine.mapping.statement.MappedStatement;

import java.io.*;
import java.util.*;

/**
 * Wrapper for Caches.
 */
public class CacheModel implements ExecuteListener {

  private static final Log log = LogFactory.getLog(CacheModel.class);

  private static final int MAX_OBJECT_LOG_SIZE = 200;

  /**
   * This is used to represent null objects that are returned from the cache so
   * that they can be cached, too.
   */
  public static final Object NULL_OBJECT = new Object();
  private int requests = 0;
  private int hits = 0;

  /**
   * Constant to turn off periodic cache flushes
   */
  private static final long NO_FLUSH_INTERVAL = -99999;

  private String id;

  private boolean readOnly;
  private boolean serialize;

  private long lastFlush;
  private long flushInterval;
  private long flushIntervalSeconds;
  private Set flushTriggerStatements;

  private CacheController controller;

  private String resource;

  /**
   * Default constructor
   */
  public CacheModel() {
    this.flushInterval = NO_FLUSH_INTERVAL;
    this.flushIntervalSeconds = NO_FLUSH_INTERVAL;
    this.lastFlush = System.currentTimeMillis();
    this.flushTriggerStatements = new HashSet();
  }

  /**
   * Getter for the cache model's id
   *
   * @return the id
   */
  public String getId() {
    return id;
  }

  /**
   * Setter for the cache model's id
   *
   * @param id - the new id
   */
  public void setId(String id) {
    this.id = id;
  }

  /**
   * Getter for read-only property
   *
   * @return true if a read-only model
   */
  public boolean isReadOnly() {
    return readOnly;
  }

  /**
   * Setter for read-only property
   *
   * @param readOnly - the new setting
   */
  public void setReadOnly(boolean readOnly) {
    this.readOnly = readOnly;
  }

  /**
   * Getter to tell if the cache serializes
   *
   * @return true if the cache model serializes objects
   */
  public boolean isSerialize() {
    return serialize;
  }

  /**
   * Setter to tell the cache to serialize objects
   *
   * @param serialize - if the cache model is to serialize objects
   */
  public void setSerialize(boolean serialize) {
    this.serialize = serialize;
  }

  /**
   * Getter for resource property
   *
   * @return the value of the resource property
   */
  public String getResource() {
    return resource;
  }

  /**
   * Setter for resource property
   *
   * @param resource - the new value
   */
  public void setResource(String resource) {
    this.resource = resource;
  }

  /**
   * Sets up the controller for the cache model
   *
   * @param implementation - the class (FQCN) for the controller
   * @throws ClassNotFoundException - if the class cannot be found
   * @throws InstantiationException - if the class cannot be instantiated
   * @throws IllegalAccessException - if the classes constructor is not accessible
   */
  public void setControllerClassName(String implementation)
      throws ClassNotFoundException, InstantiationException, IllegalAccessException {
    Class clazz = Resources.classForName(implementation);
    controller = (CacheController) Resources.instantiate(clazz);
  }

  /**
   * Getter for flushInterval property
   *
   * @return The flushInterval (in milliseconds)
   */
  public long getFlushInterval() {
    return flushInterval;
  }

  /**
   * Getter for flushInterval property
   *
   * @return The flushInterval (in milliseconds)
   */
  public long getFlushIntervalSeconds() {
    return flushIntervalSeconds;
  }

  /**
   * Setter for flushInterval property
   *
   * @param flushInterval The new flushInterval (in milliseconds)
   */
  public void setFlushInterval(long flushInterval) {
    this.flushInterval = flushInterval;
    this.flushIntervalSeconds = flushInterval / 1000;
  }

  /**
   * Adds a flushTriggerStatment. When a flushTriggerStatment is executed, the
   * cache is flushed (cleared).
   *
   * @param statementName The statement to add.
   */
  public void addFlushTriggerStatement(String statementName) {
    flushTriggerStatements.add(statementName);
  }

  /**
   * Gets an Iterator containing all flushTriggerStatment objects for this cache.
   *
   * @return The Iterator
   */
  public Iterator getFlushTriggerStatementNames() {
    return flushTriggerStatements.iterator();
  }

  /**
   * ExecuteListener event.  This will be called by a MappedStatement
   * for which this cache is registered as a ExecuteListener.  It will
   * be called each time an executeXXXXXX method is called.  In the
   * case of the Cache class, it is registered in order to flush the
   * cache whenever a certain statement is executed.
   * (i.e. the flushOnExecute cache policy)
   *
   * @param statement The statement to execute
   */
  public void onExecuteStatement(MappedStatement statement) {
    flush();
  }


  /**
   * Returns statistical information about the cache.
   *
   * @return the number of cache hits divided by the total requests
   */
  public double getHitRatio() {
    return (double) hits / (double) requests;
  }

  /**
   * Configures the cache
   *
   * @param props
   */
  public void configure(Properties props) {
    controller.configure(props);
  }

  /**
   * Clears the cache
   */
  public void flush() {
  	synchronized (this)  {
      controller.flush(this);
      lastFlush = System.currentTimeMillis();
      if ( log.isDebugEnabled() )  {
        log("flushed", false, null);
      }
    }
  }

  /**
   * Get an object out of the cache.
   * A side effect of this method is that is may clear the cache if it has not been
   * cleared in the flushInterval.
   *
   * @param key The key of the object to be returned
   * @return The cached object (or null)
   */
  public Object getObject(CacheKey key) {
  	Object value = null;
    synchronized (this) {
      if (flushInterval != NO_FLUSH_INTERVAL
          && System.currentTimeMillis() - lastFlush > flushInterval) {
        flush();
      }

      value = controller.getObject(this, key);
      if (serialize && !readOnly &&
       	    (value != NULL_OBJECT && value != null)) {
        try {
          ByteArrayInputStream bis = new ByteArrayInputStream((byte[]) value);
          ObjectInputStream ois = new ObjectInputStream(bis);
          value = ois.readObject();
          ois.close();
        } catch (Exception e) {
          throw new RuntimeException("Error caching serializable object.  Be sure you're not attempting to use " +
                                           "a serialized cache for an object that may be taking advantage of lazy loading.  Cause: " + e, e);
        }
      }
      requests++;
      if (value != null) {
        hits++;
      }
      if ( log.isDebugEnabled() )  {
      	if ( value != null )  {
            log("retrieved object", true, value);
      	}
      	else  {
      		log("cache miss", false, null);
      	}
      }
    }
    return value;
  }

  /**
   * Add an object to the cache
   *
   * @param key   The key of the object to be cached
   * @param value The object to be cached
   */
  public void putObject(CacheKey key, Object value) {
  	if (null == value) value = NULL_OBJECT;
  	synchronized ( this )  {
      if (serialize && !readOnly && value != NULL_OBJECT) {
        try {
          ByteArrayOutputStream bos = new ByteArrayOutputStream();
          ObjectOutputStream oos = new ObjectOutputStream(bos);
          oos.writeObject(value);
          oos.flush();
          oos.close();
          value = bos.toByteArray();
        } catch (IOException e) {
          throw new RuntimeException("Error caching serializable object.  Cause: " + e, e);
        }
      }
      controller.putObject(this, key, value);
      if ( log.isDebugEnabled() )  {
        log("stored object", true, value);
      }
    }
  }

  /**
   * Get the maximum size of an object in the log output.
   *
   * @return Maximum size of a logged object in the output
   */
  protected int getMaxObjectLogSize()  {
      return MAX_OBJECT_LOG_SIZE;
  }

  /**
   * Log a cache action. Since this method is pretty heavy
   * weight, it's best to enclose it with a log.isDebugEnabled()
   * when called.
   *
   * @param action String to output
   * @param addValue Add the value being cached to the log
   * @param cacheValue The value being logged
   */
  protected void log(String action, boolean addValue,
  		             Object cacheValue)  {
    StringBuffer output = new StringBuffer("Cache '");
    output.append(getId());
    output.append("': ");
    output.append(action);
    if ( addValue )  {
      String cacheObjectStr = (cacheValue == null ? "null" : cacheValue.toString());
      output.append(" '");
      if ( cacheObjectStr.length() < getMaxObjectLogSize() )  {
      	output.append(cacheObjectStr.toString());
      }
      else  {
      	output.append(cacheObjectStr.substring(1,
      			                 getMaxObjectLogSize()));
      	output.append("...");
      }
      output.append("'");
    }
    log.debug(output.toString());
  }
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩av中文在线观看| 一区二区三区日韩欧美| 国产精品欧美经典| 午夜精品一区在线观看| 国产剧情一区二区三区| 欧洲亚洲国产日韩| 久久综合九色综合欧美就去吻| 亚洲男人的天堂在线观看| 伦理电影国产精品| 在线精品亚洲一区二区不卡| 国产精品国产三级国产a| 日韩不卡手机在线v区| 91免费观看视频在线| 国产欧美精品一区二区色综合 | 色哟哟在线观看一区二区三区| 欧美一级日韩不卡播放免费| 亚洲影视资源网| thepron国产精品| 中文字幕va一区二区三区| 天涯成人国产亚洲精品一区av| 色天使色偷偷av一区二区| 亚洲国产精品黑人久久久| 韩国女主播成人在线观看| 欧美一级黄色片| 丝袜美腿一区二区三区| 欧洲激情一区二区| 亚洲欧美电影一区二区| av一区二区久久| 国产精品久久久久久久午夜片| 国产精品亚洲专一区二区三区| 日韩欧美精品在线| 奇米精品一区二区三区四区| 91精品国产综合久久福利软件| 亚洲成av人影院在线观看网| 欧美午夜不卡视频| 亚洲综合色在线| 欧美精品第1页| 日韩 欧美一区二区三区| 欧美精品在线视频| 日本在线不卡一区| 欧美一区二区福利视频| 卡一卡二国产精品 | 中文字幕av一区 二区| 国产精品亚洲第一区在线暖暖韩国 | 欧美日本国产视频| 亚洲网友自拍偷拍| 欧美日韩国产经典色站一区二区三区| 亚洲成人av福利| 欧美日韩成人综合天天影院| 日韩成人一级片| 久久婷婷国产综合精品青草| 丰满亚洲少妇av| 综合欧美亚洲日本| 在线观看欧美日本| 日本视频一区二区| 国产日韩欧美精品电影三级在线| 不卡一卡二卡三乱码免费网站| 亚洲日穴在线视频| 欧美日韩国产小视频在线观看| 紧缚捆绑精品一区二区| 国产情人综合久久777777| 91麻豆国产香蕉久久精品| 亚洲成a人片在线观看中文| 精品女同一区二区| 99久久婷婷国产综合精品电影| 亚洲自拍都市欧美小说| 日韩欧美精品在线| av中文字幕一区| 麻豆国产欧美一区二区三区| 中文字幕在线观看一区| 欧美日韩大陆一区二区| 国产精品1024| 五月婷婷色综合| 国产精品美女www爽爽爽| 欧美视频一区二区三区| 国产精品一区二区在线观看网站| 一区二区在线观看免费视频播放| 日韩欧美中文字幕精品| 91一区二区在线| 久草这里只有精品视频| 亚洲卡通动漫在线| 亚洲精品一区在线观看| 一本一本大道香蕉久在线精品 | 中文字幕乱码久久午夜不卡| 欧美日韩国产在线观看| 国产成人超碰人人澡人人澡| 视频在线观看91| 亚洲人亚洲人成电影网站色| 日韩一区二区影院| 色婷婷久久一区二区三区麻豆| 黄色精品一二区| 日韩影院精彩在线| 亚洲欧美成aⅴ人在线观看| 久久先锋资源网| 欧美妇女性影城| 麻豆91精品视频| 亚洲免费观看高清完整版在线| 欧美伊人精品成人久久综合97| 久久久久久一二三区| 国产蜜臀97一区二区三区| 国产大片一区二区| 亚洲国产精品影院| 亚洲欧洲无码一区二区三区| 久久九九久久九九| 精品剧情v国产在线观看在线| 欧美日韩三级视频| 91高清视频在线| 色欧美88888久久久久久影院| 成人av电影在线| 国产成人av电影| 高清shemale亚洲人妖| 国产精品自拍毛片| 国内欧美视频一区二区| 裸体一区二区三区| 蜜桃视频在线一区| 日韩电影免费一区| 免费成人av在线| 久久激情五月激情| 久久国产精品99久久久久久老狼| 久久精品99国产精品| 久久99国产精品久久99| 国产乱人伦偷精品视频不卡| 国产成人午夜精品5599| 成人av动漫在线| 在线观看免费视频综合| 色久优优欧美色久优优| 色老汉一区二区三区| 欧美精品在线视频| 日韩欧美另类在线| 久久久久成人黄色影片| 亚洲日本中文字幕区| 午夜精品123| 国内精品久久久久影院薰衣草| 国产成人无遮挡在线视频| 国产盗摄一区二区| 色综合久久中文字幕综合网 | 色综合天天综合色综合av | 欧美精品第1页| 欧美不卡激情三级在线观看| 国产视频911| 亚洲黄色av一区| 蜜桃视频一区二区三区 | 国产欧美精品一区二区三区四区| 国产精品乱码一区二区三区软件| 亚洲人成网站影音先锋播放| 午夜国产精品一区| 国产综合久久久久久久久久久久| 成人a免费在线看| 欧美日韩国产乱码电影| 久久亚洲一区二区三区明星换脸 | 91在线无精精品入口| 欧洲生活片亚洲生活在线观看| 5月丁香婷婷综合| 欧美国产一区二区| 亚洲va韩国va欧美va| 国产福利精品导航| 欧美日韩日日骚| 国产蜜臀97一区二区三区| 亚洲成人免费视频| 国产99久久久国产精品免费看| 欧美色图一区二区三区| 精品国产自在久精品国产| 亚洲精品欧美二区三区中文字幕| 久久狠狠亚洲综合| 在线一区二区视频| 久久综合色8888| 欧美色偷偷大香| 国产免费成人在线视频| 日韩电影在线一区| 91丝袜高跟美女视频| 精品国产乱码久久久久久浪潮| 亚洲国产欧美日韩另类综合 | 国产精品美女久久久久aⅴ| 五月天网站亚洲| 97精品国产97久久久久久久久久久久| 日韩欧美国产小视频| 亚洲欧美在线视频| 国产美女精品在线| 91麻豆精品国产91久久久久| 一区二区在线观看免费视频播放| 国产91精品入口| 亚洲精品一区二区三区香蕉| 日韩国产精品91| 欧洲精品一区二区三区在线观看| 国产精品久久久久影院亚瑟| 国产综合色视频| 欧美电影免费观看高清完整版| 亚洲成av人片在线观看| 一本久久a久久精品亚洲| 日本一区二区三区四区在线视频| 美女网站视频久久| 欧美老人xxxx18| 天涯成人国产亚洲精品一区av| 欧美三级电影在线看| 亚洲美女屁股眼交| 91麻豆国产福利精品| 综合婷婷亚洲小说| 99在线精品免费| 亚洲色图在线播放| 91在线小视频|