View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *      http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  package org.apache.commons.dbcp2;
18  
19  import java.sql.SQLException;
20  
21  /**
22   * Defines the methods that will be made available via
23   * <a href="https://docs.oracle.com/javase/8/docs/technotes/guides/management/agent.html">JMX</a>.
24   *
25   * @since 2.9.0
26   */
27  public interface DataSourceMXBean {
28  
29      /**
30       * See {@link BasicDataSource#getAbandonedUsageTracking()}.
31       *
32       * @return {@link BasicDataSource#getAbandonedUsageTracking()}
33       */
34      boolean getAbandonedUsageTracking();
35  
36      /**
37       * See {@link BasicDataSource#getCacheState()}.
38       *
39       * @return {@link BasicDataSource#getCacheState()}.
40       */
41      boolean getCacheState();
42  
43      /**
44       * See {@link BasicDataSource#getConnectionInitSqlsAsArray()}.
45       *
46       * @return {@link BasicDataSource#getConnectionInitSqlsAsArray()}.
47       */
48      String[] getConnectionInitSqlsAsArray();
49  
50      /**
51       * See {@link BasicDataSource#getDefaultAutoCommit()}.
52       *
53       * @return {@link BasicDataSource#getDefaultAutoCommit()}.
54       */
55      Boolean getDefaultAutoCommit();
56  
57      /**
58       * See {@link BasicDataSource#getDefaultCatalog()}.
59       *
60       * @return {@link BasicDataSource#getDefaultCatalog()}.
61       */
62      String getDefaultCatalog();
63  
64      /**
65       * See {@link BasicDataSource#getDefaultReadOnly()}.
66       *
67       * @return {@link BasicDataSource#getDefaultReadOnly()}.
68       */
69      Boolean getDefaultReadOnly();
70  
71      /**
72       * See {@link BasicDataSource#getDefaultSchema()}.
73       *
74       * @return {@link BasicDataSource#getDefaultSchema()}.
75       * @since 2.5.0
76       */
77      default String getDefaultSchema() {
78          return null;
79      }
80  
81      /**
82       * See {@link BasicDataSource#getDefaultTransactionIsolation()}.
83       *
84       * @return {@link BasicDataSource#getDefaultTransactionIsolation()}.
85       */
86      int getDefaultTransactionIsolation();
87  
88      /**
89       * See {@link BasicDataSource#getDisconnectionSqlCodesAsArray()}.
90       *
91       * @return {@link BasicDataSource#getDisconnectionSqlCodesAsArray()}.
92       * @since 2.1
93       */
94      String[] getDisconnectionSqlCodesAsArray();
95  
96      /**
97       * See {@link BasicDataSource#getDriverClassName()}.
98       *
99       * @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      * @deprecated Use {@link #getUserName()}.
278      */
279     @Deprecated
280     String getUsername();
281 
282     /**
283      * See {@link BasicDataSource#getUsername()}.
284      *
285      * @return {@link BasicDataSource#getUsername()}.
286      * @since 2.11.0
287      */
288     default String getUserName() {
289         return getUsername();
290     }
291 
292     /**
293      * See {@link BasicDataSource#getValidationQuery()}.
294      *
295      * @return {@link BasicDataSource#getValidationQuery()}.
296      */
297     String getValidationQuery();
298 
299     /**
300      * See {@link BasicDataSource#getValidationQueryTimeout()}.
301      *
302      * @return {@link BasicDataSource#getValidationQueryTimeout()}.
303      */
304     int getValidationQueryTimeout();
305 
306     /**
307      * See {@link BasicDataSource#isAccessToUnderlyingConnectionAllowed()}.
308      *
309      * @return {@link BasicDataSource#isAccessToUnderlyingConnectionAllowed()}.
310      */
311     boolean isAccessToUnderlyingConnectionAllowed();
312 
313     /**
314      * See {@link BasicDataSource#isClearStatementPoolOnReturn()}.
315      *
316      * @return {@link BasicDataSource#isClearStatementPoolOnReturn()}.
317      * @since 2.8.0
318      */
319     default boolean isClearStatementPoolOnReturn() {
320         return false;
321     }
322 
323     /**
324      * See {@link BasicDataSource#isClosed()}.
325      *
326      * @return {@link BasicDataSource#isClosed()}.
327      */
328     boolean isClosed();
329 
330     /**
331      * See {@link BasicDataSource#isPoolPreparedStatements()}.
332      *
333      * @return {@link BasicDataSource#isPoolPreparedStatements()}.
334      */
335     boolean isPoolPreparedStatements();
336 
337     /**
338      * See {@link BasicDataSource#restart()}
339      *
340      * @throws SQLException if an error occurs initializing the data source.
341      *
342      * @since 2.8.0
343      */
344     default void restart() throws SQLException {
345         // do nothing by default?
346     }
347 
348     /**
349      * See {@link BasicDataSource#start()}
350      *
351      * @throws SQLException if an error occurs initializing the data source.
352      *
353      * @since 2.8.0
354      */
355     default void start() throws SQLException {
356         // do nothing
357     }
358 }