Strabon

changeset 398:d8e50c09be54

call Strabon.deregisterDriver() only through strabon-endpoint (see comment at the respective method why to do that)
author Babis Nikolaou <charnik@di.uoa.gr>
date Thu Jun 28 16:25:12 2012 +0300 (2012-06-28)
parents 9cb1f1314e7b
children 8200fa66b6c0
files endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/StrabonBeanWrapper.java runtime/src/main/java/eu/earthobservatory/runtime/generaldb/Strabon.java runtime/src/main/java/eu/earthobservatory/runtime/monetdb/Strabon.java runtime/src/main/java/eu/earthobservatory/runtime/postgis/Strabon.java
line diff
     1.1 --- a/endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/StrabonBeanWrapper.java	Thu Jun 28 15:50:00 2012 +0300
     1.2 +++ b/endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/StrabonBeanWrapper.java	Thu Jun 28 16:25:12 2012 +0300
     1.3 @@ -195,6 +195,9 @@
     1.4  	public void destroy() throws Exception {
     1.5  		if (strabon != null) {
     1.6  			strabon.close();
     1.7 +			
     1.8 +			// deregister jdbc driver
     1.9 +			strabon.deregisterDriver();
    1.10  		}
    1.11  	}
    1.12  
     2.1 --- a/runtime/src/main/java/eu/earthobservatory/runtime/generaldb/Strabon.java	Thu Jun 28 15:50:00 2012 +0300
     2.2 +++ b/runtime/src/main/java/eu/earthobservatory/runtime/generaldb/Strabon.java	Thu Jun 28 16:25:12 2012 +0300
     2.3 @@ -86,9 +86,17 @@
     2.4  
     2.5  
     2.6  	/**
     2.7 -	 * Called by Strabon.close() to deregister the underlying JDBC driver used.
     2.8 +	 * Deregisters the JDBC driver. This is advisable when running <tt>Strabon</tt>
     2.9 +	 * through the <tt>strabon-endpoint</tt>, i.e., in a container, such as Apache Tomcat.
    2.10 +	 * Earlier versions of Tomcat would not deregister the JDBC drivers leading
    2.11 +	 * to memory leaks.
    2.12 +	 * 
    2.13 +	 * Deregistering the JDBC driver when running Strabon through <tt>Java</tt> is not required.
    2.14 +	 * Instead, it might lead to unexpected errors when creating many <tt>Strabon</tt> instances,
    2.15 +	 * one after the other, and deregistering the driver. Subsequent instantiations of
    2.16 +	 * <tt>Strabon</tt> in the same <tt>Java</tt> run would fail to load the driver again.
    2.17  	 */
    2.18 -	protected abstract void deregisterDriver();
    2.19 +	public abstract void deregisterDriver();
    2.20  	
    2.21  	/**
    2.22  	 * Called in Strabon constructor to initialize Strabon (establish connection to the
    2.23 @@ -152,9 +160,6 @@
    2.24  			con1.close();
    2.25  			repo1.shutDown();
    2.26  			
    2.27 -			// deregister jdbc driver
    2.28 -			deregisterDriver();
    2.29 -
    2.30  		} catch (RepositoryException e) {
    2.31  			logger.error("[Strabon.close]", e);
    2.32  		}
     3.1 --- a/runtime/src/main/java/eu/earthobservatory/runtime/monetdb/Strabon.java	Thu Jun 28 15:50:00 2012 +0300
     3.2 +++ b/runtime/src/main/java/eu/earthobservatory/runtime/monetdb/Strabon.java	Thu Jun 28 16:25:12 2012 +0300
     3.3 @@ -64,7 +64,7 @@
     3.4  	}
     3.5  	
     3.6  	@Override
     3.7 -	protected void deregisterDriver() {
     3.8 +	public void deregisterDriver() {
     3.9  		try {
    3.10  			logger.info("[Strabon.deregisterDriver] Deregistering JDBC driver...");
    3.11  	        java.sql.Driver driver = DriverManager.getDriver("jdbc:monetdb://" + serverName + ":" + port + "/");
     4.1 --- a/runtime/src/main/java/eu/earthobservatory/runtime/postgis/Strabon.java	Thu Jun 28 15:50:00 2012 +0300
     4.2 +++ b/runtime/src/main/java/eu/earthobservatory/runtime/postgis/Strabon.java	Thu Jun 28 16:25:12 2012 +0300
     4.3 @@ -56,7 +56,7 @@
     4.4  	}
     4.5  
     4.6  	@Override
     4.7 -	protected void deregisterDriver() {
     4.8 +	public void deregisterDriver() {
     4.9  		try {
    4.10  			logger.info("[Strabon.deregisterDriver] Deregistering JDBC driver...");
    4.11  	        java.sql.Driver driver = DriverManager.getDriver("jdbc:postgresql://" + serverName + ":" + port + "/");