001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.commons.dbcp2; 018 019import java.sql.SQLException; 020 021/** 022 * Defines the methods that will be made available via JMX. 023 * 024 * @since 2.0 025 */ 026public interface BasicDataSourceMXBean { 027 028 /** 029 * See {@link BasicDataSource#getAbandonedUsageTracking()} 030 * 031 * @return {@link BasicDataSource#getAbandonedUsageTracking()} 032 */ 033 boolean getAbandonedUsageTracking(); 034 035 /** 036 * See {@link BasicDataSource#getDefaultAutoCommit()} 037 * 038 * @return {@link BasicDataSource#getDefaultAutoCommit()} 039 */ 040 Boolean getDefaultAutoCommit(); 041 042 /** 043 * See {@link BasicDataSource#getDefaultReadOnly()} 044 * 045 * @return {@link BasicDataSource#getDefaultReadOnly()} 046 */ 047 Boolean getDefaultReadOnly(); 048 049 /** 050 * See {@link BasicDataSource#getDefaultTransactionIsolation()} 051 * 052 * @return {@link BasicDataSource#getDefaultTransactionIsolation()} 053 */ 054 int getDefaultTransactionIsolation(); 055 056 /** 057 * See {@link BasicDataSource#getDefaultCatalog()} 058 * 059 * @return {@link BasicDataSource#getDefaultCatalog()} 060 */ 061 String getDefaultCatalog(); 062 063 /** 064 * See {@link BasicDataSource#getDefaultSchema()} 065 * 066 * @return {@link BasicDataSource#getDefaultSchema()} 067 * @since 2.5.0 068 */ 069 default String getDefaultSchema() { 070 return null; 071 } 072 073 /** 074 * See {@link BasicDataSource#getCacheState()} 075 * 076 * @return {@link BasicDataSource#getCacheState()} 077 */ 078 boolean getCacheState(); 079 080 /** 081 * See {@link BasicDataSource#getDriverClassName()} 082 * 083 * @return {@link BasicDataSource#getDriverClassName()} 084 */ 085 String getDriverClassName(); 086 087 /** 088 * See {@link BasicDataSource#getLifo()} 089 * 090 * @return {@link BasicDataSource#getLifo()} 091 */ 092 boolean getLifo(); 093 094 /** 095 * See {@link BasicDataSource#getMaxTotal()} 096 * 097 * @return {@link BasicDataSource#getMaxTotal()} 098 */ 099 int getMaxTotal(); 100 101 /** 102 * See {@link BasicDataSource#getMaxIdle()} 103 * 104 * @return {@link BasicDataSource#getMaxIdle()} 105 */ 106 int getMaxIdle(); 107 108 /** 109 * See {@link BasicDataSource#getMinIdle()} 110 * 111 * @return {@link BasicDataSource#getMinIdle()} 112 */ 113 int getMinIdle(); 114 115 /** 116 * See {@link BasicDataSource#getInitialSize()} 117 * 118 * @return {@link BasicDataSource#getInitialSize()} 119 */ 120 int getInitialSize(); 121 122 /** 123 * See {@link BasicDataSource#getMaxWaitMillis()} 124 * 125 * @return {@link BasicDataSource#getMaxWaitMillis()} 126 */ 127 long getMaxWaitMillis(); 128 129 /** 130 * See {@link BasicDataSource#isPoolPreparedStatements()} 131 * 132 * @return {@link BasicDataSource#isPoolPreparedStatements()} 133 */ 134 boolean isPoolPreparedStatements(); 135 136 /** 137 * See {@link BasicDataSource#isClearStatementPoolOnReturn()} 138 * 139 * @return {@link BasicDataSource#isClearStatementPoolOnReturn()} 140 * @since 2.8.0 141 */ 142 default boolean isClearStatementPoolOnReturn() { 143 return false; 144 } 145 146 /** 147 * See {@link BasicDataSource#getMaxOpenPreparedStatements()} 148 * 149 * @return {@link BasicDataSource#getMaxOpenPreparedStatements()} 150 */ 151 int getMaxOpenPreparedStatements(); 152 153 /** 154 * See {@link BasicDataSource#getTestOnCreate()} 155 * 156 * @return {@link BasicDataSource#getTestOnCreate()} 157 */ 158 boolean getTestOnCreate(); 159 160 /** 161 * See {@link BasicDataSource#getTestOnBorrow()} 162 * 163 * @return {@link BasicDataSource#getTestOnBorrow()} 164 */ 165 boolean getTestOnBorrow(); 166 167 /** 168 * See {@link BasicDataSource#getTimeBetweenEvictionRunsMillis()} 169 * 170 * @return {@link BasicDataSource#getTimeBetweenEvictionRunsMillis()} 171 */ 172 long getTimeBetweenEvictionRunsMillis(); 173 174 /** 175 * See {@link BasicDataSource#getNumTestsPerEvictionRun()} 176 * 177 * @return {@link BasicDataSource#getNumTestsPerEvictionRun()} 178 */ 179 int getNumTestsPerEvictionRun(); 180 181 /** 182 * See {@link BasicDataSource#getMinEvictableIdleTimeMillis()} 183 * 184 * @return {@link BasicDataSource#getMinEvictableIdleTimeMillis()} 185 */ 186 long getMinEvictableIdleTimeMillis(); 187 188 /** 189 * See {@link BasicDataSource#getSoftMinEvictableIdleTimeMillis()} 190 * 191 * @return {@link BasicDataSource#getSoftMinEvictableIdleTimeMillis()} 192 */ 193 long getSoftMinEvictableIdleTimeMillis(); 194 195 /** 196 * See {@link BasicDataSource#getTestWhileIdle()} 197 * 198 * @return {@link BasicDataSource#getTestWhileIdle()} 199 */ 200 boolean getTestWhileIdle(); 201 202 /** 203 * See {@link BasicDataSource#getNumActive()} 204 * 205 * @return {@link BasicDataSource#getNumActive()} 206 */ 207 int getNumActive(); 208 209 /** 210 * See {@link BasicDataSource#getNumIdle()} 211 * 212 * @return {@link BasicDataSource#getNumIdle()} 213 */ 214 int getNumIdle(); 215 216 /** 217 * See {@link BasicDataSource#getPassword()} 218 * 219 * @return {@link BasicDataSource#getPassword()} 220 */ 221 String getPassword(); 222 223 /** 224 * See {@link BasicDataSource#getUrl()} 225 * 226 * @return {@link BasicDataSource#getUrl()} 227 */ 228 String getUrl(); 229 230 /** 231 * See {@link BasicDataSource#getUsername()} 232 * 233 * @return {@link BasicDataSource#getUsername()} 234 */ 235 String getUsername(); 236 237 /** 238 * See {@link BasicDataSource#getValidationQuery()} 239 * 240 * @return {@link BasicDataSource#getValidationQuery()} 241 */ 242 String getValidationQuery(); 243 244 /** 245 * See {@link BasicDataSource#getValidationQueryTimeout()} 246 * 247 * @return {@link BasicDataSource#getValidationQueryTimeout()} 248 */ 249 int getValidationQueryTimeout(); 250 251 /** 252 * See {@link BasicDataSource#getConnectionInitSqlsAsArray()} 253 * 254 * @return {@link BasicDataSource#getConnectionInitSqlsAsArray()} 255 */ 256 String[] getConnectionInitSqlsAsArray(); 257 258 /** 259 * See {@link BasicDataSource#isAccessToUnderlyingConnectionAllowed()} 260 * 261 * @return {@link BasicDataSource#isAccessToUnderlyingConnectionAllowed()} 262 */ 263 boolean isAccessToUnderlyingConnectionAllowed(); 264 265 /** 266 * See {@link BasicDataSource#getMaxConnLifetimeMillis()} 267 * 268 * @return {@link BasicDataSource#getMaxConnLifetimeMillis()} 269 */ 270 long getMaxConnLifetimeMillis(); 271 272 /** 273 * See {@link BasicDataSource#getLogExpiredConnections()} 274 * 275 * @return {@link BasicDataSource#getLogExpiredConnections()} 276 * @since 2.1 277 */ 278 boolean getLogExpiredConnections(); 279 280 /** 281 * See {@link BasicDataSource#getRemoveAbandonedOnBorrow()} 282 * 283 * @return {@link BasicDataSource#getRemoveAbandonedOnBorrow()} 284 */ 285 boolean getRemoveAbandonedOnBorrow(); 286 287 /** 288 * See {@link BasicDataSource#getRemoveAbandonedOnMaintenance()} 289 * 290 * @return {@link BasicDataSource#getRemoveAbandonedOnMaintenance()} 291 */ 292 boolean getRemoveAbandonedOnMaintenance(); 293 294 /** 295 * See {@link BasicDataSource#getRemoveAbandonedTimeout()} 296 * 297 * @return {@link BasicDataSource#getRemoveAbandonedTimeout()} 298 */ 299 int getRemoveAbandonedTimeout(); 300 301 /** 302 * See {@link BasicDataSource#getLogAbandoned()} 303 * 304 * @return {@link BasicDataSource#getLogAbandoned()} 305 */ 306 boolean getLogAbandoned(); 307 308 /** 309 * See {@link BasicDataSource#isClosed()} 310 * 311 * @return {@link BasicDataSource#isClosed()} 312 */ 313 boolean isClosed(); 314 315 /** 316 * See {@link BasicDataSource#getFastFailValidation()} 317 * 318 * @return {@link BasicDataSource#getFastFailValidation()} 319 * @since 2.1 320 */ 321 boolean getFastFailValidation(); 322 323 /** 324 * See {@link BasicDataSource#getDisconnectionSqlCodesAsArray()} 325 * 326 * @return {@link BasicDataSource#getDisconnectionSqlCodesAsArray()} 327 * @since 2.1 328 */ 329 String[] getDisconnectionSqlCodesAsArray(); 330 331 /** 332 * See {@link BasicDataSource#start()} 333 * 334 * @throws SQLException if an error occurs initializing the datasource 335 * 336 * @since 2.8.0 337 */ 338 default void start() throws SQLException { 339 // do nothing 340 } 341 342 /** 343 * See {@link BasicDataSource#restart()} 344 * 345 * @throws SQLException if an error occurs initializing the datasource 346 * 347 * @since 2.8.0 348 */ 349 default void restart() throws SQLException { 350 // do nothing by default? 351 } 352}