[SDNC-5] Rebase sdnc-core
[sdnc/core.git] / dblib / common / src / main / java / org / apache / tomcat / jdbc / pool / DataSourceProxy.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * openecomp
4  * ================================================================================
5  * Copyright (C) 2016 - 2017 AT&T
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 /*
22  * Licensed to the Apache Software Foundation (ASF) under one or more
23  * contributor license agreements.  See the NOTICE file distributed with
24  * this work for additional information regarding copyright ownership.
25  * The ASF licenses this file to You under the Apache License, Version 2.0
26  * (the "License"); you may not use this file except in compliance with
27  * the License.  You may obtain a copy of the License at
28  *
29  *      http://www.apache.org/licenses/LICENSE-2.0
30  *
31  * Unless required by applicable law or agreed to in writing, software
32  * distributed under the License is distributed on an "AS IS" BASIS,
33  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
34  * See the License for the specific language governing permissions and
35  * limitations under the License.
36  */
37 package org.apache.tomcat.jdbc.pool;
38
39 import java.io.PrintWriter;
40 import java.sql.Connection;
41 import java.sql.SQLException;
42 import java.sql.SQLFeatureNotSupportedException;
43 import java.util.Iterator;
44 import java.util.Properties;
45 import java.util.concurrent.Future;
46 import java.util.logging.Logger;
47
48 import javax.sql.XAConnection;
49
50 import org.apache.juli.logging.Log;
51 import org.apache.juli.logging.LogFactory;
52 import org.apache.tomcat.jdbc.pool.PoolProperties.InterceptorDefinition;
53
54 /**
55  *
56  * The DataSource proxy lets us implements methods that don't exist in the current
57  * compiler JDK but might be methods that are part of a future JDK DataSource interface.
58  * <br>
59  * It's a trick to work around compiler issues when implementing interfaces. For example,
60  * I could put in Java 6 methods of javax.sql.DataSource here, and compile it with JDK 1.5
61  * and still be able to run under Java 6 without getting NoSuchMethodException.
62  *
63  * @version 1.0
64  */
65
66 public class DataSourceProxy implements PoolConfiguration {
67     private static final Log log = LogFactory.getLog(DataSourceProxy.class);
68
69     protected volatile ConnectionPool pool = null;
70
71     protected volatile PoolConfiguration poolProperties = null;
72
73     public DataSourceProxy() {
74         this(new PoolProperties());
75     }
76
77     public DataSourceProxy(PoolConfiguration poolProperties) {
78         if (poolProperties == null) throw new NullPointerException("PoolConfiguration cannot be null.");
79         this.poolProperties = poolProperties;
80     }
81
82
83     @SuppressWarnings("unused") // Has to match signature in DataSource
84     public boolean isWrapperFor(Class<?> iface) throws SQLException {
85         // we are not a wrapper of anything
86         return false;
87     }
88
89
90     @SuppressWarnings("unused") // Has to match signature in DataSource
91     public <T> T unwrap(Class<T> iface) throws SQLException {
92         //we can't unwrap anything
93         return null;
94     }
95
96     /**
97      * Get a database connection.
98      * {@link javax.sql.DataSource#getConnection()}
99      * @param username The user name
100      * @param password The password
101      * @return the connection
102      * @throws SQLException Connection error
103      */
104     public Connection getConnection(String username, String password) throws SQLException {
105         if (this.getPoolProperties().isAlternateUsernameAllowed()) {
106             if (pool == null)
107                 return createPool().getConnection(username,password);
108             return pool.getConnection(username,password);
109         } else {
110             return getConnection();
111         }
112     }
113
114     public PoolConfiguration getPoolProperties() {
115         return poolProperties;
116     }
117
118     /**
119      * Sets up the connection pool, by creating a pooling driver.
120      * @return the connection pool
121      * @throws SQLException Error creating pool
122      */
123     public ConnectionPool createPool() throws SQLException {
124         if (pool != null) {
125             return pool;
126         } else {
127             return pCreatePool();
128         }
129     }
130
131     /**
132      * Sets up the connection pool, by creating a pooling driver.
133      */
134     private synchronized ConnectionPool pCreatePool() throws SQLException {
135         if (pool != null) {
136             return pool;
137         } else {
138             pool = new ConnectionPool(poolProperties);
139             return pool;
140         }
141     }
142
143     /**
144      * Get a database connection.
145      * {@link javax.sql.DataSource#getConnection()}
146      * @return the connection
147      * @throws SQLException Connection error
148      */
149     public Connection getConnection() throws SQLException {
150         if (pool == null)
151             return createPool().getConnection();
152         return pool.getConnection();
153     }
154
155     /**
156      * Invokes an sync operation to retrieve the connection.
157      * @return a Future containing a reference to the connection when it becomes available
158      * @throws SQLException Connection error
159      */
160     public Future<Connection> getConnectionAsync() throws SQLException {
161         if (pool == null)
162             return createPool().getConnectionAsync();
163         return pool.getConnectionAsync();
164     }
165
166     /**
167      * Get a database connection.
168      * {@link javax.sql.XADataSource#getXAConnection()}
169      * @return the connection
170      * @throws SQLException Connection error
171      */
172     public XAConnection getXAConnection() throws SQLException {
173         Connection con = getConnection();
174         if (con instanceof XAConnection) {
175             return (XAConnection)con;
176         } else {
177             try {
178                 con.close();
179             } catch (Exception ignore) {
180                 // Ignore
181             }
182             throw new SQLException("Connection from pool does not implement javax.sql.XAConnection");
183         }
184     }
185
186     /**
187      * Get a database connection.
188      * {@link javax.sql.XADataSource#getXAConnection(String, String)}
189      * @param username The user name
190      * @param password The password
191      * @return the connection
192      * @throws SQLException Connection error
193      */
194     public XAConnection getXAConnection(String username, String password) throws SQLException {
195         Connection con = getConnection(username, password);
196         if (con instanceof XAConnection) {
197             return (XAConnection)con;
198         } else {
199             try {
200                 con.close();
201             } catch (Exception ignore) {
202                 // Ignore
203             }
204             throw new SQLException("Connection from pool does not implement javax.sql.XAConnection");
205         }
206     }
207
208
209     /**
210      * Get a database connection.
211      * {@link javax.sql.DataSource#getConnection()}
212      * @return the connection
213      * @throws SQLException Connection error
214      */
215     public javax.sql.PooledConnection getPooledConnection() throws SQLException {
216         return (javax.sql.PooledConnection) getConnection();
217     }
218
219     /**
220      * Get a database connection.
221      * {@link javax.sql.DataSource#getConnection()}
222      * @param username unused
223      * @param password unused
224      * @return the connection
225      * @throws SQLException Connection error
226      */
227     public javax.sql.PooledConnection getPooledConnection(String username,
228             String password) throws SQLException {
229         return (javax.sql.PooledConnection) getConnection();
230     }
231
232     public ConnectionPool getPool() {
233         try {
234             return createPool();
235         }catch (SQLException x) {
236             log.error("Error during connection pool creation.", x);
237             return null;
238         }
239     }
240
241
242     public void close() {
243         close(false);
244     }
245     public void close(boolean all) {
246         try {
247             if (pool != null) {
248                 final ConnectionPool p = pool;
249                 pool = null;
250                 if (p!=null) {
251                     p.close(all);
252                 }
253             }
254         }catch (Exception x) {
255             log.warn("Error during connection pool closure.", x);
256         }
257     }
258
259     public int getPoolSize() {
260         final ConnectionPool p = pool;
261         if (p == null) return 0;
262         else return p.getSize();
263     }
264
265
266     @Override
267     public String toString() {
268         return super.toString()+"{"+getPoolProperties()+"}";
269     }
270
271
272 /*-----------------------------------------------------------------------*/
273 //      PROPERTIES WHEN NOT USED WITH FACTORY
274 /*------------------------------------------------------------------------*/
275
276     /**
277      * {@inheritDoc}
278      */
279
280     @Override
281     public String getPoolName() {
282         return pool.getName();
283     }
284
285
286     public void setPoolProperties(PoolConfiguration poolProperties) {
287         this.poolProperties = poolProperties;
288     }
289
290     /**
291      * {@inheritDoc}
292      */
293
294     @Override
295     public void setDriverClassName(String driverClassName) {
296         this.poolProperties.setDriverClassName(driverClassName);
297     }
298
299     /**
300      * {@inheritDoc}
301      */
302
303     @Override
304     public void setInitialSize(int initialSize) {
305         this.poolProperties.setInitialSize(initialSize);
306     }
307
308     /**
309      * {@inheritDoc}
310      */
311
312     @Override
313     public void setInitSQL(String initSQL) {
314         this.poolProperties.setInitSQL(initSQL);
315     }
316
317     /**
318      * {@inheritDoc}
319      */
320
321     @Override
322     public void setLogAbandoned(boolean logAbandoned) {
323         this.poolProperties.setLogAbandoned(logAbandoned);
324     }
325
326     /**
327      * {@inheritDoc}
328      */
329
330     @Override
331     public void setMaxActive(int maxActive) {
332         this.poolProperties.setMaxActive(maxActive);
333     }
334
335     /**
336      * {@inheritDoc}
337      */
338
339     @Override
340     public void setMaxIdle(int maxIdle) {
341         this.poolProperties.setMaxIdle(maxIdle);
342     }
343
344     /**
345      * {@inheritDoc}
346      */
347
348     @Override
349     public void setMaxWait(int maxWait) {
350         this.poolProperties.setMaxWait(maxWait);
351     }
352
353     /**
354      * {@inheritDoc}
355      */
356
357     @Override
358     public void setMinEvictableIdleTimeMillis(int minEvictableIdleTimeMillis) {
359         this.poolProperties.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis);
360     }
361
362     /**
363      * {@inheritDoc}
364      */
365
366     @Override
367     public void setMinIdle(int minIdle) {
368         this.poolProperties.setMinIdle(minIdle);
369     }
370
371     /**
372      * {@inheritDoc}
373      */
374
375     @Override
376     public void setNumTestsPerEvictionRun(int numTestsPerEvictionRun) {
377         this.poolProperties.setNumTestsPerEvictionRun(numTestsPerEvictionRun);
378     }
379
380     /**
381      * {@inheritDoc}
382      */
383
384     @Override
385     public void setPassword(String password) {
386         this.poolProperties.setPassword(password);
387         this.poolProperties.getDbProperties().setProperty("password",this.poolProperties.getPassword());
388     }
389
390     /**
391      * {@inheritDoc}
392      */
393
394     @Override
395     public void setRemoveAbandoned(boolean removeAbandoned) {
396         this.poolProperties.setRemoveAbandoned(removeAbandoned);
397     }
398
399     /**
400      * {@inheritDoc}
401      */
402
403     @Override
404     public void setRemoveAbandonedTimeout(int removeAbandonedTimeout) {
405         this.poolProperties.setRemoveAbandonedTimeout(removeAbandonedTimeout);
406     }
407
408     /**
409      * {@inheritDoc}
410      */
411
412     @Override
413     public void setTestOnBorrow(boolean testOnBorrow) {
414         this.poolProperties.setTestOnBorrow(testOnBorrow);
415     }
416
417     /**
418      * {@inheritDoc}
419      */
420
421     @Override
422     public void setTestOnConnect(boolean testOnConnect) {
423         this.poolProperties.setTestOnConnect(testOnConnect);
424     }
425
426     /**
427      * {@inheritDoc}
428      */
429
430     @Override
431     public void setTestOnReturn(boolean testOnReturn) {
432         this.poolProperties.setTestOnReturn(testOnReturn);
433     }
434
435     /**
436      * {@inheritDoc}
437      */
438
439     @Override
440     public void setTestWhileIdle(boolean testWhileIdle) {
441         this.poolProperties.setTestWhileIdle(testWhileIdle);
442     }
443
444     /**
445      * {@inheritDoc}
446      */
447
448     @Override
449     public void setTimeBetweenEvictionRunsMillis(int timeBetweenEvictionRunsMillis) {
450         this.poolProperties.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis);
451     }
452
453     /**
454      * {@inheritDoc}
455      */
456
457     @Override
458     public void setUrl(String url) {
459         this.poolProperties.setUrl(url);
460     }
461
462     /**
463      * {@inheritDoc}
464      */
465
466     @Override
467     public void setUsername(String username) {
468         this.poolProperties.setUsername(username);
469         this.poolProperties.getDbProperties().setProperty("user",getPoolProperties().getUsername());
470     }
471
472     /**
473      * {@inheritDoc}
474      */
475
476     @Override
477     public void setValidationInterval(long validationInterval) {
478         this.poolProperties.setValidationInterval(validationInterval);
479     }
480
481     /**
482      * {@inheritDoc}
483      */
484
485     @Override
486     public void setValidationQuery(String validationQuery) {
487         this.poolProperties.setValidationQuery(validationQuery);
488     }
489
490     /**
491      * {@inheritDoc}
492      */
493
494     @Override
495     public void setValidatorClassName(String className) {
496         this.poolProperties.setValidatorClassName(className);
497     }
498
499     /**
500      * {@inheritDoc}
501      */
502
503     @Override
504     public void setValidationQueryTimeout(int validationQueryTimeout) {
505         this.poolProperties.setValidationQueryTimeout(validationQueryTimeout);
506     }
507
508     /**
509      * {@inheritDoc}
510      */
511
512     @Override
513     public void setJdbcInterceptors(String interceptors) {
514         this.getPoolProperties().setJdbcInterceptors(interceptors);
515     }
516
517     /**
518      * {@inheritDoc}
519      */
520
521     @Override
522     public void setJmxEnabled(boolean enabled) {
523         this.getPoolProperties().setJmxEnabled(enabled);
524     }
525
526     /**
527      * {@inheritDoc}
528      */
529
530     @Override
531     public void setFairQueue(boolean fairQueue) {
532         this.getPoolProperties().setFairQueue(fairQueue);
533     }
534
535     /**
536      * {@inheritDoc}
537      */
538
539     @Override
540     public void setUseLock(boolean useLock) {
541         this.getPoolProperties().setUseLock(useLock);
542     }
543
544     /**
545      * {@inheritDoc}
546      */
547
548     @Override
549     public void setDefaultCatalog(String catalog) {
550         this.getPoolProperties().setDefaultCatalog(catalog);
551     }
552
553     /**
554      * {@inheritDoc}
555      */
556
557     @Override
558     public void setDefaultAutoCommit(Boolean autocommit) {
559         this.getPoolProperties().setDefaultAutoCommit(autocommit);
560     }
561
562     /**
563      * {@inheritDoc}
564      */
565
566     @Override
567     public void setDefaultTransactionIsolation(int defaultTransactionIsolation) {
568         this.getPoolProperties().setDefaultTransactionIsolation(defaultTransactionIsolation);
569     }
570
571     /**
572      * {@inheritDoc}
573      */
574
575     @Override
576     public void setConnectionProperties(String properties) {
577         try {
578             java.util.Properties prop = DataSourceFactory
579                     .getProperties(properties);
580             Iterator<?> i = prop.keySet().iterator();
581             while (i.hasNext()) {
582                 String key = (String) i.next();
583                 String value = prop.getProperty(key);
584                 getPoolProperties().getDbProperties().setProperty(key, value);
585             }
586
587         } catch (Exception x) {
588             log.error("Unable to parse connection properties.", x);
589             throw new RuntimeException(x);
590         }
591     }
592
593     /**
594      * {@inheritDoc}
595      */
596
597     @Override
598     public void setUseEquals(boolean useEquals) {
599         this.getPoolProperties().setUseEquals(useEquals);
600     }
601
602     /**
603      * no-op
604      * {@link javax.sql.DataSource#getParentLogger}
605      * @return no return value
606      * @throws SQLFeatureNotSupportedException Unsupported
607      */
608     public Logger getParentLogger() throws SQLFeatureNotSupportedException {
609         throw new SQLFeatureNotSupportedException();
610     }
611
612     /**
613      * no-op
614      * {@link javax.sql.DataSource#getLogWriter}
615      * @return null
616      * @throws SQLException No exception
617      */
618     public PrintWriter getLogWriter() throws SQLException {
619         return null;
620     }
621
622
623     /**
624      * no-op
625      * {@link javax.sql.DataSource#setLogWriter(PrintWriter)}
626      * @param out Ignored
627      * @throws SQLException No exception
628      */
629     public void setLogWriter(PrintWriter out) throws SQLException {
630         // NOOP
631     }
632
633     /**
634      * no-op
635      * {@link javax.sql.DataSource#getLoginTimeout}
636      * @return the timeout
637      */
638     public int getLoginTimeout() {
639         if (poolProperties == null) {
640             return 0;
641         } else {
642             return poolProperties.getMaxWait() / 1000;
643         }
644     }
645
646     /**
647      * {@link javax.sql.DataSource#setLoginTimeout(int)}
648      * @param i The timeout value
649      */
650     public void setLoginTimeout(int i) {
651         if (poolProperties == null) {
652             return;
653         } else {
654             poolProperties.setMaxWait(1000 * i);
655         }
656
657     }
658
659
660     /**
661      * {@inheritDoc}
662      */
663
664     @Override
665     public int getSuspectTimeout() {
666         return getPoolProperties().getSuspectTimeout();
667     }
668
669     /**
670      * {@inheritDoc}
671      */
672
673     @Override
674     public void setSuspectTimeout(int seconds) {
675         getPoolProperties().setSuspectTimeout(seconds);
676     }
677
678   //===============================================================================
679 //  Expose JMX attributes through Tomcat's dynamic reflection
680 //===============================================================================
681     /**
682      * If the pool has not been created, it will be created during this call.
683      * @return the number of established but idle connections
684      */
685     public int getIdle() {
686         try {
687             return createPool().getIdle();
688         }catch (SQLException x) {
689             throw new RuntimeException(x);
690         }
691     }
692
693     /**
694      * {@link #getIdle()}
695      * @return the number of established but idle connections
696      */
697     public int getNumIdle() {
698         return getIdle();
699     }
700
701     /**
702      * Forces an abandon check on the connection pool.
703      * If connections that have been abandoned exists, they will be closed during this run
704      */
705     public void checkAbandoned() {
706         try {
707             createPool().checkAbandoned();
708         }catch (SQLException x) {
709             throw new RuntimeException(x);
710         }
711     }
712
713     /**
714      * Forces a check for resizing of the idle connections
715      */
716     public void checkIdle() {
717         try {
718             createPool().checkIdle();
719         }catch (SQLException x) {
720             throw new RuntimeException(x);
721         }
722     }
723
724     /**
725      * @return number of connections in use by the application
726      */
727     public int getActive() {
728         try {
729             return createPool().getActive();
730         }catch (SQLException x) {
731             throw new RuntimeException(x);
732         }
733     }
734
735     /**
736      * @return number of connections in use by the application
737      * {@link DataSource#getActive()}
738      */
739     public int getNumActive() {
740         return getActive();
741     }
742
743     /**
744      * @return number of threads waiting for a connection
745      */
746     public int getWaitCount() {
747         try {
748             return createPool().getWaitCount();
749         }catch (SQLException x) {
750             throw new RuntimeException(x);
751         }
752     }
753
754     /**
755      * @return the current size of the pool
756      */
757     public int getSize() {
758         try {
759             return createPool().getSize();
760         }catch (SQLException x) {
761             throw new RuntimeException(x);
762         }
763     }
764
765     /**
766      * Performs a validation on idle connections
767      */
768     public void testIdle() {
769         try {
770             createPool().testAllIdle();
771         }catch (SQLException x) {
772             throw new RuntimeException(x);
773         }
774     }
775
776     /**
777      * The total number of connections borrowed from this pool.
778      * @return the borrowed connection count
779      */
780     public long getBorrowedCount() {
781         try {
782             return createPool().getBorrowedCount();
783         } catch (SQLException x) {
784             throw new RuntimeException(x);
785         }
786     }
787
788     /**
789      * The total number of connections returned to this pool.
790      * @return the returned connection count
791      */
792     public long getReturnedCount() {
793         try {
794             return createPool().getReturnedCount();
795         } catch (SQLException x) {
796             throw new RuntimeException(x);
797         }
798     }
799
800     /**
801      * The total number of connections created by this pool.
802      * @return the created connection count
803      */
804     public long getCreatedCount() {
805         try {
806             return createPool().getCreatedCount();
807         } catch (SQLException x) {
808             throw new RuntimeException(x);
809         }
810     }
811
812     /**
813      * The total number of connections released from this pool.
814      * @return the released connection count
815      */
816     public long getReleasedCount() {
817         try {
818             return createPool().getReleasedCount();
819         } catch (SQLException x) {
820             throw new RuntimeException(x);
821         }
822     }
823
824     /**
825      * The total number of connections reconnected by this pool.
826      * @return the reconnected connection count
827      */
828     public long getReconnectedCount() {
829         try {
830             return createPool().getReconnectedCount();
831         } catch (SQLException x) {
832             throw new RuntimeException(x);
833         }
834     }
835
836     /**
837      * The total number of connections released by remove abandoned.
838      * @return the PoolCleaner removed abandoned connection count
839      */
840     public long getRemoveAbandonedCount() {
841         try {
842             return createPool().getRemoveAbandonedCount();
843         } catch (SQLException x) {
844             throw new RuntimeException(x);
845         }
846     }
847
848     /**
849      * The total number of connections released by eviction.
850      * @return the PoolCleaner evicted idle connection count
851      */
852     public long getReleasedIdleCount() {
853         try {
854             return createPool().getReleasedIdleCount();
855         } catch (SQLException x) {
856             throw new RuntimeException(x);
857         }
858     }
859
860     /**
861      * reset the statistics of this pool.
862      */
863     public void resetStats() {
864         try {
865             createPool().resetStats();
866         } catch (SQLException x) {
867             throw new RuntimeException(x);
868         }
869     }
870
871     //=========================================================
872     //  PROPERTIES / CONFIGURATION
873     //=========================================================
874
875     /**
876      * {@inheritDoc}
877      */
878
879     @Override
880     public String getConnectionProperties() {
881         return getPoolProperties().getConnectionProperties();
882     }
883
884     /**
885      * {@inheritDoc}
886      */
887
888     @Override
889     public Properties getDbProperties() {
890         return getPoolProperties().getDbProperties();
891     }
892
893     /**
894      * {@inheritDoc}
895      */
896
897     @Override
898     public String getDefaultCatalog() {
899         return getPoolProperties().getDefaultCatalog();
900     }
901
902     /**
903      * {@inheritDoc}
904      */
905
906     @Override
907     public int getDefaultTransactionIsolation() {
908         return getPoolProperties().getDefaultTransactionIsolation();
909     }
910
911     /**
912      * {@inheritDoc}
913      */
914
915     @Override
916     public String getDriverClassName() {
917         return getPoolProperties().getDriverClassName();
918     }
919
920
921     /**
922      * {@inheritDoc}
923      */
924
925     @Override
926     public int getInitialSize() {
927         return getPoolProperties().getInitialSize();
928     }
929
930     /**
931      * {@inheritDoc}
932      */
933
934     @Override
935     public String getInitSQL() {
936         return getPoolProperties().getInitSQL();
937     }
938
939     /**
940      * {@inheritDoc}
941      */
942
943     @Override
944     public String getJdbcInterceptors() {
945         return getPoolProperties().getJdbcInterceptors();
946     }
947
948     /**
949      * {@inheritDoc}
950      */
951
952     @Override
953     public int getMaxActive() {
954         return getPoolProperties().getMaxActive();
955     }
956
957     /**
958      * {@inheritDoc}
959      */
960
961     @Override
962     public int getMaxIdle() {
963         return getPoolProperties().getMaxIdle();
964     }
965
966     /**
967      * {@inheritDoc}
968      */
969
970     @Override
971     public int getMaxWait() {
972         return getPoolProperties().getMaxWait();
973     }
974
975     /**
976      * {@inheritDoc}
977      */
978
979     @Override
980     public int getMinEvictableIdleTimeMillis() {
981         return getPoolProperties().getMinEvictableIdleTimeMillis();
982     }
983
984     /**
985      * {@inheritDoc}
986      */
987
988     @Override
989     public int getMinIdle() {
990         return getPoolProperties().getMinIdle();
991     }
992
993     /**
994      * {@inheritDoc}
995      */
996
997     @Override
998     public long getMaxAge() {
999         return getPoolProperties().getMaxAge();
1000     }
1001
1002     /**
1003      * {@inheritDoc}
1004      */
1005
1006     @Override
1007     public String getName() {
1008         return getPoolProperties().getName();
1009     }
1010
1011     /**
1012      * {@inheritDoc}
1013      */
1014
1015     @Override
1016     public int getNumTestsPerEvictionRun() {
1017         return getPoolProperties().getNumTestsPerEvictionRun();
1018     }
1019
1020     /**
1021      * @return DOES NOT RETURN THE PASSWORD, IT WOULD SHOW UP IN JMX
1022      */
1023     @Override
1024     public String getPassword() {
1025         return "Password not available as DataSource/JMX operation.";
1026     }
1027
1028     /**
1029      * {@inheritDoc}
1030      */
1031
1032     @Override
1033     public int getRemoveAbandonedTimeout() {
1034         return getPoolProperties().getRemoveAbandonedTimeout();
1035     }
1036
1037
1038     /**
1039      * {@inheritDoc}
1040      */
1041
1042     @Override
1043     public int getTimeBetweenEvictionRunsMillis() {
1044         return getPoolProperties().getTimeBetweenEvictionRunsMillis();
1045     }
1046
1047     /**
1048      * {@inheritDoc}
1049      */
1050
1051     @Override
1052     public String getUrl() {
1053         return getPoolProperties().getUrl();
1054     }
1055
1056     /**
1057      * {@inheritDoc}
1058      */
1059
1060     @Override
1061     public String getUsername() {
1062         return getPoolProperties().getUsername();
1063     }
1064
1065     /**
1066      * {@inheritDoc}
1067      */
1068
1069     @Override
1070     public long getValidationInterval() {
1071         return getPoolProperties().getValidationInterval();
1072     }
1073
1074     /**
1075      * {@inheritDoc}
1076      */
1077
1078     @Override
1079     public String getValidationQuery() {
1080         return getPoolProperties().getValidationQuery();
1081     }
1082
1083     /**
1084      * {@inheritDoc}
1085      */
1086
1087     @Override
1088     public int getValidationQueryTimeout() {
1089         return getPoolProperties().getValidationQueryTimeout();
1090     }
1091
1092     /**
1093      * {@inheritDoc}
1094      */
1095
1096     @Override
1097     public String getValidatorClassName() {
1098         return getPoolProperties().getValidatorClassName();
1099     }
1100
1101     /**
1102      * {@inheritDoc}
1103      */
1104
1105     @Override
1106     public Validator getValidator() {
1107         return getPoolProperties().getValidator();
1108     }
1109
1110     /**
1111      * {@inheritDoc}
1112      */
1113     @Override
1114     public void setValidator(Validator validator) {
1115         getPoolProperties().setValidator(validator);
1116     }
1117
1118
1119     /**
1120      * {@inheritDoc}
1121      */
1122
1123     @Override
1124     public boolean isAccessToUnderlyingConnectionAllowed() {
1125         return getPoolProperties().isAccessToUnderlyingConnectionAllowed();
1126     }
1127
1128     /**
1129      * {@inheritDoc}
1130      */
1131
1132     @Override
1133     public Boolean isDefaultAutoCommit() {
1134         return getPoolProperties().isDefaultAutoCommit();
1135     }
1136
1137     /**
1138      * {@inheritDoc}
1139      */
1140
1141     @Override
1142     public Boolean isDefaultReadOnly() {
1143         return getPoolProperties().isDefaultReadOnly();
1144     }
1145
1146     /**
1147      * {@inheritDoc}
1148      */
1149
1150     @Override
1151     public boolean isLogAbandoned() {
1152         return getPoolProperties().isLogAbandoned();
1153     }
1154
1155     /**
1156      * {@inheritDoc}
1157      */
1158
1159     @Override
1160     public boolean isPoolSweeperEnabled() {
1161         return getPoolProperties().isPoolSweeperEnabled();
1162     }
1163
1164     /**
1165      * {@inheritDoc}
1166      */
1167
1168     @Override
1169     public boolean isRemoveAbandoned() {
1170         return getPoolProperties().isRemoveAbandoned();
1171     }
1172
1173     /**
1174      * {@inheritDoc}
1175      */
1176
1177     @Override
1178     public int getAbandonWhenPercentageFull() {
1179         return getPoolProperties().getAbandonWhenPercentageFull();
1180     }
1181
1182     /**
1183      * {@inheritDoc}
1184      */
1185
1186     @Override
1187     public boolean isTestOnBorrow() {
1188         return getPoolProperties().isTestOnBorrow();
1189     }
1190
1191     /**
1192      * {@inheritDoc}
1193      */
1194
1195     @Override
1196     public boolean isTestOnConnect() {
1197         return getPoolProperties().isTestOnConnect();
1198     }
1199
1200     /**
1201      * {@inheritDoc}
1202      */
1203
1204     @Override
1205     public boolean isTestOnReturn() {
1206         return getPoolProperties().isTestOnReturn();
1207     }
1208
1209     /**
1210      * {@inheritDoc}
1211      */
1212
1213     @Override
1214     public boolean isTestWhileIdle() {
1215         return getPoolProperties().isTestWhileIdle();
1216     }
1217
1218
1219     /**
1220      * {@inheritDoc}
1221      */
1222
1223     @Override
1224     public Boolean getDefaultAutoCommit() {
1225         return getPoolProperties().getDefaultAutoCommit();
1226     }
1227
1228     /**
1229      * {@inheritDoc}
1230      */
1231
1232     @Override
1233     public Boolean getDefaultReadOnly() {
1234         return getPoolProperties().getDefaultReadOnly();
1235     }
1236
1237     /**
1238      * {@inheritDoc}
1239      */
1240
1241     @Override
1242     public InterceptorDefinition[] getJdbcInterceptorsAsArray() {
1243         return getPoolProperties().getJdbcInterceptorsAsArray();
1244     }
1245
1246     /**
1247      * {@inheritDoc}
1248      */
1249
1250     @Override
1251     public boolean getUseLock() {
1252         return getPoolProperties().getUseLock();
1253     }
1254
1255     /**
1256      * {@inheritDoc}
1257      */
1258
1259     @Override
1260     public boolean isFairQueue() {
1261         return getPoolProperties().isFairQueue();
1262     }
1263
1264     /**
1265      * {@inheritDoc}
1266      */
1267
1268     @Override
1269     public boolean isJmxEnabled() {
1270         return getPoolProperties().isJmxEnabled();
1271     }
1272
1273     /**
1274      * {@inheritDoc}
1275      */
1276
1277     @Override
1278     public boolean isUseEquals() {
1279         return getPoolProperties().isUseEquals();
1280     }
1281
1282     /**
1283      * {@inheritDoc}
1284      */
1285
1286     @Override
1287     public void setAbandonWhenPercentageFull(int percentage) {
1288         getPoolProperties().setAbandonWhenPercentageFull(percentage);
1289     }
1290
1291     /**
1292      * {@inheritDoc}
1293      */
1294
1295     @Override
1296     public void setAccessToUnderlyingConnectionAllowed(boolean accessToUnderlyingConnectionAllowed) {
1297         getPoolProperties().setAccessToUnderlyingConnectionAllowed(accessToUnderlyingConnectionAllowed);
1298     }
1299
1300     /**
1301      * {@inheritDoc}
1302      */
1303
1304     @Override
1305     public void setDbProperties(Properties dbProperties) {
1306         getPoolProperties().setDbProperties(dbProperties);
1307     }
1308
1309     /**
1310      * {@inheritDoc}
1311      */
1312
1313     @Override
1314     public void setDefaultReadOnly(Boolean defaultReadOnly) {
1315         getPoolProperties().setDefaultReadOnly(defaultReadOnly);
1316     }
1317
1318     /**
1319      * {@inheritDoc}
1320      */
1321
1322     @Override
1323     public void setMaxAge(long maxAge) {
1324         getPoolProperties().setMaxAge(maxAge);
1325     }
1326
1327     /**
1328      * {@inheritDoc}
1329      */
1330
1331     @Override
1332     public void setName(String name) {
1333         getPoolProperties().setName(name);
1334     }
1335
1336     /**
1337      * {@inheritDoc}
1338      */
1339     @Override
1340     public void setDataSource(Object ds) {
1341         getPoolProperties().setDataSource(ds);
1342     }
1343
1344     /**
1345      * {@inheritDoc}
1346      */
1347     @Override
1348     public Object getDataSource() {
1349         return getPoolProperties().getDataSource();
1350     }
1351
1352
1353     /**
1354      * {@inheritDoc}
1355      */
1356     @Override
1357     public void setDataSourceJNDI(String jndiDS) {
1358         getPoolProperties().setDataSourceJNDI(jndiDS);
1359     }
1360
1361     /**
1362      * {@inheritDoc}
1363      */
1364     @Override
1365     public String getDataSourceJNDI() {
1366         return getPoolProperties().getDataSourceJNDI();
1367     }
1368
1369     /**
1370      * {@inheritDoc}
1371      */
1372     @Override
1373     public boolean isAlternateUsernameAllowed() {
1374         return getPoolProperties().isAlternateUsernameAllowed();
1375     }
1376
1377     /**
1378      * {@inheritDoc}
1379      */
1380     @Override
1381     public void setAlternateUsernameAllowed(boolean alternateUsernameAllowed) {
1382         getPoolProperties().setAlternateUsernameAllowed(alternateUsernameAllowed);
1383     }
1384
1385     /**
1386      * {@inheritDoc}
1387      */
1388     @Override
1389     public void setCommitOnReturn(boolean commitOnReturn) {
1390         getPoolProperties().setCommitOnReturn(commitOnReturn);
1391     }
1392
1393     /**
1394      * {@inheritDoc}
1395      */
1396     @Override
1397     public boolean getCommitOnReturn() {
1398         return getPoolProperties().getCommitOnReturn();
1399     }
1400
1401     /**
1402      * {@inheritDoc}
1403      */
1404     @Override
1405     public void setRollbackOnReturn(boolean rollbackOnReturn) {
1406         getPoolProperties().setRollbackOnReturn(rollbackOnReturn);
1407     }
1408
1409     /**
1410      * {@inheritDoc}
1411      */
1412     @Override
1413     public boolean getRollbackOnReturn() {
1414         return getPoolProperties().getRollbackOnReturn();
1415     }
1416
1417     /**
1418      * {@inheritDoc}
1419      */
1420     @Override
1421     public void setUseDisposableConnectionFacade(boolean useDisposableConnectionFacade) {
1422         getPoolProperties().setUseDisposableConnectionFacade(useDisposableConnectionFacade);
1423     }
1424
1425     /**
1426      * {@inheritDoc}
1427      */
1428     @Override
1429     public boolean getUseDisposableConnectionFacade() {
1430         return getPoolProperties().getUseDisposableConnectionFacade();
1431     }
1432
1433     /**
1434      * {@inheritDoc}
1435      */
1436     @Override
1437     public void setLogValidationErrors(boolean logValidationErrors) {
1438         getPoolProperties().setLogValidationErrors(logValidationErrors);
1439     }
1440
1441     /**
1442      * {@inheritDoc}
1443      */
1444     @Override
1445     public boolean getLogValidationErrors() {
1446         return getPoolProperties().getLogValidationErrors();
1447     }
1448
1449     /**
1450      * {@inheritDoc}
1451      */
1452     @Override
1453     public boolean getPropagateInterruptState() {
1454         return getPoolProperties().getPropagateInterruptState();
1455     }
1456
1457     /**
1458      * {@inheritDoc}
1459      */
1460     @Override
1461     public void setPropagateInterruptState(boolean propagateInterruptState) {
1462         getPoolProperties().setPropagateInterruptState(propagateInterruptState);
1463     }
1464
1465     /**
1466      * {@inheritDoc}
1467      */
1468     @Override
1469     public boolean isIgnoreExceptionOnPreLoad() {
1470         return getPoolProperties().isIgnoreExceptionOnPreLoad();
1471     }
1472
1473     /**
1474      * {@inheritDoc}
1475      */
1476     @Override
1477     public void setIgnoreExceptionOnPreLoad(boolean ignoreExceptionOnPreLoad) {
1478         getPoolProperties().setIgnoreExceptionOnPreLoad(ignoreExceptionOnPreLoad);
1479     }
1480
1481     public void purge()  {
1482         try {
1483             createPool().purge();
1484         }catch (SQLException x) {
1485             log.error("Unable to purge pool.",x);
1486         }
1487     }
1488
1489     public void purgeOnReturn() {
1490         try {
1491             createPool().purgeOnReturn();
1492         }catch (SQLException x) {
1493             log.error("Unable to purge pool.",x);
1494         }
1495     }
1496 }