| %line | %branch | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| org.apache.jcs.auxiliary.disk.jdbc.JDBCDiskCacheAttributes |
|
|
| 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.jcs.auxiliary.disk.AbstractDiskCacheAttributes; |
|
| 23 | ||
| 24 | /** |
|
| 25 | * The configurator will set these values based on what is in the cache.ccf |
|
| 26 | * file. |
|
| 27 | * <p> |
|
| 28 | * @author Aaron Smuts |
|
| 29 | */ |
|
| 30 | 35 | public class JDBCDiskCacheAttributes |
| 31 | extends AbstractDiskCacheAttributes |
|
| 32 | { |
|
| 33 | private static final long serialVersionUID = -6535808344813320062L; |
|
| 34 | ||
| 35 | private static final String DEFAULT_TABLE_NAME = "JCS_STORE"; |
|
| 36 | ||
| 37 | private String userName; |
|
| 38 | ||
| 39 | private String password; |
|
| 40 | ||
| 41 | private String url; |
|
| 42 | ||
| 43 | 35 | private String database = ""; |
| 44 | ||
| 45 | private String driverClassName; |
|
| 46 | ||
| 47 | 35 | private String tableName = DEFAULT_TABLE_NAME; |
| 48 | ||
| 49 | 35 | private boolean testBeforeInsert = true; |
| 50 | ||
| 51 | /** This is the default limit on the maximum number of active connections. */ |
|
| 52 | public static final int DEFAULT_MAX_ACTIVE = 10; |
|
| 53 | ||
| 54 | 35 | private int maxActive = DEFAULT_MAX_ACTIVE; |
| 55 | ||
| 56 | /** This is the default setting for the cleanup routine. */ |
|
| 57 | public static final int DEFAULT_SHRINKER_INTERVAL_SECONDS = 300; |
|
| 58 | ||
| 59 | 35 | private int shrinkerIntervalSeconds = DEFAULT_SHRINKER_INTERVAL_SECONDS; |
| 60 | ||
| 61 | 35 | private boolean UseDiskShrinker = true; |
| 62 | ||
| 63 | /** |
|
| 64 | * @param userName |
|
| 65 | * The userName to set. |
|
| 66 | */ |
|
| 67 | public void setUserName( String userName ) |
|
| 68 | { |
|
| 69 | 42 | this.userName = userName; |
| 70 | 42 | } |
| 71 | ||
| 72 | /** |
|
| 73 | * @return Returns the userName. |
|
| 74 | */ |
|
| 75 | public String getUserName() |
|
| 76 | { |
|
| 77 | 133 | return userName; |
| 78 | } |
|
| 79 | ||
| 80 | /** |
|
| 81 | * @param password |
|
| 82 | * The password to set. |
|
| 83 | */ |
|
| 84 | public void setPassword( String password ) |
|
| 85 | { |
|
| 86 | 42 | this.password = password; |
| 87 | 42 | } |
| 88 | ||
| 89 | /** |
|
| 90 | * @return Returns the password. |
|
| 91 | */ |
|
| 92 | public String getPassword() |
|
| 93 | { |
|
| 94 | 56 | return password; |
| 95 | } |
|
| 96 | ||
| 97 | /** |
|
| 98 | * @param url |
|
| 99 | * The url to set. |
|
| 100 | */ |
|
| 101 | public void setUrl( String url ) |
|
| 102 | { |
|
| 103 | 42 | this.url = url; |
| 104 | 42 | } |
| 105 | ||
| 106 | /** |
|
| 107 | * @return Returns the url. |
|
| 108 | */ |
|
| 109 | public String getUrl() |
|
| 110 | { |
|
| 111 | 245 | return url; |
| 112 | } |
|
| 113 | ||
| 114 | /** |
|
| 115 | * This is appended to the url. |
|
| 116 | * @param database |
|
| 117 | * The database to set. |
|
| 118 | */ |
|
| 119 | public void setDatabase( String database ) |
|
| 120 | { |
|
| 121 | 0 | this.database = database; |
| 122 | 0 | } |
| 123 | ||
| 124 | /** |
|
| 125 | * @return Returns the database. |
|
| 126 | */ |
|
| 127 | public String getDatabase() |
|
| 128 | { |
|
| 129 | 133 | return database; |
| 130 | } |
|
| 131 | ||
| 132 | /** |
|
| 133 | * @param driverClassName |
|
| 134 | * The driverClassName to set. |
|
| 135 | */ |
|
| 136 | public void setDriverClassName( String driverClassName ) |
|
| 137 | { |
|
| 138 | 49 | this.driverClassName = driverClassName; |
| 139 | 49 | } |
| 140 | ||
| 141 | /** |
|
| 142 | * @return Returns the driverClassName. |
|
| 143 | */ |
|
| 144 | public String getDriverClassName() |
|
| 145 | { |
|
| 146 | 133 | return driverClassName; |
| 147 | } |
|
| 148 | ||
| 149 | /** |
|
| 150 | * @param tableName |
|
| 151 | * The tableName to set. |
|
| 152 | */ |
|
| 153 | public void setTableName( String tableName ) |
|
| 154 | { |
|
| 155 | 49 | this.tableName = tableName; |
| 156 | 49 | } |
| 157 | ||
| 158 | /** |
|
| 159 | * @return Returns the tableName. |
|
| 160 | */ |
|
| 161 | public String getTableName() |
|
| 162 | { |
|
| 163 | 23956 | return tableName; |
| 164 | } |
|
| 165 | ||
| 166 | /** |
|
| 167 | * If this is true then the disk cache will check to see if the item already |
|
| 168 | * exists in the database. If it is false, it will try to insert. If the |
|
| 169 | * isnert fails it will try to update. |
|
| 170 | * @param testBeforeInsert |
|
| 171 | * The testBeforeInsert to set. |
|
| 172 | */ |
|
| 173 | public void setTestBeforeInsert( boolean testBeforeInsert ) |
|
| 174 | { |
|
| 175 | 42 | this.testBeforeInsert = testBeforeInsert; |
| 176 | 42 | } |
| 177 | ||
| 178 | /** |
|
| 179 | * @return Returns the testBeforeInsert. |
|
| 180 | */ |
|
| 181 | public boolean isTestBeforeInsert() |
|
| 182 | { |
|
| 183 | 7153 | return testBeforeInsert; |
| 184 | } |
|
| 185 | ||
| 186 | /** |
|
| 187 | * @param maxActive |
|
| 188 | * The maxActive to set. |
|
| 189 | */ |
|
| 190 | public void setMaxActive( int maxActive ) |
|
| 191 | { |
|
| 192 | 42 | this.maxActive = maxActive; |
| 193 | 42 | } |
| 194 | ||
| 195 | /** |
|
| 196 | * @return Returns the maxActive. |
|
| 197 | */ |
|
| 198 | public int getMaxActive() |
|
| 199 | { |
|
| 200 | 133 | return maxActive; |
| 201 | } |
|
| 202 | ||
| 203 | /** |
|
| 204 | * @param shrinkerIntervalSecondsArg |
|
| 205 | * The shrinkerIntervalSeconds to set. |
|
| 206 | */ |
|
| 207 | public void setShrinkerIntervalSeconds( int shrinkerIntervalSecondsArg ) |
|
| 208 | { |
|
| 209 | 21 | this.shrinkerIntervalSeconds = shrinkerIntervalSecondsArg; |
| 210 | 21 | } |
| 211 | ||
| 212 | /** |
|
| 213 | * @return Returns the shrinkerIntervalSeconds. |
|
| 214 | */ |
|
| 215 | public int getShrinkerIntervalSeconds() |
|
| 216 | { |
|
| 217 | 105 | return shrinkerIntervalSeconds; |
| 218 | } |
|
| 219 | ||
| 220 | /** |
|
| 221 | * @param useDiskShrinker |
|
| 222 | * The useDiskShrinker to set. |
|
| 223 | */ |
|
| 224 | public void setUseDiskShrinker( boolean useDiskShrinker ) |
|
| 225 | { |
|
| 226 | 21 | UseDiskShrinker = useDiskShrinker; |
| 227 | 21 | } |
| 228 | ||
| 229 | /** |
|
| 230 | * @return Returns the useDiskShrinker. |
|
| 231 | */ |
|
| 232 | public boolean isUseDiskShrinker() |
|
| 233 | { |
|
| 234 | 119 | return UseDiskShrinker; |
| 235 | } |
|
| 236 | ||
| 237 | /** |
|
| 238 | * For debugging. |
|
| 239 | */ |
|
| 240 | public String toString() |
|
| 241 | { |
|
| 242 | 77 | StringBuffer buf = new StringBuffer(); |
| 243 | 77 | buf.append( "\nJDBCCacheAttributes" ); |
| 244 | 77 | buf.append( "\n UserName [" + getUserName() + "]" ); |
| 245 | 77 | buf.append( "\n Url [" + getUrl() + "]" ); |
| 246 | 77 | buf.append( "\n Database [" + getDatabase() + "]" ); |
| 247 | 77 | buf.append( "\n DriverClassName [" + getDriverClassName() + "]" ); |
| 248 | 77 | buf.append( "\n TableName [" + getTableName() + "]" ); |
| 249 | 77 | buf.append( "\n TestBeforeInsert [" + isTestBeforeInsert() + "]" ); |
| 250 | 77 | buf.append( "\n MaxActive [" + getMaxActive() + "]" ); |
| 251 | 77 | buf.append( "\n AllowRemoveAll [" + isAllowRemoveAll() + "]" ); |
| 252 | 77 | buf.append( "\n ShrinkerIntervalSeconds [" + getShrinkerIntervalSeconds() + "]" ); |
| 253 | 77 | buf.append( "\n UseDiskShrinker [" + isUseDiskShrinker() + "]" ); |
| 254 | 77 | return buf.toString(); |
| 255 | } |
|
| 256 | } |
| This report is generated by jcoverage, Maven and Maven JCoverage Plugin. |