1 package org.apache.jcs.auxiliary.disk.block;
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 BlockDiskCacheFactory
33 implements AuxiliaryCacheFactory
34 {
35 /*** The logger */
36 private final static Log log = LogFactory.getLog( BlockDiskCacheFactory.class );
37
38 /*** The auxiliary name */
39 private String name;
40
41 /***
42 * Get an instance of the BlockDiskCacheManager for the attributes and then get an
43 * IndexedDiskCache from the manager.
44 * <p>
45 * The manager is a singleton.
46 * <p>
47 * One disk cache is returned per region fromt he maanger.
48 * <p>
49 * @param iaca
50 * @param cacheMgr This allows auxiliaries to reference the manager without assuming that it is
51 * a singleton. This will allow JCS to be a nonsingleton. Also, it makes it easier to
52 * test.
53 * @return AuxiliaryCache
54 */
55 public AuxiliaryCache createCache( AuxiliaryCacheAttributes iaca, ICompositeCacheManager cacheMgr )
56 {
57 BlockDiskCacheAttributes idca = (BlockDiskCacheAttributes) iaca;
58 if ( log.isDebugEnabled() )
59 {
60 log.debug( "Creating DiskCache for attributes = " + idca );
61 }
62 BlockDiskCacheManager dcm = BlockDiskCacheManager.getInstance( idca );
63 return dcm.getCache( idca );
64 }
65
66 /***
67 * Gets the name attribute of the DiskCacheFactory object
68 * <p>
69 * @return The name value
70 */
71 public String getName()
72 {
73 return this.name;
74 }
75
76 /***
77 * Sets the name attribute of the DiskCacheFactory object
78 * <p>
79 * @param name The new name value
80 */
81 public void setName( String name )
82 {
83 this.name = name;
84 }
85 }