001package org.apache.commons.jcs.auxiliary.disk.indexed; 002 003/* 004 * Licensed to the Apache Software Foundation (ASF) under one 005 * or more contributor license agreements. See the NOTICE file 006 * distributed with this work for additional information 007 * regarding copyright ownership. The ASF licenses this file 008 * to you under the Apache License, Version 2.0 (the 009 * "License"); you may not use this file except in compliance 010 * with the License. You may obtain a copy of the License at 011 * 012 * http://www.apache.org/licenses/LICENSE-2.0 013 * 014 * Unless required by applicable law or agreed to in writing, 015 * software distributed under the License is distributed on an 016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 017 * KIND, either express or implied. See the License for the 018 * specific language governing permissions and limitations 019 * under the License. 020 */ 021 022import org.apache.commons.jcs.auxiliary.AbstractAuxiliaryCacheFactory; 023import org.apache.commons.jcs.auxiliary.AuxiliaryCacheAttributes; 024import org.apache.commons.jcs.engine.behavior.ICompositeCacheManager; 025import org.apache.commons.jcs.engine.behavior.IElementSerializer; 026import org.apache.commons.jcs.engine.logging.behavior.ICacheEventLogger; 027import org.apache.commons.logging.Log; 028import org.apache.commons.logging.LogFactory; 029 030/** 031 * Creates disk cache instances. 032 */ 033public class IndexedDiskCacheFactory 034 extends AbstractAuxiliaryCacheFactory 035{ 036 /** The logger. */ 037 private static final Log log = LogFactory.getLog( IndexedDiskCacheFactory.class ); 038 039 /** 040 * Create an instance of an IndexedDiskCache. 041 * <p> 042 * @param iaca cache attributes of this cache instance 043 * @param cacheMgr This allows auxiliaries to reference the manager without assuming that it is 044 * a singleton. This will allow JCS to be a non-singleton. Also, it makes it easier to 045 * test. 046 * @param cacheEventLogger 047 * @param elementSerializer 048 * @return IndexedDiskCache 049 */ 050 @Override 051 public <K, V> IndexedDiskCache<K, V> createCache( AuxiliaryCacheAttributes iaca, ICompositeCacheManager cacheMgr, 052 ICacheEventLogger cacheEventLogger, IElementSerializer elementSerializer ) 053 { 054 IndexedDiskCacheAttributes idca = (IndexedDiskCacheAttributes) iaca; 055 if ( log.isDebugEnabled() ) 056 { 057 log.debug( "Creating DiskCache for attributes = " + idca ); 058 } 059 060 IndexedDiskCache<K, V> cache = new IndexedDiskCache<K, V>( idca, elementSerializer ); 061 cache.setCacheEventLogger( cacheEventLogger ); 062 063 return cache; 064 } 065}