亚洲欧美第一页_禁久久精品乱码_粉嫩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一区二区三区在线| 国产一级精品在线| 日韩女优电影在线观看| 亚洲一区二区三区激情| 欧美性一二三区| 夜夜爽夜夜爽精品视频| 在线观看免费视频综合| 午夜日韩在线电影| 91精品国产91久久综合桃花| 三级在线观看一区二区| 日韩一区二区精品葵司在线| 久久99精品国产.久久久久久| 久久色中文字幕| 97se亚洲国产综合在线| 五月激情综合婷婷| 精品少妇一区二区三区在线播放 | 91在线观看视频| 亚洲午夜久久久久久久久久久| 中文子幕无线码一区tr| 在线免费观看不卡av| 日本人妖一区二区| 国产精品久久免费看| 69久久夜色精品国产69蝌蚪网| 精品一区二区三区蜜桃| 中文字幕视频一区二区三区久| 欧美日韩免费观看一区三区| 韩国视频一区二区| 亚洲尤物视频在线| 中文无字幕一区二区三区| 欧美日韩国产在线播放网站| 麻豆精品蜜桃视频网站| 一区二区激情小说| 亚洲国产激情av| www成人在线观看| av电影天堂一区二区在线 | 亚洲一区二区美女| 精品动漫一区二区三区在线观看| 97久久精品人人做人人爽| 国产精品白丝av| 国产一区视频导航| 裸体健美xxxx欧美裸体表演| 视频一区视频二区在线观看| 久久蜜桃一区二区| 2020国产精品自拍| 久久五月婷婷丁香社区| 亚洲精品在线免费观看视频| 欧美亚洲另类激情小说| 国产成人h网站| 国产一区二区免费在线| 久久99国产精品免费| 日韩在线播放一区二区| 午夜一区二区三区视频| 亚洲国产精品天堂| 男人的天堂久久精品| 亚洲成人综合视频| 日本色综合中文字幕| 精品在线视频一区| 国产激情精品久久久第一区二区 | 国产精品免费网站在线观看| 中文字幕在线一区| 一区二区三区不卡视频| 婷婷国产在线综合| 国模无码大尺度一区二区三区 | 亚洲一区av在线| 韩日av一区二区| 色8久久精品久久久久久蜜| 正在播放亚洲一区| 中文字幕一区二区不卡 | 亚洲国产另类精品专区| 另类调教123区| 99re6这里只有精品视频在线观看| 88在线观看91蜜桃国自产| 国产日韩综合av| 性感美女久久精品| 不卡电影一区二区三区| 日韩一区二区三区在线观看| ㊣最新国产の精品bt伙计久久| 日本不卡一区二区| 91国产福利在线| 国产精品久久久久久久久免费桃花| 亚洲影院在线观看| 不卡视频在线观看| 国产精品麻豆久久久| 欧美在线free| 成人免费在线视频| 成人app软件下载大全免费| 欧美电视剧免费全集观看| 亚洲免费观看在线视频| www.一区二区| 中文字幕乱码久久午夜不卡| 免费国产亚洲视频| 日韩午夜激情av| 视频在线观看一区二区三区| 91高清视频免费看| 亚洲一区二区四区蜜桃| 欧美在线短视频| 亚洲午夜精品在线| 欧美午夜在线一二页| 亚洲国产精品久久人人爱 | 欧美日韩美女一区二区| 亚洲国产美女搞黄色| 欧美亚洲综合久久| 美女视频黄a大片欧美| xf在线a精品一区二区视频网站| 国产专区综合网| 国产精品久久久99| 在线播放中文一区| 韩国成人福利片在线播放| 亚洲成人av在线电影| 日韩免费高清av| 91免费精品国自产拍在线不卡| 亚洲午夜影视影院在线观看| 9191精品国产综合久久久久久| 日韩精品1区2区3区| 国产色一区二区| 欧美亚洲自拍偷拍| 久久99久久精品欧美| 亚洲色大成网站www久久九九| 欧美日本韩国一区二区三区视频| 久久爱另类一区二区小说| 亚洲欧美日韩人成在线播放| 7777精品久久久大香线蕉| 国产大陆a不卡| 日本一不卡视频| 亚洲综合激情另类小说区| 国产偷国产偷精品高清尤物| 欧美日韩国产首页| 色老综合老女人久久久| 国产成人av一区二区| 蜜桃视频免费观看一区| 亚洲精品视频在线看| 欧美哺乳videos| 一区二区三区欧美| 国产精品久久久久影院亚瑟| 欧美一区二区三区喷汁尤物| 色综合久久久久综合体| 国产suv精品一区二区三区| 色国产综合视频| 91麻豆产精品久久久久久| 亚洲妇女屁股眼交7| 亚洲电影一级黄| 同产精品九九九| 一区二区理论电影在线观看| 樱花影视一区二区| 一二三四社区欧美黄| 一区二区三区在线观看动漫| 成人免费在线播放视频| 中文字幕一区二区三区不卡| 国产欧美一区二区精品性色| 国产精品丝袜一区| 中文字幕一区二区日韩精品绯色| 亚洲视频免费在线观看| 亚洲综合视频网| 久久69国产一区二区蜜臀| 高清在线成人网| av一区二区三区在线| 欧美丰满一区二区免费视频| 精品国产一区二区三区久久久蜜月 | 精品一区二区综合| 国产精品综合视频| 在线一区二区观看| 26uuu色噜噜精品一区| 中文字幕第一页久久| 亚洲嫩草精品久久| 国产资源在线一区| 7777女厕盗摄久久久| 日本一区二区三区免费乱视频| 亚洲影视资源网| 成人白浆超碰人人人人| 在线播放中文字幕一区| 亚洲色图.com| 国产aⅴ综合色| 久久人人97超碰com| 亚洲国产aⅴ天堂久久| www.久久久久久久久| 亚洲精品一区二区三区福利| 亚洲国产精品久久人人爱 | 国产乱一区二区| 日韩精品在线一区| 欧美色区777第一页| 久久色在线观看| 久草精品在线观看| 欧美—级在线免费片| 福利91精品一区二区三区| 日韩毛片一二三区| 色国产精品一区在线观看| 亚洲不卡av一区二区三区| 欧美一区二区三区免费| 18欧美乱大交hd1984| 成人激情开心网| 九九国产精品视频| 欧美精品视频www在线观看| 一区二区激情视频| 欧美视频一区二| 三级成人在线视频| 日韩一级免费一区| 国产一区二区在线观看视频| 久久综合色之久久综合| 国产精品一品视频|