1 package org.apache.commons.jcs.auxiliary.disk.indexed;
2
3 /*
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
19 * under the License.
20 */
21
22 import org.apache.commons.jcs.auxiliary.AbstractAuxiliaryCacheFactory;
23 import org.apache.commons.jcs.auxiliary.AuxiliaryCacheAttributes;
24 import org.apache.commons.jcs.engine.behavior.ICompositeCacheManager;
25 import org.apache.commons.jcs.engine.behavior.IElementSerializer;
26 import org.apache.commons.jcs.engine.logging.behavior.ICacheEventLogger;
27 import org.apache.commons.logging.Log;
28 import org.apache.commons.logging.LogFactory;
29
30 /**
31 * Creates disk cache instances.
32 */
33 public class IndexedDiskCacheFactory
34 extends AbstractAuxiliaryCacheFactory
35 {
36 /** The logger. */
37 private static final Log log = LogFactory.getLog( IndexedDiskCacheFactory.class );
38
39 /**
40 * Create an instance of an IndexedDiskCache.
41 * <p>
42 * @param iaca cache attributes of this cache instance
43 * @param cacheMgr This allows auxiliaries to reference the manager without assuming that it is
44 * a singleton. This will allow JCS to be a non-singleton. Also, it makes it easier to
45 * test.
46 * @param cacheEventLogger
47 * @param elementSerializer
48 * @return IndexedDiskCache
49 */
50 @Override
51 public <K, V> IndexedDiskCache<K, V> createCache( AuxiliaryCacheAttributes iaca, ICompositeCacheManager cacheMgr,
52 ICacheEventLogger cacheEventLogger, IElementSerializer elementSerializer )
53 {
54 IndexedDiskCacheAttributes idca = (IndexedDiskCacheAttributes) iaca;
55 if ( log.isDebugEnabled() )
56 {
57 log.debug( "Creating DiskCache for attributes = " + idca );
58 }
59
60 IndexedDiskCache<K, V> cache = new IndexedDiskCache<K, V>( idca, elementSerializer );
61 cache.setCacheEventLogger( cacheEventLogger );
62
63 return cache;
64 }
65 }