1 package org.apache.jcs.auxiliary.disk.jdbc;
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
26 /***
27 * This manages instances of the jdbc disk cache. It maintains one for each
28 * region. One for all regions would work, but this gives us more detailed stats
29 * by region.
30 */
31 public class JDBCDiskCacheManager
32 extends JDBCDiskCacheManagerAbstractTemplate
33 {
34 private static final long serialVersionUID = -8258856770927857896L;
35
36 private static final Log log = LogFactory.getLog( JDBCDiskCacheManager.class );
37
38 private static JDBCDiskCacheManager instance;
39
40 private JDBCDiskCacheAttributes defaultJDBCDiskCacheAttributes;
41
42 /***
43 * Constructor for the HSQLCacheManager object
44 * <p>
45 * @param cattr
46 */
47 private JDBCDiskCacheManager( JDBCDiskCacheAttributes cattr )
48 {
49 if ( log.isInfoEnabled() )
50 {
51 log.info( "Creating JDBCDiskCacheManager with " + cattr );
52 }
53 defaultJDBCDiskCacheAttributes = cattr;
54 }
55
56 /***
57 * Gets the defaultCattr attribute of the HSQLCacheManager object
58 * <p>
59 * @return The defaultCattr value
60 */
61 public JDBCDiskCacheAttributes getDefaultJDBCDiskCacheAttributes()
62 {
63 return defaultJDBCDiskCacheAttributes;
64 }
65
66 /***
67 * Gets the instance attribute of the HSQLCacheManager class
68 * <p>
69 * @param cattr
70 * @return The instance value
71 */
72 public static JDBCDiskCacheManager getInstance( JDBCDiskCacheAttributes cattr )
73 {
74 synchronized ( JDBCDiskCacheManager.class )
75 {
76 if ( instance == null )
77 {
78 instance = new JDBCDiskCacheManager( cattr );
79 }
80 }
81 clients++;
82 return instance;
83 }
84
85 /***
86 * Gets the cache attribute of the HSQLCacheManager object
87 * <p>
88 * @param cacheName
89 * @return The cache value
90 */
91 public AuxiliaryCache getCache( String cacheName )
92 {
93 JDBCDiskCacheAttributes cattr = (JDBCDiskCacheAttributes) defaultJDBCDiskCacheAttributes.copy();
94 cattr.setCacheName( cacheName );
95 return getCache( cattr );
96 }
97
98 /***
99 * Creates a JDBCDiskCache using the supplied attributes.
100 * <p>
101 * @param cattr
102 * @return
103 */
104 protected AuxiliaryCache createJDBCDiskCache( JDBCDiskCacheAttributes cattr, TableState tableState )
105 {
106 AuxiliaryCache raf;
107 raf = new JDBCDiskCache( cattr, tableState );
108 return raf;
109 }
110 }