1 package org.apache.jcs.auxiliary.disk.file;
2
3 import java.io.Serializable;
4
5 import org.apache.commons.logging.Log;
6 import org.apache.commons.logging.LogFactory;
7 import org.apache.jcs.auxiliary.AuxiliaryCacheAttributes;
8 import org.apache.jcs.auxiliary.AuxiliaryCacheFactory;
9 import org.apache.jcs.engine.behavior.ICompositeCacheManager;
10 import org.apache.jcs.engine.behavior.IElementSerializer;
11 import org.apache.jcs.engine.logging.behavior.ICacheEventLogger;
12
13
14 public class FileDiskCacheFactory
15 implements AuxiliaryCacheFactory
16 {
17
18 private final static Log log = LogFactory.getLog( FileDiskCacheFactory.class );
19
20
21 private String name;
22
23
24 private FileDiskCacheManager diskFileCacheManager;
25
26
27
28
29
30
31
32
33
34
35
36
37 public <K extends Serializable, V extends Serializable> FileDiskCache<K, V> createCache(
38 AuxiliaryCacheAttributes attr, ICompositeCacheManager cacheMgr,
39 ICacheEventLogger cacheEventLogger, IElementSerializer elementSerializer )
40 {
41 FileDiskCacheAttributes idfca = (FileDiskCacheAttributes) attr;
42 if ( log.isDebugEnabled() )
43 {
44 log.debug( "Creating DiskFileCache for attributes = " + idfca );
45 }
46 synchronized( this )
47 {
48 if ( diskFileCacheManager == null )
49 {
50 if ( log.isDebugEnabled() )
51 {
52 log.debug( "Creating DiskFileCacheManager" );
53 }
54 diskFileCacheManager = new FileDiskCacheManager( idfca, cacheEventLogger, elementSerializer );
55 }
56 return diskFileCacheManager.getCache( idfca );
57 }
58 }
59
60
61
62
63
64
65 public String getName()
66 {
67 return this.name;
68 }
69
70
71
72
73
74
75 public void setName( String name )
76 {
77 this.name = name;
78 }
79 }