    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
    023 * <a href="https://docs.oracle.com/javase/8/docs/technotes/guides/management/agent.html">JMX</a>.
    024 *
    025 * @since 2.9.0
    026 */
    027public interface DataSourceMXBean {
    028
    029    /**
    030     * See {@link BasicDataSource#getAbandonedUsageTracking()}.
    031     *
    032     * @return {@link BasicDataSource#getAbandonedUsageTracking()}
    033     */
    034    boolean getAbandonedUsageTracking();
    035
    036    /**
    037     * See {@link BasicDataSource#getCacheState()}.
    038     *
    039     * @return {@link BasicDataSource#getCacheState()}.
    040     */
    041    boolean getCacheState();
    042
    043    /**
    044     * See {@link BasicDataSource#getConnectionInitSqlsAsArray()}.
    045     *
    046     * @return {@link BasicDataSource#getConnectionInitSqlsAsArray()}.
    047     */
    048    String[] getConnectionInitSqlsAsArray();
    049
    050    /**
    051     * See {@link BasicDataSource#getDefaultAutoCommit()}.
    052     *
    053     * @return {@link BasicDataSource#getDefaultAutoCommit()}.
    054     */
    055    Boolean getDefaultAutoCommit();
    056
    057    /**
    058     * See {@link BasicDataSource#getDefaultCatalog()}.
    059     *
    060     * @return {@link BasicDataSource#getDefaultCatalog()}.
    061     */
    062    String getDefaultCatalog();
    063
    064    /**
    065     * See {@link BasicDataSource#getDefaultReadOnly()}.
    066     *
    067     * @return {@link BasicDataSource#getDefaultReadOnly()}.
    068     */
    069    Boolean getDefaultReadOnly();
    070
    071    /**
    072     * See {@link BasicDataSource#getDefaultSchema()}.
    073     *
    074     * @return {@link BasicDataSource#getDefaultSchema()}.
    075     * @since 2.5.0
    076     */
    077    default String getDefaultSchema() {
    078        return null;
    079    }
    080
    081    /**
    082     * See {@link BasicDataSource#getDefaultTransactionIsolation()}.
    083     *
    084     * @return {@link BasicDataSource#getDefaultTransactionIsolation()}.
    085     */
    086    int getDefaultTransactionIsolation();
    087
    088    /**
    089     * See {@link BasicDataSource#getDisconnectionSqlCodesAsArray()}.
    090     *
    091     * @return {@link BasicDataSource#getDisconnectionSqlCodesAsArray()}.
    092     * @since 2.1
    093     */
    094    String[] getDisconnectionSqlCodesAsArray();
    095
    096    /**
    097     * See {@link BasicDataSource#getDriverClassName()}.
    098     *
    099     * @return {@link BasicDataSource#getDriverClassName()}.
    100     */
    101    String getDriverClassName();
    102
    103    /**
    104     * See {@link BasicDataSource#getFastFailValidation()}.
    105     *
    106     * @return {@link BasicDataSource#getFastFailValidation()}.
    107     * @since 2.1
    108     */
    109    boolean getFastFailValidation();
    110
    111    /**
    112     * See {@link BasicDataSource#getInitialSize()}.
    113     *
    114     * @return {@link BasicDataSource#getInitialSize()}.
    115     */
    116    int getInitialSize();
    117
    118    /**
    119     * See {@link BasicDataSource#getLifo()}.
    120     *
    121     * @return {@link BasicDataSource#getLifo()}.
    122     */
    123    boolean getLifo();
    124
    125    /**
    126     * See {@link BasicDataSource#getLogAbandoned()}.
    127     *
    128     * @return {@link BasicDataSource#getLogAbandoned()}.
    129     */
    130    boolean getLogAbandoned();
    131
    132    /**
    133     * See {@link BasicDataSource#getLogExpiredConnections()}.
    134     *
    135     * @return {@link BasicDataSource#getLogExpiredConnections()}.
    136     * @since 2.1
    137     */
    138    boolean getLogExpiredConnections();
    139
    140    /**
    141     * See {@link BasicDataSource#getMaxConnLifetimeMillis()}.
    142     *
    143     * @return {@link BasicDataSource#getMaxConnLifetimeMillis()}.
    144     */
    145    long getMaxConnLifetimeMillis();
    146
    147    /**
    148     * See {@link BasicDataSource#getMaxIdle()}.
    149     *
    150     * @return {@link BasicDataSource#getMaxIdle()}.
    151     */
    152    int getMaxIdle();
    153
    154    /**
    155     * See {@link BasicDataSource#getMaxOpenPreparedStatements()}.
    156     *
    157     * @return {@link BasicDataSource#getMaxOpenPreparedStatements()}.
    158     */
    159    int getMaxOpenPreparedStatements();
    160
    161    /**
    162     * See {@link BasicDataSource#getMaxTotal()}.
    163     *
    164     * @return {@link BasicDataSource#getMaxTotal()}.
    165     */
    166    int getMaxTotal();
    167
    168    /**
    169     * See {@link BasicDataSource#getMaxWaitMillis()}.
    170     *
    171     * @return {@link BasicDataSource#getMaxWaitMillis()}.
    172     */
    173    long getMaxWaitMillis();
    174
    175    /**
    176     * See {@link BasicDataSource#getMinEvictableIdleTimeMillis()}.
    177     *
    178     * @return {@link BasicDataSource#getMinEvictableIdleTimeMillis()}.
    179     */
    180    long getMinEvictableIdleTimeMillis();
    181
    182    /**
    183     * See {@link BasicDataSource#getMinIdle()}.
    184     *
    185     * @return {@link BasicDataSource#getMinIdle()}.
    186     */
    187    int getMinIdle();
    188
    189    /**
    190     * See {@link BasicDataSource#getNumActive()}.
    191     *
    192     * @return {@link BasicDataSource#getNumActive()}.
    193     */
    194    int getNumActive();
    195
    196    /**
    197     * See {@link BasicDataSource#getNumIdle()}.
    198     *
    199     * @return {@link BasicDataSource#getNumIdle()}.
    200     */
    201    int getNumIdle();
    202
    203    /**
    204     * See {@link BasicDataSource#getNumTestsPerEvictionRun()}.
    205     *
    206     * @return {@link BasicDataSource#getNumTestsPerEvictionRun()}.
    207     */
    208    int getNumTestsPerEvictionRun();
    209
    210    /**
    211     * See {@link BasicDataSource#getRemoveAbandonedOnBorrow()}.
    212     *
    213     * @return {@link BasicDataSource#getRemoveAbandonedOnBorrow()}.
    214     */
    215    boolean getRemoveAbandonedOnBorrow();
    216
    217    /**
    218     * See {@link BasicDataSource#getRemoveAbandonedOnMaintenance()}.
    219     *
    220     * @return {@link BasicDataSource#getRemoveAbandonedOnMaintenance()}.
    221     */
    222    boolean getRemoveAbandonedOnMaintenance();
    223
    224    /**
    225     * See {@link BasicDataSource#getRemoveAbandonedTimeout()}.
    226     *
    227     * @return {@link BasicDataSource#getRemoveAbandonedTimeout()}.
    228     */
    229    int getRemoveAbandonedTimeout();
    230
    231    /**
    232     * See {@link BasicDataSource#getSoftMinEvictableIdleTimeMillis()}.
    233     *
    234     * @return {@link BasicDataSource#getSoftMinEvictableIdleTimeMillis()}.
    235     */
    236    long getSoftMinEvictableIdleTimeMillis();
    237
    238    /**
    239     * See {@link BasicDataSource#getTestOnBorrow()}.
    240     *
    241     * @return {@link BasicDataSource#getTestOnBorrow()}.
    242     */
    243    boolean getTestOnBorrow();
    244
    245    /**
    246     * See {@link BasicDataSource#getTestOnCreate()}.
    247     *
    248     * @return {@link BasicDataSource#getTestOnCreate()}.
    249     */
    250    boolean getTestOnCreate();
    251
    252    /**
    253     * See {@link BasicDataSource#getTestWhileIdle()}.
    254     *
    255     * @return {@link BasicDataSource#getTestWhileIdle()}.
    256     */
    257    boolean getTestWhileIdle();
    258
    259    /**
    260     * See {@link BasicDataSource#getTimeBetweenEvictionRunsMillis()}.
    261     *
    262     * @return {@link BasicDataSource#getTimeBetweenEvictionRunsMillis()}.
    263     */
    264    long getTimeBetweenEvictionRunsMillis();
    265
    266    /**
    267     * See {@link BasicDataSource#getUrl()}.
    268     *
    269     * @return {@link BasicDataSource#getUrl()}.
    270     */
    271    String getUrl();
    272
    273    /**
    274     * See {@link BasicDataSource#getUsername()}.
    275     *
    276     * @return {@link BasicDataSource#getUsername()}.
    277     */
    278    String getUsername();
    279
    280    /**
    281     * See {@link BasicDataSource#getValidationQuery()}.
    282     *
    283     * @return {@link BasicDataSource#getValidationQuery()}.
    284     */
    285    String getValidationQuery();
    286
    287    /**
    288     * See {@link BasicDataSource#getValidationQueryTimeout()}.
    289     *
    290     * @return {@link BasicDataSource#getValidationQueryTimeout()}.
    291     */
    292    int getValidationQueryTimeout();
    293
    294    /**
    295     * See {@link BasicDataSource#isAccessToUnderlyingConnectionAllowed()}.
    296     *
    297     * @return {@link BasicDataSource#isAccessToUnderlyingConnectionAllowed()}.
    298     */
    299    boolean isAccessToUnderlyingConnectionAllowed();
    300
    301    /**
    302     * See {@link BasicDataSource#isClearStatementPoolOnReturn()}.
    303     *
    304     * @return {@link BasicDataSource#isClearStatementPoolOnReturn()}.
    305     * @since 2.8.0
    306     */
    307    default boolean isClearStatementPoolOnReturn() {
    308        return false;
    309    }
    310
    311    /**
    312     * See {@link BasicDataSource#isClosed()}.
    313     *
    314     * @return {@link BasicDataSource#isClosed()}.
    315     */
    316    boolean isClosed();
    317
    318    /**
    319     * See {@link BasicDataSource#isPoolPreparedStatements()}.
    320     *
    321     * @return {@link BasicDataSource#isPoolPreparedStatements()}.
    322     */
    323    boolean isPoolPreparedStatements();
    324
    325    /**
    326     * See {@link BasicDataSource#restart()}
    327     *
    328     * @throws SQLException if an error occurs initializing the data source.
    329     *
    330     * @since 2.8.0
    331     */
    332    default void restart() throws SQLException {
    333        // do nothing by default?
    334    }
    335
    336    /**
    337     * See {@link BasicDataSource#start()}
    338     *
    339     * @throws SQLException if an error occurs initializing the data source.
    340     *
    341     * @since 2.8.0
    342     */
    343    default void start() throws SQLException {
    344        // do nothing
    345    }
    346}