1 package org.apache.jcs.auxiliary.disk.indexed;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.apache.commons.logging.Log;
23 import org.apache.commons.logging.LogFactory;
24 import org.apache.jcs.auxiliary.AuxiliaryCache;
25 import org.apache.jcs.auxiliary.AuxiliaryCacheAttributes;
26 import org.apache.jcs.auxiliary.AuxiliaryCacheFactory;
27 import org.apache.jcs.engine.behavior.ICompositeCacheManager;
28
29 /***
30 * Creates disk cache instances.
31 */
32 public class IndexedDiskCacheFactory
33 implements AuxiliaryCacheFactory
34 {
35 private final static Log log = LogFactory.getLog( IndexedDiskCacheFactory.class );
36
37 private String name;
38
39 /***
40 * Get an instance of the IndexDiskCacheManager for the attributes and then
41 * get an IndexedDiskCache from the manager.
42 * <p>
43 * The manager is a singleton.
44 * <p>
45 * One disk cache is returned per region fromt he maanger.
46 * <p>
47 * @param iaca
48 * @param cacheMgr
49 * This allows auxiliaries to reference the manager without
50 * assuming that it is a singleton. This will allow JCS to be a
51 * nonsingleton. Also, it makes it easier to test.
52 * @return AuxiliaryCache
53 */
54 public AuxiliaryCache createCache( AuxiliaryCacheAttributes iaca, ICompositeCacheManager cacheMgr )
55 {
56 IndexedDiskCacheAttributes idca = (IndexedDiskCacheAttributes) iaca;
57 if ( log.isDebugEnabled() )
58 {
59 log.debug( "Creating DiskCache for attributes = " + idca );
60 }
61 IndexedDiskCacheManager dcm = IndexedDiskCacheManager.getInstance( idca );
62 return dcm.getCache( idca );
63 }
64
65 /***
66 * Gets the name attribute of the DiskCacheFactory object
67 * <p>
68 * @return The name value
69 */
70 public String getName()
71 {
72 return this.name;
73 }
74
75 /***
76 * Sets the name attribute of the DiskCacheFactory object
77 * <p>
78 * @param name
79 * The new name value
80 */
81 public void setName( String name )
82 {
83 this.name = name;
84 }
85 }