%line | %branch | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
org.apache.jcs.auxiliary.disk.jdbc.JDBCDiskCacheManager |
|
|
1 | package org.apache.jcs.auxiliary.disk.jdbc; |
|
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.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 | 42 | 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 | 21 | { |
49 | 21 | if ( log.isInfoEnabled() ) |
50 | { |
|
51 | 21 | log.info( "Creating JDBCDiskCacheManager with " + cattr ); |
52 | } |
|
53 | 21 | defaultJDBCDiskCacheAttributes = cattr; |
54 | 21 | } |
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 | 0 | 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 | 35 | synchronized ( JDBCDiskCacheManager.class ) |
75 | { |
|
76 | 35 | if ( instance == null ) |
77 | { |
|
78 | 21 | instance = new JDBCDiskCacheManager( cattr ); |
79 | } |
|
80 | 35 | } |
81 | 35 | clients++; |
82 | 35 | 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 | 0 | JDBCDiskCacheAttributes cattr = (JDBCDiskCacheAttributes) defaultJDBCDiskCacheAttributes.copy(); |
94 | 0 | cattr.setCacheName( cacheName ); |
95 | 0 | 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 | 35 | raf = new JDBCDiskCache( cattr, tableState ); |
108 | 35 | return raf; |
109 | } |
|
110 | } |
This report is generated by jcoverage, Maven and Maven JCoverage Plugin. |