diff --git a/deegree-core/deegree-connectionprovider-datasource/src/main/resources/META-INF/schemas/connectionprovider/datasource/3.4.0/example_dbcp_mssql.xml b/deegree-core/deegree-connectionprovider-datasource/src/main/resources/META-INF/schemas/connectionprovider/datasource/3.4.0/example_dbcp_mssql.xml
index 97ec533d22..ed80cb824c 100644
--- a/deegree-core/deegree-connectionprovider-datasource/src/main/resources/META-INF/schemas/connectionprovider/datasource/3.4.0/example_dbcp_mssql.xml
+++ b/deegree-core/deegree-connectionprovider-datasource/src/main/resources/META-INF/schemas/connectionprovider/datasource/3.4.0/example_dbcp_mssql.xml
@@ -3,7 +3,7 @@
xsi:schemaLocation="http://www.deegree.org/connectionprovider/datasource http://schemas.deegree.org/jdbc/datasource/3.4.0/datasource.xsd">
-
+
diff --git a/deegree-core/deegree-connectionprovider-datasource/src/main/resources/META-INF/schemas/connectionprovider/datasource/3.4.0/example_dbcp_oracle.xml b/deegree-core/deegree-connectionprovider-datasource/src/main/resources/META-INF/schemas/connectionprovider/datasource/3.4.0/example_dbcp_oracle.xml
index 305700e9c7..77cc72831a 100644
--- a/deegree-core/deegree-connectionprovider-datasource/src/main/resources/META-INF/schemas/connectionprovider/datasource/3.4.0/example_dbcp_oracle.xml
+++ b/deegree-core/deegree-connectionprovider-datasource/src/main/resources/META-INF/schemas/connectionprovider/datasource/3.4.0/example_dbcp_oracle.xml
@@ -3,7 +3,7 @@
xsi:schemaLocation="http://www.deegree.org/connectionprovider/datasource http://schemas.deegree.org/jdbc/datasource/3.4.0/datasource.xsd">
-
+
diff --git a/deegree-core/deegree-connectionprovider-datasource/src/main/resources/META-INF/schemas/connectionprovider/datasource/3.4.0/example_dbcp_postgres.xml b/deegree-core/deegree-connectionprovider-datasource/src/main/resources/META-INF/schemas/connectionprovider/datasource/3.4.0/example_dbcp_postgres.xml
index 18176a7252..defc7069b8 100644
--- a/deegree-core/deegree-connectionprovider-datasource/src/main/resources/META-INF/schemas/connectionprovider/datasource/3.4.0/example_dbcp_postgres.xml
+++ b/deegree-core/deegree-connectionprovider-datasource/src/main/resources/META-INF/schemas/connectionprovider/datasource/3.4.0/example_dbcp_postgres.xml
@@ -3,7 +3,7 @@
xsi:schemaLocation="http://www.deegree.org/connectionprovider/datasource http://schemas.deegree.org/jdbc/datasource/3.4.0/datasource.xsd">
-
+
diff --git a/deegree-core/deegree-core-commons/pom.xml b/deegree-core/deegree-core-commons/pom.xml
index 56f5e9eb5c..199c685fff 100644
--- a/deegree-core/deegree-core-commons/pom.xml
+++ b/deegree-core/deegree-core-commons/pom.xml
@@ -72,16 +72,16 @@
xercesImpl
- commons-dbcp
- commons-dbcp
+ org.apache.commons
+ commons-dbcp2
org.apache.httpcomponents
httpclient
- commons-pool
- commons-pool
+ org.apache.commons
+ commons-pool2
jogl
diff --git a/deegree-core/deegree-core-commons/src/main/java/org/deegree/commons/jdbc/ConnectionPool.java b/deegree-core/deegree-core-commons/src/main/java/org/deegree/commons/jdbc/ConnectionPool.java
index 5664e9ce28..63c525b86c 100644
--- a/deegree-core/deegree-core-commons/src/main/java/org/deegree/commons/jdbc/ConnectionPool.java
+++ b/deegree-core/deegree-core-commons/src/main/java/org/deegree/commons/jdbc/ConnectionPool.java
@@ -41,12 +41,12 @@
import java.sql.Connection;
import java.sql.SQLException;
-import org.apache.commons.dbcp.ConnectionFactory;
-import org.apache.commons.dbcp.DelegatingConnection;
-import org.apache.commons.dbcp.DriverManagerConnectionFactory;
-import org.apache.commons.dbcp.PoolableConnectionFactory;
-import org.apache.commons.dbcp.PoolingDataSource;
-import org.apache.commons.pool.impl.GenericObjectPool;
+import org.apache.commons.dbcp2.ConnectionFactory;
+import org.apache.commons.dbcp2.DriverManagerConnectionFactory;
+import org.apache.commons.dbcp2.PoolableConnection;
+import org.apache.commons.dbcp2.PoolableConnectionFactory;
+import org.apache.commons.dbcp2.PoolingDataSource;
+import org.apache.commons.pool2.impl.GenericObjectPool;
import org.deegree.commons.annotations.LoggingNotes;
import org.slf4j.Logger;
@@ -67,7 +67,7 @@ public class ConnectionPool {
private final PoolingDataSource ds;
- private final GenericObjectPool pool;
+ private final GenericObjectPool pool;
/**
* Creates a new {@link ConnectionPool} instance.
@@ -84,14 +84,16 @@ public ConnectionPool( String id, String connectURI, String user, String passwor
int maxActive ) {
this.id = id;
- pool = new GenericObjectPool( null );
+ ConnectionFactory connectionFactory = new DriverManagerConnectionFactory( connectURI, user, password );
+ PoolableConnectionFactory poolableConnectionFactory = new PoolableConnectionFactory( connectionFactory, null );
+ pool = new GenericObjectPool<>(poolableConnectionFactory);
pool.setMinIdle( minIdle );
- pool.setMaxActive( maxActive );
+ pool.setMaxTotal( maxActive );
+ pool.setTestOnBorrow(true);
- ConnectionFactory connectionFactory = new DriverManagerConnectionFactory( connectURI, user, password );
- // TODO make this configurable
- new PoolableConnectionFactory( connectionFactory, pool, null, null, readOnly, true );
+ poolableConnectionFactory.setPool(pool);
ds = new PoolingDataSource( pool );
+
// needed, so users can retrieve the underlying connection from pooled
// connections, e.g. to access the
// LargeObjectManager from a PGConnection
@@ -117,11 +119,13 @@ public Connection getConnection()
public void destroy()
throws Exception {
pool.close();
+ ds.close();
}
- public void invalidate( DelegatingConnection conn )
+ public void invalidate( PoolableConnection conn )
throws Exception {
conn.getDelegate().close();
+ conn.reallyClose();
pool.invalidateObject( conn );
}
}
diff --git a/deegree-core/deegree-core-db/src/main/java/org/deegree/db/legacy/LegacyConnectionProvider.java b/deegree-core/deegree-core-db/src/main/java/org/deegree/db/legacy/LegacyConnectionProvider.java
index 30e2cfd422..0f5a3fd223 100644
--- a/deegree-core/deegree-core-db/src/main/java/org/deegree/db/legacy/LegacyConnectionProvider.java
+++ b/deegree-core/deegree-core-db/src/main/java/org/deegree/db/legacy/LegacyConnectionProvider.java
@@ -44,7 +44,8 @@ Occam Labs UG (haftungsbeschränkt)
import java.sql.Connection;
import java.sql.SQLException;
-import org.apache.commons.dbcp.DelegatingConnection;
+import org.apache.commons.dbcp2.DelegatingConnection;
+import org.apache.commons.dbcp2.PoolableConnection;
import org.deegree.commons.jdbc.ConnectionPool;
import org.deegree.db.ConnectionProvider;
import org.deegree.sqldialect.SQLDialect;
@@ -128,7 +129,7 @@ public SQLDialect getDialect() {
@Override
public void invalidate( Connection conn ) {
try {
- pool.invalidate( (DelegatingConnection) conn );
+ pool.invalidate( (PoolableConnection) conn );
} catch ( Exception e ) {
throw new RuntimeException( e );
}
diff --git a/deegree-datastores/deegree-tilestores/deegree-tilestore-geotiff/src/main/java/org/deegree/tile/persistence/geotiff/GeoTIFFTile.java b/deegree-datastores/deegree-tilestores/deegree-tilestore-geotiff/src/main/java/org/deegree/tile/persistence/geotiff/GeoTIFFTile.java
index ee14274cd3..7f12bd011a 100644
--- a/deegree-datastores/deegree-tilestores/deegree-tilestore-geotiff/src/main/java/org/deegree/tile/persistence/geotiff/GeoTIFFTile.java
+++ b/deegree-datastores/deegree-tilestores/deegree-tilestore-geotiff/src/main/java/org/deegree/tile/persistence/geotiff/GeoTIFFTile.java
@@ -51,7 +51,7 @@ Occam Labs UG (haftungsbeschränkt)
import javax.imageio.ImageIO;
import javax.imageio.ImageReader;
-import org.apache.commons.pool.impl.GenericObjectPool;
+import org.apache.commons.pool2.impl.GenericObjectPool;
import org.deegree.feature.FeatureCollection;
import org.deegree.geometry.Envelope;
import org.deegree.tile.Tile;
diff --git a/deegree-datastores/deegree-tilestores/deegree-tilestore-geotiff/src/main/java/org/deegree/tile/persistence/geotiff/GeoTIFFTileDataLevel.java b/deegree-datastores/deegree-tilestores/deegree-tilestore-geotiff/src/main/java/org/deegree/tile/persistence/geotiff/GeoTIFFTileDataLevel.java
index 443c127430..b042dda3a4 100644
--- a/deegree-datastores/deegree-tilestores/deegree-tilestore-geotiff/src/main/java/org/deegree/tile/persistence/geotiff/GeoTIFFTileDataLevel.java
+++ b/deegree-datastores/deegree-tilestores/deegree-tilestore-geotiff/src/main/java/org/deegree/tile/persistence/geotiff/GeoTIFFTileDataLevel.java
@@ -43,7 +43,7 @@ Occam Labs UG (haftungsbeschränkt)
import java.io.File;
import java.util.List;
-import org.apache.commons.pool.impl.GenericObjectPool;
+import org.apache.commons.pool2.impl.GenericObjectPool;
import org.deegree.geometry.Envelope;
import org.deegree.geometry.GeometryFactory;
import org.deegree.tile.TileDataLevel;
diff --git a/deegree-datastores/deegree-tilestores/deegree-tilestore-geotiff/src/main/java/org/deegree/tile/persistence/geotiff/ImageReaderFactory.java b/deegree-datastores/deegree-tilestores/deegree-tilestore-geotiff/src/main/java/org/deegree/tile/persistence/geotiff/ImageReaderFactory.java
index 6c5d5d2eac..75008d1292 100644
--- a/deegree-datastores/deegree-tilestores/deegree-tilestore-geotiff/src/main/java/org/deegree/tile/persistence/geotiff/ImageReaderFactory.java
+++ b/deegree-datastores/deegree-tilestores/deegree-tilestore-geotiff/src/main/java/org/deegree/tile/persistence/geotiff/ImageReaderFactory.java
@@ -50,42 +50,52 @@ Occam Labs UG (haftungsbeschränkt)
import javax.imageio.ImageReader;
import javax.imageio.stream.ImageInputStream;
-import org.apache.commons.pool.PoolableObjectFactory;
+import org.apache.commons.pool2.PooledObject;
+import org.apache.commons.pool2.PooledObjectFactory;
+import org.apache.commons.pool2.impl.DefaultPooledObject;
/**
- * ImageReaderFactory
: an object factory for commons-pool. It should really be replaced with a better
- * solution, not using generics here (and throwing Exception) is not the way to go...
+ * ImageReaderFactory
: an object factory for Apache commons-pool providing
+ * file-based image reader.
*
* @author Andreas Schmitz
- * @author last edited by: $Author: mschneider $
- *
- * @version $Revision: 31882 $, $Date: 2011-09-15 02:05:04 +0200 (Thu, 15 Sep 2011) $
+ * @author Torsten Friebe
+ *
*/
+public class ImageReaderFactory implements PooledObjectFactory {
-public class ImageReaderFactory implements PoolableObjectFactory {
-
- private File file;
+ private final File file;
public ImageReaderFactory( File file ) {
this.file = file;
}
@Override
- public void activateObject( Object o )
- throws Exception {
+ public void destroyObject(PooledObject pooledObject) throws Exception {
+ ImageReader reader = (ImageReader) pooledObject;
+ reader.dispose();
+ }
+
+ @Override
+ public boolean validateObject(PooledObject pooledObject) {
+ // ImageReader reader = (ImageReader) o;
+ // ImageInputStream iis = (ImageInputStream) reader.getInput();
+ // unknown if we need something here, so far no readers have become invalid
+ return true;
+ }
+
+ @Override
+ public void activateObject(PooledObject pooledObject) throws Exception {
// nothing to do
}
@Override
- public void destroyObject( Object o )
- throws Exception {
- ImageReader reader = (ImageReader) o;
- reader.dispose();
+ public void passivateObject(PooledObject pooledObject) throws Exception {
+ // nothing to do
}
@Override
- public Object makeObject()
- throws Exception {
+ public PooledObject makeObject() throws Exception {
ImageInputStream iis = null;
ImageReader reader = null;
Iterator readers = getImageReadersBySuffix( "tiff" );
@@ -95,21 +105,6 @@ public Object makeObject()
iis = createImageInputStream( file );
// already checked in provider
reader.setInput( iis );
- return reader;
+ return new DefaultPooledObject(reader);
}
-
- @Override
- public void passivateObject( Object o )
- throws Exception {
- // nothing to do
- }
-
- @Override
- public boolean validateObject( Object o ) {
- // ImageReader reader = (ImageReader) o;
- // ImageInputStream iis = (ImageInputStream) reader.getInput();
- // unknown if we need something here, so far no readers have become invalid
- return true;
- }
-
}
diff --git a/deegree-services/deegree-webservices-handbook/src/main/asciidoc/serverconnections.adoc b/deegree-services/deegree-webservices-handbook/src/main/asciidoc/serverconnections.adoc
index 47a6cf5ede..a30fd85aa1 100644
--- a/deegree-services/deegree-webservices-handbook/src/main/asciidoc/serverconnections.adoc
+++ b/deegree-services/deegree-webservices-handbook/src/main/asciidoc/serverconnections.adoc
@@ -55,7 +55,7 @@ database:
xsi:schemaLocation="http://www.deegree.org/connectionprovider/datasource http://schemas.deegree.org/jdbc/datasource/3.4.0/datasource.xsd">
-
+
@@ -68,7 +68,7 @@ database:
----
* The DataSource object uses Java class
-_org.apache.commons.dbcp.BasicDataSource_ (a connection pool class
+_org.apache.commons.dbcp2.BasicDataSource_ (a connection pool class
provided by
http://commons.apache.org/proper/commons-dbcp/index.html[Apache Commons
DBCP].). If you don't know what this means, then this is most likely
@@ -102,7 +102,7 @@ This example defines a connection pool for an Oracle database:
xsi:schemaLocation="http://www.deegree.org/connectionprovider/datasource http://schemas.deegree.org/jdbc/datasource/3.4.0/datasource.xsd">
-
+
@@ -119,7 +119,7 @@ This example defines a connection pool for an Oracle database:
This defines a database connection with the following properties:
* The DataSource object uses the Java class
-_org.apache.commons.dbcp.BasicDataSource_ (a connection pool class
+_org.apache.commons.dbcp2.BasicDataSource_ (a connection pool class
provided by Apache DBCP). If you are not familiar with J2EE containers,
this is most likely what you want to use.
* The JDBC driver class is _oracle.jdbc.OracleDriver_. This is the
@@ -147,7 +147,7 @@ This example defines a connection pool for a Microsoft SQL Server:
xsi:schemaLocation="http://www.deegree.org/connectionprovider/datasource http://schemas.deegree.org/jdbc/datasource/3.4.0/datasource.xsd">
-
+
@@ -164,7 +164,7 @@ This example defines a connection pool for a Microsoft SQL Server:
This defines a database connection with the following properties:
* The DataSource object uses the Java class
-_org.apache.commons.dbcp.BasicDataSource_ (a connection pool class
+_org.apache.commons.dbcp2.BasicDataSource_ (a connection pool class
provided by Apache DBCP). If you are not familiar with J2EE containers,
this is most likely what you want to use.
* The JDBC driver class is _org.postgresql.Driver_. This is the Java
@@ -284,13 +284,13 @@ snippets for clarification:
[source,xml]
----
...
-
+
...
----
In this snippet, no _factoryMethod_ attribute is present. Therefore,
the constructor of Java class
-_org.apache.commons.dbcp.BasicDataSource_ is invoked. The returned
+_org.apache.commons.dbcp2.BasicDataSource_ is invoked. The returned
instance must be an implementation of _javax.sql.DataSource_, and this
is guaranteed, because the class implements this interface. There are no
arguments passed to the constructor.
@@ -344,7 +344,7 @@ The properties available for configuration depend on the implementation
of _javax.sql.DataSource_:
* Apache Commons DBCP: See
-http://commons.apache.org/proper/commons-dbcp/api-1.4/org/apache/commons/dbcp/BasicDataSource.html
+http://commons.apache.org/proper/commons-dbcp/api-2.7.0/org/apache/commons/dbcp2/BasicDataSource.html
* Oracle UCP:
http://docs.oracle.com/cd/E11882_01/java.112/e12826/oracle/ucp/jdbc/PoolDataSource.html
diff --git a/pom.xml b/pom.xml
index 6046e3ea4f..bb61a3737d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -446,14 +446,14 @@
- commons-pool
- commons-pool
- 1.6
+ org.apache.commons
+ commons-pool2
+ 2.7.0
- commons-dbcp
- commons-dbcp
- 1.4
+ org.apache.commons
+ commons-dbcp2
+ 2.7.0
commons-cli