sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1811312 - in /sis/branches/JDK7: ./ application/sis-console/src/main/java/org/apache/sis/console/ core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/sql/ core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/
Date Fri, 06 Oct 2017 09:59:59 GMT
Author: desruisseaux
Date: Fri Oct  6 09:59:59 2017
New Revision: 1811312

URL: http://svn.apache.org/viewvc?rev=1811312&view=rev
Log:
Merge from JDK8 branch.

Modified:
    sis/branches/JDK7/   (props changed)
    sis/branches/JDK7/application/sis-console/src/main/java/org/apache/sis/console/ResourcesDownloader.java
    sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/sql/Initializer.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGFactory.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGInstaller.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/InstallationScriptProvider.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/package-info.java

Propchange: sis/branches/JDK7/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Oct  6 09:59:59 2017
@@ -1,5 +1,5 @@
 /sis/branches/Android:1430670-1480699
 /sis/branches/JDK6:1394913-1508480
-/sis/branches/JDK8:1584960-1811215
+/sis/branches/JDK8:1584960-1811310
 /sis/branches/JDK9:1773327-1803064
 /sis/trunk:1394364-1508466,1519089-1519674

Modified: sis/branches/JDK7/application/sis-console/src/main/java/org/apache/sis/console/ResourcesDownloader.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/application/sis-console/src/main/java/org/apache/sis/console/ResourcesDownloader.java?rev=1811312&r1=1811311&r2=1811312&view=diff
==============================================================================
--- sis/branches/JDK7/application/sis-console/src/main/java/org/apache/sis/console/ResourcesDownloader.java
[UTF-8] (original)
+++ sis/branches/JDK7/application/sis-console/src/main/java/org/apache/sis/console/ResourcesDownloader.java
[UTF-8] Fri Oct  6 09:59:59 2017
@@ -297,6 +297,7 @@ public class ResourcesDownloader extends
      * @return a reader for the installation script content.
      * @throws IllegalArgumentException if the given {@code authority} argument is not one
of the expected values.
      * @throws IndexOutOfBoundsException if the given {@code resource} argument is out of
bounds.
+     * @throws FileNotFoundException if the SQL script of the given name has not been found.
      * @throws IOException if an error occurred while creating the reader.
      */
     @Override

Modified: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/sql/Initializer.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/sql/Initializer.java?rev=1811312&r1=1811311&r2=1811312&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/sql/Initializer.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/sql/Initializer.java
[UTF-8] Fri Oct  6 09:59:59 2017
@@ -275,17 +275,16 @@ public abstract class Initializer {
              * Only if the SIS_DATA environment variable is not set, verify first if the
'sis-embedded-data' module is
              * on the classpath. Note that if SIS_DATA is defined and valid, it has precedence.
              */
-            final boolean create;
+            boolean create = false;
             final boolean isEnvClear = DataDirectory.isEnvClear();
-            if (isEnvClear && (source = embedded()) != null) {
-                create = false;
-            } else {
+            if (!isEnvClear || (source = embedded()) == null) {
                 final String home = AccessController.doPrivileged(new PrivilegedAction<String>()
{
                     @Override public String run() {
                         return System.getProperty(DERBY_HOME_KEY);
                     }
                 });
                 final Path dir = DataDirectory.DATABASES.getDirectory();
+                final String dbURL;
                 if (dir != null) {
                     Path path = dir.resolve(DATABASE);
                     if (home != null) try {
@@ -301,25 +300,35 @@ public abstract class Initializer {
                         // The path can not be relativized. This is okay.
                         Logging.recoverableException(Logging.getLogger(Loggers.SQL), Initializer.class,
"getDataSource", e);
                     }
-                    /*
-                     * Create the Derby data source using the context class loader if possible,
-                     * or otherwise a URL class loader to the JavaDB distributed with the
JDK.
-                     */
                     path   = path.normalize();
                     create = !Files.exists(path);
-                    source = forJavaDB(path.toString().replace(path.getFileSystem().getSeparator(),
"/"));
+                    dbURL  = path.toString().replace(path.getFileSystem().getSeparator(),
"/");
                 } else if (home != null) {
                     final Path path = Paths.get(home);
                     create = !Files.exists(path.resolve(DATABASE)) && Files.isDirectory(path);
-                    source = forJavaDB(DATABASE);
-                } else if (!isEnvClear) {
-                    create = false;
-                    source = embedded();        // Try only if we did not already tried after
above JNDI check.
-                    if (source == null) {
+                    dbURL  = DATABASE;
+                } else {
+                    create = true;
+                    dbURL  = null;
+                }
+                /*
+                 * If we need to create the database, verify if an embedded database is available
instead.
+                 * We perform this check only if we have not already checked for embedded
database at the
+                 * beginning of this block.
+                 */
+                if (create & !isEnvClear) {
+                    source = embedded();
+                    create = (source == null);
+                }
+                if (source == null) {
+                    if (dbURL == null) {
                         return null;
                     }
-                } else {
-                    return null;
+                    /*
+                     * Create the Derby data source using the context class loader if possible,
+                     * or otherwise a URL class loader to the JavaDB distributed with the
JDK.
+                     */
+                    source = forJavaDB(dbURL);
                 }
             }
             /*

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGFactory.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGFactory.java?rev=1811312&r1=1811311&r2=1811312&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGFactory.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGFactory.java
[UTF-8] Fri Oct  6 09:59:59 2017
@@ -26,6 +26,7 @@ import java.sql.DatabaseMetaData;
 import java.sql.SQLException;
 import javax.sql.DataSource;
 import java.io.IOException;
+import java.io.FileNotFoundException;
 import org.opengis.util.NameFactory;
 import org.opengis.util.FactoryException;
 import org.opengis.referencing.crs.CRSFactory;
@@ -366,7 +367,9 @@ public class EPSGFactory extends Concurr
      * See <a href="https://issues.apache.org/jira/browse/LEGAL-183">LEGAL-183</a>
for more information.</p>
      *
      * @param  connection  connection to the database where to create the EPSG schema.
-     * @throws IOException if the SQL script can not be found or an I/O error occurred while
reading them.
+     * @throws FileNotFoundException if a SQL script has not been found,
+     *         typically because a required resource is not on the classpath.
+     * @throws IOException  if an I/O error occurred while reading a SQL script.
      * @throws SQLException if an error occurred while writing to the database.
      *
      * @see InstallationScriptProvider

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGInstaller.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGInstaller.java?rev=1811312&r1=1811311&r2=1811312&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGInstaller.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGInstaller.java
[UTF-8] Fri Oct  6 09:59:59 2017
@@ -18,6 +18,7 @@ package org.apache.sis.referencing.facto
 
 import java.util.Locale;
 import java.io.IOException;
+import java.io.FileNotFoundException;
 import java.sql.Connection;
 import java.sql.DatabaseMetaData;
 import java.sql.SQLException;
@@ -235,7 +236,9 @@ final class EPSGInstaller extends Script
      * Processes to the creation of the EPSG database using the SQL scripts from the given
provider.
      *
      * @param  scriptProvider  user-provided scripts, or {@code null} for automatic lookup.
-     * @throws IOException  if an error occurred while reading an input.
+     * @param  locale          the locale for information or warning messages, if any.
+     * @throws FileNotFoundException if a SQL script has not been found.
+     * @throws IOException  if another error occurred while reading an input.
      * @throws SQLException if an error occurred while executing a SQL statement.
      */
     public void run(InstallationResources scriptProvider, final Locale locale) throws SQLException,
IOException {
@@ -260,12 +263,14 @@ final class EPSGInstaller extends Script
 
     /**
      * Searches for a SQL script provider on the classpath before to fallback on the default
provider.
+     *
+     * @param  locale  the locale for information or warning messages, if any.
      */
     private static InstallationResources lookupProvider(final Locale locale) throws IOException
{
         InstallationResources fallback = null;
         for (final InstallationResources provider : DefaultFactories.createServiceLoader(InstallationResources.class))
{
             if (provider.getAuthorities().contains(EPSG)) {
-                if (provider.getClass().isAnnotationPresent(Fallback.class)) {
+                if (!provider.getClass().isAnnotationPresent(Fallback.class)) {
                     return provider;
                 }
                 fallback = provider;

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/InstallationScriptProvider.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/InstallationScriptProvider.java?rev=1811312&r1=1811311&r2=1811312&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/InstallationScriptProvider.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/InstallationScriptProvider.java
[UTF-8] Fri Oct  6 09:59:59 2017
@@ -38,6 +38,7 @@ import org.apache.sis.util.logging.Loggi
 import org.apache.sis.util.ArgumentChecks;
 import org.apache.sis.setup.InstallationResources;
 import org.apache.sis.internal.referencing.Resources;
+import org.apache.sis.internal.referencing.Fallback;
 import org.apache.sis.internal.system.DataDirectory;
 import org.apache.sis.internal.system.Loggers;
 import org.apache.sis.internal.util.CollectionsExt;
@@ -205,6 +206,7 @@ public abstract class InstallationScript
      * @return a reader for the content of SQL script to execute.
      * @throws IllegalArgumentException if the given {@code authority} argument is not the
expected value.
      * @throws IndexOutOfBoundsException if the given {@code resource} argument is out of
bounds.
+     * @throws FileNotFoundException if the SQL script of the given name has not been found.
      * @throws IOException if an error occurred while creating the reader.
      */
     @Override
@@ -294,6 +296,7 @@ public abstract class InstallationScript
      * @since   0.7
      * @module
      */
+    @Fallback
     static final class Default extends InstallationScriptProvider {
         /**
          * The directory containing the scripts, or {@code null} if it does not exist.
@@ -308,6 +311,8 @@ public abstract class InstallationScript
 
         /**
          * Creates a default provider.
+         *
+         * @param locale  the locale for warning messages, if any.
          */
         Default(final Locale locale) throws IOException {
             super(Constants.EPSG,

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/package-info.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/package-info.java?rev=1811312&r1=1811311&r2=1811312&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/package-info.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/package-info.java
[UTF-8] Fri Oct  6 09:59:59 2017
@@ -35,6 +35,8 @@
  *       a JDBC connection for the {@code "jdbc:derby:$SIS_DATA/Databases/SpatialMetadata"}
URL.</li>
  *   <li>If the {@code "derby.system.home"} {@linkplain java.lang.System#getProperty(String)
property} is defined,
  *       a JDBC connection for the {@code "jdbc:derby:SpatialMetadata"} URL.</li>
+ *   <li>If the {@code org.apache.sis.non-free:sis-embedded-data} module is present
on the classpath,
+ *       a read-only connection to the database in the JAR file.</li>
  * </ol>
  *
  * In choice 1, the JDBC driver must be provided by the application container (e.g. Apache
Tomcat).



Mime
View raw message