You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sis.apache.org by de...@apache.org on 2016/02/14 19:20:59 UTC
svn commit: r1730366 [1/2] - in /sis/branches/JDK7: ./
core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/sql/
core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/
core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identi...
Author: desruisseaux
Date: Sun Feb 14 18:20:58 2016
New Revision: 1730366
URL: http://svn.apache.org/viewvc?rev=1730366&view=rev
Log:
Merge from the JDK8 branch. Contains:
- CRS.forCode(String) more robust to unavailable EPSG factory.
- Better test of logging messages.
- Javadoc update.
Modified:
sis/branches/JDK7/ (props changed)
sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/sql/Initializer.java
sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/AllMetadataTest.java
sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultResolutionTest.java
sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/maintenance/DefaultScopeDescriptionTest.java
sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/spatial/DefaultGeorectifiedTest.java
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/Code.java
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/AuthorityFactories.java
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/CRS.java
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/CommonCRS.java
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/EPSGFactoryFallback.java
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/ConcurrentAuthorityFactory.java
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/GeodeticAuthorityFactory.java
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/IdentifiedObjectSet.java
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/UnavailableFactoryException.java
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGDataAccess.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/package-info.java
sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/internal/jaxb/referencing/CC_GeneralOperationParameterTest.java
sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/AuthorityFactoriesTest.java
sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/CRSTest.java
sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/CommonCRSTest.java
sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/EPSGFactoryFallbackTest.java
sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultProjectedCRSTest.java
sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS2002.java
sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS2004.java
sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS2005.java
sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GIGS2006.java
sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/MultiAuthoritiesFactoryTest.java
sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGFactoryTest.java
sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGInstallerTest.java
sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/report/CoordinateReferenceSystems.java
sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/integration/DefaultMetadataTest.java
sis/branches/JDK7/core/sis-referencing/src/test/resources/org/apache/sis/referencing/operation/Conversion.xml
sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/SetOfUnknownSize.java
sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/math/DecimalFunctions.java
sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/measure/Units.java
sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/IndexedResourceBundle.java
sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/LoggingWatcher.java
Propchange: sis/branches/JDK7/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Feb 14 18:20:58 2016
@@ -1,4 +1,4 @@
/sis/branches/Android:1430670-1480699
/sis/branches/JDK6:1394913-1508480
-/sis/branches/JDK8:1584960-1729974
+/sis/branches/JDK8:1584960-1730364
/sis/trunk:1394364-1508466,1519089-1519674
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=1730366&r1=1730365&r2=1730366&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] Sun Feb 14 18:20:58 2016
@@ -72,7 +72,7 @@ public abstract class Initializer {
/**
* The property name for the home of Derby databases.
*/
- private static final String HOME_KEY = "derby.system.home";
+ private static final String DERBY_HOME_KEY = "derby.system.home";
/**
* Name of the JNDI resource to lookup in the {@code "java:comp/env"} context.
@@ -241,8 +241,8 @@ public abstract class Initializer {
* At this point we determined that there is no JNDI context or no object binded to "jdbc/SpatialMetadata".
* As a fallback, try to open the Derby database located in $SIS_DATA/Databases/SpatialMetadata directory.
*/
- boolean create = false;
- final String home = System.getProperty(HOME_KEY);
+ final boolean create;
+ final String home = System.getProperty(DERBY_HOME_KEY);
final Path dir = DataDirectory.DATABASES.getDirectory();
if (dir != null) {
Path path = dir.resolve(DATABASE);
@@ -267,6 +267,8 @@ public abstract class Initializer {
create = !Files.exists(path);
source = forJavaDB(path.toString());
} else if (home != null) {
+ final Path path = Paths.get(home);
+ create = !Files.exists(path.resolve(DATABASE)) && Files.isDirectory(path);
source = forJavaDB(DATABASE);
} else {
return null;
Modified: sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/AllMetadataTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/AllMetadataTest.java?rev=1730366&r1=1730365&r2=1730366&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/AllMetadataTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/AllMetadataTest.java [UTF-8] Sun Feb 14 18:20:58 2016
@@ -44,12 +44,11 @@ import static org.junit.Assert.*;
@DependsOn(org.apache.sis.metadata.PropertyAccessorTest.class)
public final strictfp class AllMetadataTest extends MetadataTestCase {
/**
- * A JUnit {@linkplain Rule rule} for listening to log events. This field is public
- * because JUnit requires us to do so, but should be considered as an implementation
- * details (it should have been a private field).
+ * A JUnit {@link Rule} for listening to log events. This field is public because JUnit requires us to
+ * do so, but should be considered as an implementation details (it should have been a private field).
*/
@Rule
- public final LoggingWatcher listener = new LoggingWatcher(Context.LOGGER);
+ public final LoggingWatcher loggings = new LoggingWatcher(Context.LOGGER);
/**
* Creates a new test case with all GeoAPI interfaces and code lists to test.
@@ -219,8 +218,12 @@ public final strictfp class AllMetadataT
@Test
@Override
public void testPropertyValues() {
- listener.maximumLogCount = 4;
super.testPropertyValues();
+ loggings.assertNextLogContains("angularDistance", "distance");
+ loggings.assertNextLogContains("distance", "equivalentScale");
+ loggings.assertNextLogContains("equivalentScale", "levelOfDetail");
+ loggings.assertNextLogContains("levelOfDetail", "vertical");
+ loggings.assertNoUnexpectedLog();
}
/**
Modified: sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultResolutionTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultResolutionTest.java?rev=1730366&r1=1730365&r2=1730366&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultResolutionTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultResolutionTest.java [UTF-8] Sun Feb 14 18:20:58 2016
@@ -25,6 +25,7 @@ import org.apache.sis.internal.jaxb.Sche
import org.apache.sis.test.LoggingWatcher;
import org.apache.sis.test.DependsOn;
import org.apache.sis.test.TestCase;
+import org.junit.After;
import org.junit.Rule;
import org.junit.Test;
@@ -36,27 +37,25 @@ import static org.apache.sis.test.Assert
*
* @author Martin Desruisseaux (Geomatys)
* @since 0.3
- * @version 0.6
+ * @version 0.7
* @module
*/
@DependsOn(DefaultRepresentativeFractionTest.class)
public final strictfp class DefaultResolutionTest extends TestCase {
/**
- * A JUnit {@linkplain Rule rule} for listening to log events. This field is public
- * because JUnit requires us to do so, but should be considered as an implementation
- * details (it should have been a private field).
+ * A JUnit {@link Rule} for listening to log events. This field is public because JUnit requires us to
+ * do so, but should be considered as an implementation details (it should have been a private field).
*/
@Rule
- public final LoggingWatcher listener = new LoggingWatcher(Context.LOGGER) {
- /**
- * Ensures that the logging message contains the name of the exclusive properties.
- */
- @Override
- protected void verifyMessage(final String message) {
- assertTrue(message.contains("distance"));
- assertTrue(message.contains("equivalentScale"));
- }
- };
+ public final LoggingWatcher loggings = new LoggingWatcher(Context.LOGGER);
+
+ /**
+ * Verifies that no unexpected warning has been emitted in any test defined in this class.
+ */
+ @After
+ public void assertNoUnexpectedLog() {
+ loggings.assertNoUnexpectedLog();
+ }
/**
* Tests the {@link DefaultResolution#DefaultResolution(RepresentativeFraction)} constructor.
@@ -86,11 +85,13 @@ public final strictfp class DefaultResol
metadata.setDistance(2.0);
assertEquals("distance", Double.valueOf(2.0), metadata.getDistance());
assertNull("equivalentScale", metadata.getEquivalentScale());
+ loggings.assertNoUnexpectedLog();
- listener.maximumLogCount = 1;
metadata.setEquivalentScale(scale);
assertSame("equivalentScale", scale, metadata.getEquivalentScale());
assertNull("distance", metadata.getDistance());
+ loggings.assertNextLogContains("distance", "equivalentScale");
+ loggings.assertNoUnexpectedLog();
metadata.setDistance(null); // Expected to be a no-op.
assertSame("equivalentScale", scale, metadata.getEquivalentScale());
Modified: sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/maintenance/DefaultScopeDescriptionTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/maintenance/DefaultScopeDescriptionTest.java?rev=1730366&r1=1730365&r2=1730366&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/maintenance/DefaultScopeDescriptionTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/maintenance/DefaultScopeDescriptionTest.java [UTF-8] Sun Feb 14 18:20:58 2016
@@ -20,6 +20,7 @@ import org.apache.sis.util.iso.SimpleInt
import org.apache.sis.internal.jaxb.Context;
import org.apache.sis.test.LoggingWatcher;
import org.apache.sis.test.TestCase;
+import org.junit.After;
import org.junit.Rule;
import org.junit.Test;
@@ -36,21 +37,19 @@ import static org.apache.sis.test.Assert
*/
public final strictfp class DefaultScopeDescriptionTest extends TestCase {
/**
- * A JUnit {@linkplain Rule rule} for listening to log events. This field is public
- * because JUnit requires us to do so, but should be considered as an implementation
- * details (it should have been a private field).
+ * A JUnit {@link Rule} for listening to log events. This field is public because JUnit requires us to
+ * do so, but should be considered as an implementation details (it should have been a private field).
*/
@Rule
- public final LoggingWatcher listener = new LoggingWatcher(Context.LOGGER) {
- /**
- * Ensures that the logging message contains the name of the exclusive properties.
- */
- @Override
- protected void verifyMessage(final String message) {
- assertTrue(message.contains("dataset"));
- assertTrue(message.contains("other"));
- }
- };
+ public final LoggingWatcher loggings = new LoggingWatcher(Context.LOGGER);
+
+ /**
+ * Verifies that no unexpected warning has been emitted in any test defined in this class.
+ */
+ @After
+ public void assertNoUnexpectedLog() {
+ loggings.assertNoUnexpectedLog();
+ }
/**
* Tests the various setter methods. Since they are exclusive properties,
@@ -61,13 +60,15 @@ public final strictfp class DefaultScope
final DefaultScopeDescription metadata = new DefaultScopeDescription();
metadata.setDataset("A dataset");
assertEquals("dataset", "A dataset", metadata.getDataset());
+ loggings.assertNoUnexpectedLog();
- listener.maximumLogCount = 1;
metadata.setOther(new SimpleInternationalString("Other value"));
assertEquals("other", "Other value", String.valueOf(metadata.getOther()));
assertNull("dataset", metadata.getDataset());
+ loggings.assertNextLogContains("dataset", "other");
+ loggings.assertNoUnexpectedLog();
- metadata.setDataset(null); // Expected to be a no-op.
+ metadata.setDataset(null); // Expected to be a no-op.
assertEquals("other", "Other value", String.valueOf(metadata.getOther()));
assertNull("dataset", metadata.getDataset());
Modified: sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/spatial/DefaultGeorectifiedTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/spatial/DefaultGeorectifiedTest.java?rev=1730366&r1=1730365&r2=1730366&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/spatial/DefaultGeorectifiedTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/spatial/DefaultGeorectifiedTest.java [UTF-8] Sun Feb 14 18:20:58 2016
@@ -21,6 +21,7 @@ import org.apache.sis.util.iso.SimpleInt
import org.apache.sis.internal.jaxb.Context;
import org.apache.sis.test.LoggingWatcher;
import org.apache.sis.test.TestCase;
+import org.junit.After;
import org.junit.Rule;
import org.junit.Test;
@@ -37,21 +38,19 @@ import static org.apache.sis.test.Assert
*/
public final strictfp class DefaultGeorectifiedTest extends TestCase {
/**
- * A JUnit {@linkplain Rule rule} for listening to log events. This field is public
- * because JUnit requires us to do so, but should be considered as an implementation
- * details (it should have been a private field).
+ * A JUnit {@link Rule} for listening to log events. This field is public because JUnit requires us to
+ * do so, but should be considered as an implementation details (it should have been a private field).
*/
@Rule
- public final LoggingWatcher listener = new LoggingWatcher(Context.LOGGER) {
- /**
- * Ensures that the logging message contains the name of the exclusive properties.
- */
- @Override
- protected void verifyMessage(final String message) {
- assertTrue(message.contains("checkPointAvailability"));
- assertTrue(message.contains("checkPointDescription"));
- }
- };
+ public final LoggingWatcher loggings = new LoggingWatcher(Context.LOGGER);
+
+ /**
+ * Verifies that no unexpected warning has been emitted in any test defined in this class.
+ */
+ @After
+ public void assertNoUnexpectedLog() {
+ loggings.assertNoUnexpectedLog();
+ }
/**
* Tests {@link DefaultGeorectified#isCheckPointAvailable()} and
@@ -66,11 +65,13 @@ public final strictfp class DefaultGeore
// Setting the description shall set automatically the availability.
metadata.setCheckPointDescription(description);
assertTrue("checkPointAvailability", metadata.isCheckPointAvailable());
+ loggings.assertNoUnexpectedLog();
// Setting the availability flag shall hide the description and logs a message.
- listener.maximumLogCount = 1;
metadata.setCheckPointAvailable(false);
assertNull("checkPointDescription", metadata.getCheckPointDescription());
+ loggings.assertNextLogContains("checkPointDescription", "checkPointAvailability");
+ loggings.assertNoUnexpectedLog();
// Setting the availability flag shall bring back the description.
metadata.setCheckPointAvailable(true);
Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/Code.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/Code.java?rev=1730366&r1=1730365&r2=1730366&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/Code.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/Code.java [UTF-8] Sun Feb 14 18:20:58 2016
@@ -116,7 +116,7 @@ public final class Code {
* an EPSG code has the "EPSG" codespace. Example:
*
* - XML: <gml:identifier codeSpace="IOGP">urn:ogc:def:crs:EPSG::4326</gml:identifier>
- * - ISO: For "EPSG::4326", Identifier.codeSpace = "EPSG" and Identifier.code = "4326".
+ * - ISO: For "EPSG:4326", Identifier.codeSpace = "EPSG" and Identifier.code = "4326".
*
* Apache SIS attempts to organize this apparent contradiction by considering IOGP as the codespace of
* the EPSG codespace, but this interpretation is not likely to be widely used by libraries other than
Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/AuthorityFactories.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/AuthorityFactories.java?rev=1730366&r1=1730365&r2=1730366&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/AuthorityFactories.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/AuthorityFactories.java [UTF-8] Sun Feb 14 18:20:58 2016
@@ -19,6 +19,7 @@ package org.apache.sis.referencing;
import java.util.ServiceLoader;
import java.util.logging.Level;
import java.util.logging.LogRecord;
+import java.sql.SQLTransientException;
import org.opengis.util.FactoryException;
import org.opengis.referencing.AuthorityFactory;
import org.opengis.referencing.cs.CSAuthorityFactory;
@@ -30,6 +31,7 @@ import org.apache.sis.internal.system.Lo
import org.apache.sis.internal.system.Modules;
import org.apache.sis.internal.system.SystemListener;
import org.apache.sis.referencing.factory.MultiAuthoritiesFactory;
+import org.apache.sis.referencing.factory.UnavailableFactoryException;
import org.apache.sis.referencing.factory.sql.EPSGFactory;
import org.apache.sis.util.logging.Logging;
@@ -108,9 +110,7 @@ final class AuthorityFactories<T extends
if (factory == null) try {
factory = new EPSGFactory(null);
} catch (FactoryException e) {
- final LogRecord record = new LogRecord(Level.CONFIG, e.getLocalizedMessage());
- record.setLoggerName(Loggers.CRS_FACTORY);
- Logging.log(CRS.class, "getAuthorityFactory", record);
+ log(Level.CONFIG, e);
factory = EPSGFactoryFallback.INSTANCE;
}
EPSG[0] = factory;
@@ -119,13 +119,65 @@ final class AuthorityFactories<T extends
}
/**
- * Returns the EPSG factory. This method tries to instantiate an {@link EPSGFactory} if possible,
- * or an {@link EPSGFactoryFallback} otherwise.
+ * Returns the fallback to use if the authority factory is not available. Unless the problem may be temporary,
+ * this method replaces the {@link EPSGFactory} instance by {@link EPSGFactoryFallback} in order to prevent
+ * the same exception to be thrown and logged on every calls to {@link CRS#forCode(String)}.
+ */
+ static CRSAuthorityFactory fallback(final UnavailableFactoryException e) throws UnavailableFactoryException {
+ final boolean isTransient = (e.getCause() instanceof SQLTransientException);
+ final AuthorityFactory unavailable = e.getUnavailableFactory();
+ final CRSAuthorityFactory factory;
+ synchronized (EPSG) {
+ if (unavailable != EPSG[0]) {
+ throw e; // Exception did not come from a factory that we control.
+ }
+ factory = EPSGFactoryFallback.INSTANCE;
+ if (!isTransient) {
+ ALL.reload();
+ EPSG[0] = factory;
+ }
+ }
+ log(Level.WARNING, e);
+ return factory;
+ }
+
+ /**
+ * Notifies that a factory is unavailable, but without giving a fallback and without logging.
+ * The caller is responsible for logging a warning and to provide its own fallback.
+ */
+ static void failure(final UnavailableFactoryException e) {
+ if (!(e.getCause() instanceof SQLTransientException)) {
+ final AuthorityFactory unavailable = e.getUnavailableFactory();
+ synchronized (EPSG) {
+ if (unavailable == EPSG[0]) {
+ ALL.reload();
+ EPSG[0] = EPSGFactoryFallback.INSTANCE;
+ }
+ }
+ }
+ }
+
+ /**
+ * Logs the given exception at the given level. This method pretends that the logging come from
+ * {@link CRS#getAuthorityFactory(String)}, which is the public facade for {@link #EPSG()}.
+ */
+ private static void log(final Level level, final Exception e) {
+ final LogRecord record = new LogRecord(level, e.getLocalizedMessage());
+ record.setLoggerName(Loggers.CRS_FACTORY);
+ Logging.log(CRS.class, "getAuthorityFactory", record);
+ }
+
+ /**
+ * Invoked by {@link LazySet} for adding the EPSG factory before any other factory fetched by {@code ServiceLoader}.
+ * We put the EPSG factory first because it is often used anyway even for {@code CRS} and {@code AUTO} namespaces.
+ *
+ * <p>This method tries to instantiate an {@link EPSGFactory} if possible,
+ * or an {@link EPSGFactoryFallback} otherwise.</p>
*/
@Override
@SuppressWarnings("unchecked")
protected T[] initialValues() {
- EPSG(); // Force creation of EPSG factory if not already done.
+ EPSG(); // Force EPSGFactory instantiation if not already done.
return (T[]) EPSG;
}
}
Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/CRS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/CRS.java?rev=1730366&r1=1730365&r2=1730366&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/CRS.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/CRS.java [UTF-8] Sun Feb 14 18:20:58 2016
@@ -51,6 +51,7 @@ import org.apache.sis.referencing.crs.De
import org.apache.sis.referencing.crs.DefaultVerticalCRS;
import org.apache.sis.referencing.crs.DefaultCompoundCRS;
import org.apache.sis.metadata.iso.extent.Extents;
+import org.apache.sis.referencing.factory.UnavailableFactoryException;
import org.apache.sis.util.ArgumentChecks;
import org.apache.sis.util.Utilities;
import org.apache.sis.util.Static;
@@ -148,7 +149,11 @@ public final class CRS extends Static {
throws NoSuchAuthorityCodeException, FactoryException
{
ArgumentChecks.ensureNonNull("code", code);
- return AuthorityFactories.ALL.createCoordinateReferenceSystem(code);
+ try {
+ return AuthorityFactories.ALL.createCoordinateReferenceSystem(code);
+ } catch (UnavailableFactoryException e) {
+ return AuthorityFactories.fallback(e).createCoordinateReferenceSystem(code);
+ }
}
/**
Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/CommonCRS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/CommonCRS.java?rev=1730366&r1=1730365&r2=1730366&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/CommonCRS.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/CommonCRS.java [UTF-8] Sun Feb 14 18:20:58 2016
@@ -57,6 +57,7 @@ import org.apache.sis.referencing.crs.De
import org.apache.sis.referencing.crs.DefaultVerticalCRS;
import org.apache.sis.referencing.crs.DefaultGeographicCRS;
import org.apache.sis.referencing.crs.DefaultGeocentricCRS;
+import org.apache.sis.referencing.factory.UnavailableFactoryException;
import org.apache.sis.metadata.iso.citation.Citations;
import org.apache.sis.internal.referencing.provider.TransverseMercator;
import org.apache.sis.internal.referencing.Formulas;
@@ -222,7 +223,7 @@ public enum CommonCRS {
* <tr><th>Semi-minor axis length:</th> <td>6356752 <i>(approximative)</i></td></tr>
* <tr><th>Inverse flattening:</th> <td>298.257222101 <i>(definitive)</i></td></tr>
* <tr><th>Ellipsoid axes unit:</th> <td>{@link SI#METRE}</td></tr>
- * <tr><th>UTM zones:</th> <td>28 to 38 in the North hemisphere</td></tr>
+ * <tr><th>UTM zones:</th> <td>28 to 37 in the North hemisphere</td></tr>
* </table></blockquote>
*
* <div class="note"><b>Note:</b>
@@ -231,7 +232,7 @@ public enum CommonCRS {
* while the {@code "IGNF:MILLER"} authority code uses the GRS80 datum.</div>
*/
ETRS89((short) 4258, (short) 4937, (short) 4936, (short) 6258, (short) 7019, // Geodetic info
- (short) 25800, (short) 0, (byte) 28, (byte) 38), // UTM info
+ (short) 25800, (short) 0, (byte) 28, (byte) 37), // UTM info
/**
* European Datum 1950.
@@ -507,7 +508,7 @@ public enum CommonCRS {
failure(this, "geographic", e);
}
/*
- * All constants defined in this enumeration use the same coordinate system, EPSG::6422.
+ * All constants defined in this enumeration use the same coordinate system, EPSG:6422.
* We will arbitrarily create this CS only for the most frequently created CRS,
* and share that CS instance for all other constants.
*/
@@ -564,7 +565,7 @@ public enum CommonCRS {
}
}
/*
- * All constants defined in this enumeration use the same coordinate system, EPSG::6423.
+ * All constants defined in this enumeration use the same coordinate system, EPSG:6423.
* We will arbitrarily create this CS only for the most frequently created CRS,
* and share that CS instance for all other constants.
*/
@@ -622,7 +623,7 @@ public enum CommonCRS {
}
}
/*
- * All constants defined in this enumeration use the same coordinate system, EPSG::6500.
+ * All constants defined in this enumeration use the same coordinate system, EPSG:6500.
* We will arbitrarily create this CS only for the most frequently created CRS,
* and share that CS instance for all other constants.
*/
@@ -885,7 +886,7 @@ public enum CommonCRS {
}
}
/*
- * All constants defined in this enumeration use the same coordinate system, EPSG::4400.
+ * All constants defined in this enumeration use the same coordinate system, EPSG:4400.
* We will arbitrarily create this CS only for a frequently created CRS, and share that
* CS instance for all other constants.
*/
@@ -1540,6 +1541,9 @@ public enum CommonCRS {
* After invoking this method, the caller will fallback on hard-coded values.
*/
static void failure(final Object caller, final String method, final FactoryException e) {
+ if (e instanceof UnavailableFactoryException) {
+ AuthorityFactories.failure((UnavailableFactoryException) e);
+ }
Logging.unexpectedException(Logging.getLogger(Loggers.CRS_FACTORY), caller.getClass(), method, e);
}
}
Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/EPSGFactoryFallback.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/EPSGFactoryFallback.java?rev=1730366&r1=1730365&r2=1730366&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/EPSGFactoryFallback.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/EPSGFactoryFallback.java [UTF-8] Sun Feb 14 18:20:58 2016
@@ -59,12 +59,6 @@ final class EPSGFactoryFallback extends
static final boolean FORCE_HARDCODED = false;
/**
- * A temporary flag for tests that need to be revisited after the upgrade to the next EPSG database version.
- */
- @Debug
- static final boolean PENDING_NEXT_EPSG = false;
-
- /**
* The singleton instance.
*/
static final CRSAuthorityFactory INSTANCE = new EPSGFactoryFallback();
Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/ConcurrentAuthorityFactory.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/ConcurrentAuthorityFactory.java?rev=1730366&r1=1730365&r2=1730366&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/ConcurrentAuthorityFactory.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/ConcurrentAuthorityFactory.java [UTF-8] Sun Feb 14 18:20:58 2016
@@ -389,8 +389,10 @@ public abstract class ConcurrentAuthorit
if (usage == null) {
final DAO factory = newDataAccess();
if (factory == null) {
- throw new UnavailableFactoryException(Errors.format(
+ UnavailableFactoryException e = new UnavailableFactoryException(Errors.format(
Errors.Keys.FactoryNotFound_1, GeodeticAuthorityFactory.class));
+ e.setUnavailableFactory(this);
+ throw e;
}
usage = new DataAccessRef<>(factory);
}
Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/GeodeticAuthorityFactory.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/GeodeticAuthorityFactory.java?rev=1730366&r1=1730365&r2=1730366&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/GeodeticAuthorityFactory.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/GeodeticAuthorityFactory.java [UTF-8] Sun Feb 14 18:20:58 2016
@@ -103,7 +103,7 @@ public abstract class GeodeticAuthorityF
/**
* Returns all namespaces recognized by this factory. Those namespaces can appear before codes in
- * calls to {@code createFoo(String)} methods, for example {@code "EPSG"} in {@code "EPSG::4326"}.
+ * calls to {@code createFoo(String)} methods, for example {@code "EPSG"} in {@code "EPSG:4326"}.
* Namespaces are case-insensitive.
*
* <p>The namespaces are closely related to the {@linkplain #getAuthority() authority}. Often the namespace is
@@ -115,7 +115,7 @@ public abstract class GeodeticAuthorityF
* <li>The {@link org.apache.sis.referencing.factory.sql.EPSGFactory} authority identifier is {@code "EPSG"}
* and its {@code getCodeSpaces()} method returns a set containing {@code "EPSG"}. So in this example,
* authority and namespace match. That namespace value means that {@code EPSGFactory.createFoo(String)}
- * methods accept both {@code "EPSG::4326"} (case-insensitive) and {@code "4326"} codes as argument.</li>
+ * methods accept both {@code "EPSG:4326"} (case-insensitive) and {@code "4326"} codes as argument.</li>
*
* <li>The {@link org.apache.sis.referencing.factory.sql.EPSGDataAccess} authority identifier is {@code "EPSG"}
* but its {@code getCodeSpaces()} method returns an empty set. This means that despite the EPSG authority,
@@ -198,15 +198,15 @@ public abstract class GeodeticAuthorityF
* Two frequently used authorities are "CRS" and "EPSG", which include the following codes:
*
* <table class="sis" summary="Authority codes examples">
- * <tr><th>Code</th> <th>Type</th> <th>Description</th></tr>
- * <tr><td>CRS:84</td> <td>Geographic</td> <td>Like EPSG::4326 except for (<var>longitude</var>, <var>latitude</var>) axis order</td></tr>
- * <tr><td>EPSG::4326</td> <td>Geographic</td> <td>World Geodetic System 1984</td></tr>
- * <tr><td>EPSG::4979</td> <td>Geographic 3D</td> <td>World Geodetic System 1984</td></tr>
- * <tr><td>EPSG::4978</td> <td>Geocentric</td> <td>World Geodetic System 1984</td></tr>
- * <tr><td>EPSG::3395</td> <td>Projected</td> <td>WGS 84 / World Mercator</td></tr>
- * <tr><td>EPSG::5714</td> <td>Vertical</td> <td>Mean Sea Level height</td></tr>
- * <tr><td>EPSG::6349</td> <td>Compound</td> <td>NAD83(2011) + NAVD88 height</td></tr>
- * <tr><td>EPSG::5800</td> <td>Engineering</td> <td>Astra Minas Grid</td></tr>
+ * <tr><th>Code</th> <th>Type</th> <th>Description</th></tr>
+ * <tr><td>CRS:84</td> <td>Geographic</td> <td>Like EPSG:4326 except for (<var>longitude</var>, <var>latitude</var>) axis order</td></tr>
+ * <tr><td>EPSG:4326</td> <td>Geographic</td> <td>World Geodetic System 1984</td></tr>
+ * <tr><td>EPSG:4979</td> <td>Geographic 3D</td> <td>World Geodetic System 1984</td></tr>
+ * <tr><td>EPSG:4978</td> <td>Geocentric</td> <td>World Geodetic System 1984</td></tr>
+ * <tr><td>EPSG:3395</td> <td>Projected</td> <td>WGS 84 / World Mercator</td></tr>
+ * <tr><td>EPSG:5714</td> <td>Vertical</td> <td>Mean Sea Level height</td></tr>
+ * <tr><td>EPSG:6349</td> <td>Compound</td> <td>NAD83(2011) + NAVD88 height</td></tr>
+ * <tr><td>EPSG:5800</td> <td>Engineering</td> <td>Astra Minas Grid</td></tr>
* </table></div>
*
* <div class="section">Default implementation</div>
@@ -238,20 +238,20 @@ public abstract class GeodeticAuthorityF
* Two frequently used authorities are "CRS" and "EPSG", which include the following codes:
*
* <table class="sis" summary="Authority codes examples">
- * <tr><th>Code</th> <th>Type</th> <th>Description</th></tr>
- * <tr><td>CRS:27</td> <td>Geographic</td> <td>Like EPSG::4267 except for (<var>longitude</var>, <var>latitude</var>) axis order</td></tr>
- * <tr><td>CRS:83</td> <td>Geographic</td> <td>Like EPSG::4269 except for (<var>longitude</var>, <var>latitude</var>) axis order</td></tr>
- * <tr><td>CRS:84</td> <td>Geographic</td> <td>Like EPSG::4326 except for (<var>longitude</var>, <var>latitude</var>) axis order</td></tr>
- * <tr><td>EPSG::4322</td> <td>Geographic</td> <td>World Geodetic System 1972</td></tr>
- * <tr><td>EPSG::4985</td> <td>Geographic 3D</td> <td>World Geodetic System 1972</td></tr>
- * <tr><td>EPSG::4326</td> <td>Geographic</td> <td>World Geodetic System 1984</td></tr>
- * <tr><td>EPSG::4979</td> <td>Geographic 3D</td> <td>World Geodetic System 1984</td></tr>
- * <tr><td>EPSG::4267</td> <td>Geographic</td> <td>North American Datum 1927</td></tr>
- * <tr><td>EPSG::4269</td> <td>Geographic</td> <td>North American Datum 1983</td></tr>
- * <tr><td>EPSG::4230</td> <td>Geographic</td> <td>European Datum 1950</td></tr>
- * <tr><td>EPSG::4258</td> <td>Geographic</td> <td>European Terrestrial Reference Frame 1989</td></tr>
- * <tr><td>EPSG::4937</td> <td>Geographic 3D</td> <td>European Terrestrial Reference Frame 1989</td></tr>
- * <tr><td>EPSG::4047</td> <td>Geographic</td> <td>GRS 1980 Authalic Sphere</td></tr>
+ * <tr><th>Code</th> <th>Type</th> <th>Description</th></tr>
+ * <tr><td>CRS:27</td> <td>Geographic</td> <td>Like EPSG:4267 except for (<var>longitude</var>, <var>latitude</var>) axis order</td></tr>
+ * <tr><td>CRS:83</td> <td>Geographic</td> <td>Like EPSG:4269 except for (<var>longitude</var>, <var>latitude</var>) axis order</td></tr>
+ * <tr><td>CRS:84</td> <td>Geographic</td> <td>Like EPSG:4326 except for (<var>longitude</var>, <var>latitude</var>) axis order</td></tr>
+ * <tr><td>EPSG:4322</td> <td>Geographic</td> <td>World Geodetic System 1972</td></tr>
+ * <tr><td>EPSG:4985</td> <td>Geographic 3D</td> <td>World Geodetic System 1972</td></tr>
+ * <tr><td>EPSG:4326</td> <td>Geographic</td> <td>World Geodetic System 1984</td></tr>
+ * <tr><td>EPSG:4979</td> <td>Geographic 3D</td> <td>World Geodetic System 1984</td></tr>
+ * <tr><td>EPSG:4267</td> <td>Geographic</td> <td>North American Datum 1927</td></tr>
+ * <tr><td>EPSG:4269</td> <td>Geographic</td> <td>North American Datum 1983</td></tr>
+ * <tr><td>EPSG:4230</td> <td>Geographic</td> <td>European Datum 1950</td></tr>
+ * <tr><td>EPSG:4258</td> <td>Geographic</td> <td>European Terrestrial Reference Frame 1989</td></tr>
+ * <tr><td>EPSG:4937</td> <td>Geographic 3D</td> <td>European Terrestrial Reference Frame 1989</td></tr>
+ * <tr><td>EPSG:4047</td> <td>Geographic</td> <td>GRS 1980 Authalic Sphere</td></tr>
* </table></div>
*
* <div class="section">Default implementation</div>
@@ -282,10 +282,10 @@ public abstract class GeodeticAuthorityF
* A frequently used authority is "EPSG", which includes the following codes:
*
* <table class="sis" summary="Authority codes examples">
- * <tr><th>Code</th> <th>Description</th></tr>
- * <tr><td>EPSG::4936</td> <td>European Terrestrial Reference Frame 1989</td></tr>
- * <tr><td>EPSG::4978</td> <td>World Geodetic System 1984</td></tr>
- * <tr><td>EPSG::4984</td> <td>World Geodetic System 1972</td></tr>
+ * <tr><th>Code</th> <th>Description</th></tr>
+ * <tr><td>EPSG:4936</td> <td>European Terrestrial Reference Frame 1989</td></tr>
+ * <tr><td>EPSG:4978</td> <td>World Geodetic System 1984</td></tr>
+ * <tr><td>EPSG:4984</td> <td>World Geodetic System 1972</td></tr>
* </table></div>
*
* <div class="section">Default implementation</div>
@@ -317,10 +317,10 @@ public abstract class GeodeticAuthorityF
* Some of them are:
*
* <table class="sis" summary="Authority codes examples">
- * <tr><th>Code</th> <th>Description</th></tr>
- * <tr><td>EPSG::3034</td> <td>ETRS89 / Lambert Conic Conformal Europe</td></tr>
- * <tr><td>EPSG::3395</td> <td>WGS 84 / World Mercator</td></tr>
- * <tr><td>EPSG::6350</td> <td>NAD83(2011) / Conus Albers Equal Area</td></tr>
+ * <tr><th>Code</th> <th>Description</th></tr>
+ * <tr><td>EPSG:3034</td> <td>ETRS89 / Lambert Conic Conformal Europe</td></tr>
+ * <tr><td>EPSG:3395</td> <td>WGS 84 / World Mercator</td></tr>
+ * <tr><td>EPSG:6350</td> <td>NAD83(2011) / Conus Albers Equal Area</td></tr>
* </table></div>
*
* <div class="section">Default implementation</div>
@@ -349,9 +349,9 @@ public abstract class GeodeticAuthorityF
* A frequently used authority is "EPSG", which includes the following codes:
*
* <table class="sis" summary="Authority codes examples">
- * <tr><th>Code</th> <th>Description</th></tr>
- * <tr><td>EPSG::5715</td> <td>Mean Sea Level depth</td></tr>
- * <tr><td>EPSG::5714</td> <td>Mean Sea Level height</td></tr>
+ * <tr><th>Code</th> <th>Description</th></tr>
+ * <tr><td>EPSG:5715</td> <td>Mean Sea Level depth</td></tr>
+ * <tr><td>EPSG:5714</td> <td>Mean Sea Level height</td></tr>
* </table></div>
*
* <div class="section">Default implementation</div>
@@ -398,9 +398,9 @@ public abstract class GeodeticAuthorityF
* A frequently used authority is "EPSG", which includes the following codes:
*
* <table class="sis" summary="Authority codes examples">
- * <tr><th>Code</th> <th>Description</th></tr>
- * <tr><td>EPSG::6349</td> <td>NAD83(2011) + NAVD88 height</td></tr>
- * <tr><td>EPSG::7423</td> <td>ETRS89 + EVRF2007 height</td></tr>
+ * <tr><th>Code</th> <th>Description</th></tr>
+ * <tr><td>EPSG:6349</td> <td>NAD83(2011) + NAVD88 height</td></tr>
+ * <tr><td>EPSG:7423</td> <td>ETRS89 + EVRF2007 height</td></tr>
* </table></div>
*
* <div class="section">Default implementation</div>
@@ -446,8 +446,8 @@ public abstract class GeodeticAuthorityF
* A frequently used authority is "EPSG", which includes the following codes:
*
* <table class="sis" summary="Authority codes examples">
- * <tr><th>Code</th> <th>Description</th></tr>
- * <tr><td>EPSG::5800</td> <td>Astra Minas Grid</td></tr>
+ * <tr><th>Code</th> <th>Description</th></tr>
+ * <tr><td>EPSG:5800</td> <td>Astra Minas Grid</td></tr>
* </table></div>
*
* <div class="section">Default implementation</div>
@@ -496,12 +496,12 @@ public abstract class GeodeticAuthorityF
* A frequently used authority is "EPSG", which contains hundred of datum. Some of them are:
*
* <table class="sis" summary="Authority codes examples">
- * <tr><th>Code</th> <th>Type</th> <th>Description</th></tr>
- * <tr><td>EPSG::6326</td> <td>Geodetic</td> <td>World Geodetic System 1984</td></tr>
- * <tr><td>EPSG::6322</td> <td>Geodetic</td> <td>World Geodetic System 1972</td></tr>
- * <tr><td>EPSG::1027</td> <td>Vertical</td> <td>EGM2008 geoid</td></tr>
- * <tr><td>EPSG::5100</td> <td>Vertical</td> <td>Mean Sea Level</td></tr>
- * <tr><td>EPSG::9315</td> <td>Engineering</td> <td>Seismic bin grid datum</td></tr>
+ * <tr><th>Code</th> <th>Type</th> <th>Description</th></tr>
+ * <tr><td>EPSG:6326</td> <td>Geodetic</td> <td>World Geodetic System 1984</td></tr>
+ * <tr><td>EPSG:6322</td> <td>Geodetic</td> <td>World Geodetic System 1972</td></tr>
+ * <tr><td>EPSG:1027</td> <td>Vertical</td> <td>EGM2008 geoid</td></tr>
+ * <tr><td>EPSG:5100</td> <td>Vertical</td> <td>Mean Sea Level</td></tr>
+ * <tr><td>EPSG:9315</td> <td>Engineering</td> <td>Seismic bin grid datum</td></tr>
* </table></div>
*
* <div class="section">Default implementation</div>
@@ -530,11 +530,11 @@ public abstract class GeodeticAuthorityF
* A frequently used authority is "EPSG", which contains hundred of datum. Some of them are:
*
* <table class="sis" summary="Authority codes examples">
- * <tr><th>Code</th> <th>Description</th></tr>
- * <tr><td>EPSG::6326</td> <td>World Geodetic System 1984</td></tr>
- * <tr><td>EPSG::6322</td> <td>World Geodetic System 1972</td></tr>
- * <tr><td>EPSG::6269</td> <td>North American Datum 1983</td></tr>
- * <tr><td>EPSG::6258</td> <td>European Terrestrial Reference System 1989</td></tr>
+ * <tr><th>Code</th> <th>Description</th></tr>
+ * <tr><td>EPSG:6326</td> <td>World Geodetic System 1984</td></tr>
+ * <tr><td>EPSG:6322</td> <td>World Geodetic System 1972</td></tr>
+ * <tr><td>EPSG:6269</td> <td>North American Datum 1983</td></tr>
+ * <tr><td>EPSG:6258</td> <td>European Terrestrial Reference System 1989</td></tr>
* </table></div>
*
* <div class="section">Default implementation</div>
@@ -564,11 +564,11 @@ public abstract class GeodeticAuthorityF
* A frequently used authority is "EPSG", which includes the following codes:
*
* <table class="sis" summary="Authority codes examples">
- * <tr><th>Code</th> <th>Description</th></tr>
- * <tr><td>EPSG::5100</td> <td>Mean Sea Level</td></tr>
- * <tr><td>EPSG::1027</td> <td>EGM2008 geoid</td></tr>
- * <tr><td>EPSG::1131</td> <td>Japanese Geodetic Datum 2011 (vertical)</td></tr>
- * <tr><td>EPSG::5215</td> <td>European Vertical Reference Frame 2007</td></tr>
+ * <tr><th>Code</th> <th>Description</th></tr>
+ * <tr><td>EPSG:5100</td> <td>Mean Sea Level</td></tr>
+ * <tr><td>EPSG:1027</td> <td>EGM2008 geoid</td></tr>
+ * <tr><td>EPSG:1131</td> <td>Japanese Geodetic Datum 2011 (vertical)</td></tr>
+ * <tr><td>EPSG:5215</td> <td>European Vertical Reference Frame 2007</td></tr>
* </table></div>
*
* <div class="section">Default implementation</div>
@@ -617,9 +617,9 @@ public abstract class GeodeticAuthorityF
* A frequently used authority is "EPSG", which includes the following codes:
*
* <table class="sis" summary="Authority codes examples">
- * <tr><th>Code</th> <th>Description</th></tr>
- * <tr><td>EPSG::9315</td> <td>Seismic bin grid datum</td></tr>
- * <tr><td>EPSG::9300</td> <td>Astra Minas</td></tr>
+ * <tr><th>Code</th> <th>Description</th></tr>
+ * <tr><td>EPSG:9315</td> <td>Seismic bin grid datum</td></tr>
+ * <tr><td>EPSG:9300</td> <td>Astra Minas</td></tr>
* </table></div>
*
* <div class="section">Default implementation</div>
@@ -667,10 +667,10 @@ public abstract class GeodeticAuthorityF
* A frequently used authority is "EPSG", which includes the following codes:
*
* <table class="sis" summary="Authority codes examples">
- * <tr><th>Code</th> <th>Description</th></tr>
- * <tr><td>EPSG::7030</td> <td>WGS 84</td></tr>
- * <tr><td>EPSG::7034</td> <td>Clarke 1880</td></tr>
- * <tr><td>EPSG::7048</td> <td>GRS 1980 Authalic Sphere</td></tr>
+ * <tr><th>Code</th> <th>Description</th></tr>
+ * <tr><td>EPSG:7030</td> <td>WGS 84</td></tr>
+ * <tr><td>EPSG:7034</td> <td>Clarke 1880</td></tr>
+ * <tr><td>EPSG:7048</td> <td>GRS 1980 Authalic Sphere</td></tr>
* </table></div>
*
* <div class="section">Default implementation</div>
@@ -698,12 +698,12 @@ public abstract class GeodeticAuthorityF
* A frequently used authority is "EPSG", which includes the following codes:
*
* <table class="sis" summary="Authority codes examples">
- * <tr><th>Code</th> <th>Description</th></tr>
- * <tr><td>EPSG::8901</td> <td>Greenwich</td></tr>
- * <tr><td>EPSG::8903</td> <td>Paris</td></tr>
- * <tr><td>EPSG::8904</td> <td>Bogota</td></tr>
- * <tr><td>EPSG::8905</td> <td>Madrid</td></tr>
- * <tr><td>EPSG::8906</td> <td>Rome</td></tr>
+ * <tr><th>Code</th> <th>Description</th></tr>
+ * <tr><td>EPSG:8901</td> <td>Greenwich</td></tr>
+ * <tr><td>EPSG:8903</td> <td>Paris</td></tr>
+ * <tr><td>EPSG:8904</td> <td>Bogota</td></tr>
+ * <tr><td>EPSG:8905</td> <td>Madrid</td></tr>
+ * <tr><td>EPSG:8906</td> <td>Rome</td></tr>
* </table></div>
*
* <div class="section">Default implementation</div>
@@ -731,9 +731,9 @@ public abstract class GeodeticAuthorityF
* A frequently used authority is "EPSG", which includes the following codes:
*
* <table class="sis" summary="Authority codes examples">
- * <tr><th>Code</th> <th>Description</th></tr>
- * <tr><td>EPSG::1262</td> <td>World</td></tr>
- * <tr><td>EPSG::3391</td> <td>World - between 80°S and 84°N</td></tr>
+ * <tr><th>Code</th> <th>Description</th></tr>
+ * <tr><td>EPSG:1262</td> <td>World</td></tr>
+ * <tr><td>EPSG:3391</td> <td>World - between 80°S and 84°N</td></tr>
* </table></div>
*
* <div class="section">Default implementation</div>
@@ -763,12 +763,12 @@ public abstract class GeodeticAuthorityF
* A frequently used authority is "EPSG", which includes the following codes:
*
* <table class="sis" summary="Authority codes examples">
- * <tr><th>Code</th> <th>Type</th> <th>Axes</th> <th>Orientations</th> <th>Unit</th></tr>
- * <tr><td>EPSG::4496</td> <td>Cartesian 2D CS</td> <td>easting, northing (E,N)</td> <td>east, north</td> <td>metre</td></tr>
- * <tr><td>EPSG::6422</td> <td>Ellipsoidal 2D CS</td> <td>latitude, longitude</td> <td>north, east</td> <td>degree</td></tr>
- * <tr><td>EPSG::6423</td> <td>Ellipsoidal 3D CS</td> <td>latitude, longitude, ellipsoidal height</td> <td>north, east, up</td> <td>degree, degree, metre</td></tr>
- * <tr><td>EPSG::6404</td> <td>Spherical 3D CS</td> <td>latitude, longitude, radius</td> <td>north, east, up</td> <td>degree, degree, metre</td></tr>
- * <tr><td>EPSG::6499</td> <td>Vertical CS</td> <td>height (H)</td> <td>up</td> <td>metre</td></tr>
+ * <tr><th>Code</th> <th>Type</th> <th>Axes</th> <th>Orientations</th> <th>Unit</th></tr>
+ * <tr><td>EPSG:4496</td> <td>Cartesian 2D CS</td> <td>easting, northing (E,N)</td> <td>east, north</td> <td>metre</td></tr>
+ * <tr><td>EPSG:6422</td> <td>Ellipsoidal 2D CS</td> <td>latitude, longitude</td> <td>north, east</td> <td>degree</td></tr>
+ * <tr><td>EPSG:6423</td> <td>Ellipsoidal 3D CS</td> <td>latitude, longitude, ellipsoidal height</td> <td>north, east, up</td> <td>degree, degree, metre</td></tr>
+ * <tr><td>EPSG:6404</td> <td>Spherical 3D CS</td> <td>latitude, longitude, radius</td> <td>north, east, up</td> <td>degree, degree, metre</td></tr>
+ * <tr><td>EPSG:6499</td> <td>Vertical CS</td> <td>height (H)</td> <td>up</td> <td>metre</td></tr>
* </table></div>
*
* <div class="section">Default implementation</div>
@@ -796,11 +796,11 @@ public abstract class GeodeticAuthorityF
* A frequently used authority is "EPSG", which includes the following codes:
*
* <table class="sis" summary="Authority codes examples">
- * <tr><th>Code</th> <th>Axes</th> <th>Orientations</th> <th>Unit</th></tr>
- * <tr><td>EPSG::6422</td> <td>latitude, longitude</td> <td>north, east</td> <td>degree</td></tr>
- * <tr><td>EPSG::6424</td> <td>longitude, latitude</td> <td>east, north</td> <td>degree</td></tr>
- * <tr><td>EPSG::6429</td> <td>longitude, latitude</td> <td>east, north</td> <td>radian</td></tr>
- * <tr><td>EPSG::6423</td> <td>latitude, longitude, ellipsoidal height</td> <td>north, east, up</td> <td>degree, degree, metre</td></tr>
+ * <tr><th>Code</th> <th>Axes</th> <th>Orientations</th> <th>Unit</th></tr>
+ * <tr><td>EPSG:6422</td> <td>latitude, longitude</td> <td>north, east</td> <td>degree</td></tr>
+ * <tr><td>EPSG:6424</td> <td>longitude, latitude</td> <td>east, north</td> <td>degree</td></tr>
+ * <tr><td>EPSG:6429</td> <td>longitude, latitude</td> <td>east, north</td> <td>radian</td></tr>
+ * <tr><td>EPSG:6423</td> <td>latitude, longitude, ellipsoidal height</td> <td>north, east, up</td> <td>degree, degree, metre</td></tr>
* </table></div>
*
* <div class="section">Default implementation</div>
@@ -827,9 +827,9 @@ public abstract class GeodeticAuthorityF
* A frequently used authority is "EPSG", which includes the following codes:
*
* <table class="sis" summary="Authority codes examples">
- * <tr><th>Code</th> <th>Axes</th> <th>Orientations</th> <th>Unit</th></tr>
- * <tr><td>EPSG::6498</td> <td>depth (D)</td> <td>down</td> <td>metre</td></tr>
- * <tr><td>EPSG::6499</td> <td>height (H)</td> <td>up</td> <td>metre</td></tr>
+ * <tr><th>Code</th> <th>Axes</th> <th>Orientations</th> <th>Unit</th></tr>
+ * <tr><td>EPSG:6498</td> <td>depth (D)</td> <td>down</td> <td>metre</td></tr>
+ * <tr><td>EPSG:6499</td> <td>height (H)</td> <td>up</td> <td>metre</td></tr>
* </table></div>
*
* <div class="section">Default implementation</div>
@@ -876,11 +876,11 @@ public abstract class GeodeticAuthorityF
* A frequently used authority is "EPSG", which includes the following codes:
*
* <table class="sis" summary="Authority codes examples">
- * <tr><th>Code</th> <th>Axes</th> <th>Orientations</th> <th>Unit</th></tr>
- * <tr><td>EPSG::4406</td> <td>easting, northing (E,N)</td> <td>east, north</td> <td>kilometre</td></tr>
- * <tr><td>EPSG::4496</td> <td>easting, northing (E,N)</td> <td>east, north</td> <td>metre</td></tr>
- * <tr><td>EPSG::4500</td> <td>northing, easting (N,E)</td> <td>north, east</td> <td>metre</td></tr>
- * <tr><td>EPSG::4491</td> <td>westing, northing (W,N)</td> <td>west, north</td> <td>metre</td></tr>
+ * <tr><th>Code</th> <th>Axes</th> <th>Orientations</th> <th>Unit</th></tr>
+ * <tr><td>EPSG:4406</td> <td>easting, northing (E,N)</td> <td>east, north</td> <td>kilometre</td></tr>
+ * <tr><td>EPSG:4496</td> <td>easting, northing (E,N)</td> <td>east, north</td> <td>metre</td></tr>
+ * <tr><td>EPSG:4500</td> <td>northing, easting (N,E)</td> <td>north, east</td> <td>metre</td></tr>
+ * <tr><td>EPSG:4491</td> <td>westing, northing (W,N)</td> <td>west, north</td> <td>metre</td></tr>
* </table></div>
*
* <div class="section">Default implementation</div>
@@ -908,8 +908,8 @@ public abstract class GeodeticAuthorityF
* A frequently used authority is "EPSG", which includes the following codes:
*
* <table class="sis" summary="Authority codes examples">
- * <tr><th>Code</th> <th>Axes</th> <th>Orientations</th> <th>Unit</th></tr>
- * <tr><td>EPSG::6404</td> <td>latitude, longitude, radius</td> <td>north, east, up</td> <td>degree, degree, metre</td></tr>
+ * <tr><th>Code</th> <th>Axes</th> <th>Orientations</th> <th>Unit</th></tr>
+ * <tr><td>EPSG:6404</td> <td>latitude, longitude, radius</td> <td>north, east, up</td> <td>degree, degree, metre</td></tr>
* </table></div>
*
* <div class="section">Default implementation</div>
@@ -974,11 +974,11 @@ public abstract class GeodeticAuthorityF
* A frequently used authority is "EPSG", which includes the following codes:
*
* <table class="sis" summary="Authority codes examples">
- * <tr><th>Code</th> <th>Description</th> <th>Unit</th></tr>
- * <tr><td>EPSG::106</td> <td>Latitude (φ)</td> <td>degree</td></tr>
- * <tr><td>EPSG::107</td> <td>Longitude (λ)</td> <td>degree</td></tr>
- * <tr><td>EPSG::1</td> <td>Easting (E)</td> <td>metre</td></tr>
- * <tr><td>EPSG::2</td> <td>Northing (N)</td> <td>metre</td></tr>
+ * <tr><th>Code</th> <th>Description</th> <th>Unit</th></tr>
+ * <tr><td>EPSG:106</td> <td>Latitude (φ)</td> <td>degree</td></tr>
+ * <tr><td>EPSG:107</td> <td>Longitude (λ)</td> <td>degree</td></tr>
+ * <tr><td>EPSG:1</td> <td>Easting (E)</td> <td>metre</td></tr>
+ * <tr><td>EPSG:2</td> <td>Northing (N)</td> <td>metre</td></tr>
* </table></div>
*
* <div class="section">Default implementation</div>
@@ -1007,12 +1007,12 @@ public abstract class GeodeticAuthorityF
* A frequently used authority is "EPSG", which includes the following codes:
*
* <table class="sis" summary="Authority codes examples">
- * <tr><th>Code</th> <th>Description</th></tr>
- * <tr><td>EPSG::9002</td> <td>decimal degree</td></tr>
- * <tr><td>EPSG::9001</td> <td>metre</td></tr>
- * <tr><td>EPSG::9030</td> <td>kilometre</td></tr>
- * <tr><td>EPSG::1040</td> <td>second</td></tr>
- * <tr><td>EPSG::1029</td> <td>year</td></tr>
+ * <tr><th>Code</th> <th>Description</th></tr>
+ * <tr><td>EPSG:9002</td> <td>decimal degree</td></tr>
+ * <tr><td>EPSG:9001</td> <td>metre</td></tr>
+ * <tr><td>EPSG:9030</td> <td>kilometre</td></tr>
+ * <tr><td>EPSG:1040</td> <td>second</td></tr>
+ * <tr><td>EPSG:1029</td> <td>year</td></tr>
* </table>
*
* See {@link org.apache.sis.measure.Units#valueOfEPSG(int)} for a more complete list of codes.</div>
@@ -1041,12 +1041,12 @@ public abstract class GeodeticAuthorityF
* A frequently used authority is "EPSG", which includes the following codes:
*
* <table class="sis" summary="EPSG codes examples">
- * <tr><th>Code</th> <th>Description</th></tr>
- * <tr><td>EPSG::8801</td> <td>Latitude of natural origin</td></tr>
- * <tr><td>EPSG::8802</td> <td>Longitude of natural origin</td></tr>
- * <tr><td>EPSG::8805</td> <td>Scale factor at natural origin</td></tr>
- * <tr><td>EPSG::8806</td> <td>False easting</td></tr>
- * <tr><td>EPSG::8807</td> <td>False northing</td></tr>
+ * <tr><th>Code</th> <th>Description</th></tr>
+ * <tr><td>EPSG:8801</td> <td>Latitude of natural origin</td></tr>
+ * <tr><td>EPSG:8802</td> <td>Longitude of natural origin</td></tr>
+ * <tr><td>EPSG:8805</td> <td>Scale factor at natural origin</td></tr>
+ * <tr><td>EPSG:8806</td> <td>False easting</td></tr>
+ * <tr><td>EPSG:8807</td> <td>False northing</td></tr>
* </table></div>
*
* <div class="section">Default implementation</div>
@@ -1104,11 +1104,11 @@ public abstract class GeodeticAuthorityF
* A frequently used authority is "EPSG", which includes the following codes:
*
* <table class="sis" summary="EPSG codes examples">
- * <tr><th>Code</th> <th>Description</th></tr>
- * <tr><td>EPSG::1133</td> <td>ED50 to WGS 84 (1)</td></tr>
- * <tr><td>EPSG::1241</td> <td>NAD27 to NAD83 (1)</td></tr>
- * <tr><td>EPSG::1173</td> <td>NAD27 to WGS 84 (4)</td></tr>
- * <tr><td>EPSG::6326</td> <td>NAD83(2011) to NAVD88 height (1)</td></tr>
+ * <tr><th>Code</th> <th>Description</th></tr>
+ * <tr><td>EPSG:1133</td> <td>ED50 to WGS 84 (1)</td></tr>
+ * <tr><td>EPSG:1241</td> <td>NAD27 to NAD83 (1)</td></tr>
+ * <tr><td>EPSG:1173</td> <td>NAD27 to WGS 84 (4)</td></tr>
+ * <tr><td>EPSG:6326</td> <td>NAD83(2011) to NAVD88 height (1)</td></tr>
* </table></div>
*
* <div class="section">Default implementation</div>
Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/IdentifiedObjectSet.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/IdentifiedObjectSet.java?rev=1730366&r1=1730365&r2=1730366&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/IdentifiedObjectSet.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/IdentifiedObjectSet.java [UTF-8] Sun Feb 14 18:20:58 2016
@@ -63,7 +63,7 @@ import org.apache.sis.internal.jdk8.JDK8
* {@code IdentifiedObjectSet} can be used as the set returned by implementations of the
* {@link GeodeticAuthorityFactory#createFromCoordinateReferenceSystemCodes(String, String)} method.
* Deferred creation can have great performance impact since some set may contain as much as 40 entries
- * (e.g. transformations from <cite>"ED50"</cite> (EPSG::4230) to <cite>"WGS 84"</cite> (EPSG::4326))
+ * (e.g. transformations from <cite>"ED50"</cite> (EPSG:4230) to <cite>"WGS 84"</cite> (EPSG:4326))
* while some users only want to look for the first entry.
*
* <div class="section">Exception handling</div>
Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/UnavailableFactoryException.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/UnavailableFactoryException.java?rev=1730366&r1=1730365&r2=1730366&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/UnavailableFactoryException.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/UnavailableFactoryException.java [UTF-8] Sun Feb 14 18:20:58 2016
@@ -16,6 +16,8 @@
*/
package org.apache.sis.referencing.factory;
+import org.opengis.referencing.AuthorityFactory;
+
/**
* Thrown when a factory can not be created because a resource is missing.
@@ -27,7 +29,7 @@ package org.apache.sis.referencing.facto
* By contrast, {@link MissingFactoryResourceException} means that at least one particular object
* can not be created, but other objects may be okay.
*
- * @author Martin Desruisseaux (IRD)
+ * @author Martin Desruisseaux (IRD, Geomatys)
* @since 0.7
* @version 0.7
* @module
@@ -41,6 +43,11 @@ public class UnavailableFactoryException
private static final long serialVersionUID = -661925454228937249L;
/**
+ * The factory that can not perform its work, or {@code null} if unknown.
+ */
+ private AuthorityFactory factory;
+
+ /**
* Construct an exception with no detail message.
*/
public UnavailableFactoryException() {
@@ -69,4 +76,33 @@ public class UnavailableFactoryException
public UnavailableFactoryException(String message, Throwable cause) {
super(message, cause);
}
+
+ /**
+ * Specifies which factory is unavailable. This information can be provided when the exception occurred
+ * at some later stage <em>after</em> the factory construction (never inside the factory constructor),
+ * for example the first time that the factory tried to create an object.
+ *
+ * <div class="note"><b>Example:</b>
+ * {@link org.apache.sis.referencing.factory.sql.EPSGFactory} may have been successfully created with
+ * a valid {@link javax.sql.DataSource}. But the call to {@link javax.sql.DataSource#getConnection()}
+ * happens only later (the first time that user invokes a method requiring a search in the database).
+ * In case of failure to connect to the database, user may discover late that the factory is actually
+ * unavailable. User may want to be informed about which factory is unavailable, for example in order
+ * to remove it from the list of factory managed by {@link MultiAuthoritiesFactory}.</div>
+ *
+ * @param factory The factory which is unavailable.
+ */
+ public void setUnavailableFactory(final AuthorityFactory factory) {
+ this.factory = factory;
+ }
+
+ /**
+ * Returns the factory which has been found unavailable, or {@code null} if unspecified.
+ * See {@link #setUnavailableFactory(AuthorityFactory)} for more details.
+ *
+ * @return The factory that should be considered as unavailable.
+ */
+ public AuthorityFactory getUnavailableFactory() {
+ return factory;
+ }
}
Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java?rev=1730366&r1=1730365&r2=1730366&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java [UTF-8] Sun Feb 14 18:20:58 2016
@@ -1842,7 +1842,7 @@ addURIs: for (int i=0; ; i++) {
DefaultGeographicBoundingBox bbox = null;
if (!Double.isNaN(ymin) || !Double.isNaN(ymax) || !Double.isNaN(xmin) || !Double.isNaN(xmax)) {
/*
- * Fix an error found in EPSG::3790 New Zealand - South Island - Mount Pleasant mc
+ * Fix an error found in EPSG:3790 New Zealand - South Island - Mount Pleasant mc
* for older database (this error is fixed in EPSG database 8.2).
*
* Do NOT apply anything similar for the x axis, because xmin > xmax is not error:
@@ -2168,7 +2168,7 @@ addURIs: for (int i=0; ; i++) {
* Current implementation first checks if {@link Units#valueOfEPSG(int)} can provide a hard-coded unit
* for the given code before to try to parse the information found in the database. This is done that
* way for better support of non-straightforward units like <cite>sexagesimal degrees</cite>
- * (EPSG::9110 and 9111).
+ * (EPSG:9110 and 9111).
*
* <div class="note"><b>Example:</b>
* some EPSG codes for units are:
@@ -2778,7 +2778,7 @@ addURIs: for (int i=0; ; i++) {
} while ((searchTransformations = !searchTransformations) == true);
/*
* Search finished. We may have a lot of coordinate operations
- * (e.g. about 40 for "ED50" (EPSG::4230) to "WGS 84" (EPSG::4326)).
+ * (e.g. about 40 for "ED50" (EPSG:4230) to "WGS 84" (EPSG:4326)).
* Alter the ordering using the information supplied in the supersession table.
*/
final String[] codes = set.getAuthorityCodes();
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=1730366&r1=1730365&r2=1730366&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] Sun Feb 14 18:20:58 2016
@@ -402,6 +402,7 @@ public class EPSGFactory extends Concurr
*/
@Override
protected EPSGDataAccess newDataAccess() throws FactoryException {
+ UnavailableFactoryException exception;
Connection connection = null;
try {
connection = dataSource.getConnection();
@@ -424,17 +425,20 @@ public class EPSGFactory extends Concurr
}
if (tr.isTableFound()) {
return newDataAccess(connection, tr);
+ } else {
+ connection.close();
+ exception = new UnavailableFactoryException(SQLTranslator.tableNotFound(locale));
}
- connection.close();
} catch (Exception e) { // Really want to catch all exceptions here.
if (connection != null) try {
connection.close();
} catch (SQLException e2) {
e.addSuppressed(e2);
}
- throw new UnavailableFactoryException(e.getLocalizedMessage(), e);
+ exception = new UnavailableFactoryException(e.getLocalizedMessage(), e);
}
- throw new UnavailableFactoryException(SQLTranslator.tableNotFound(locale));
+ exception.setUnavailableFactory(this);
+ throw exception;
}
/**
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=1730366&r1=1730365&r2=1730366&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] Sun Feb 14 18:20:58 2016
@@ -42,7 +42,7 @@
* <div class="section">The EPSG dataset</div>
* A widely-used factory is the <a href="http://www.epsg.org">EPSG geodetic dataset</a>.
* EPSG codes are numerical identifiers.
- * For example {@code "EPSG::4326"} is the EPSG identifier for the <cite>"WGS 84"</cite> geographic CRS.
+ * For example {@code "EPSG:4326"} is the EPSG identifier for the <cite>"WGS 84"</cite> geographic CRS.
* As an extension, the Apache SIS implementation accepts names as well as numeric identifiers.
* For example the two following method calls fetch the same object:
*
Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/internal/jaxb/referencing/CC_GeneralOperationParameterTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/internal/jaxb/referencing/CC_GeneralOperationParameterTest.java?rev=1730366&r1=1730365&r2=1730366&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/internal/jaxb/referencing/CC_GeneralOperationParameterTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/internal/jaxb/referencing/CC_GeneralOperationParameterTest.java [UTF-8] Sun Feb 14 18:20:58 2016
@@ -31,7 +31,7 @@ import org.apache.sis.test.XMLTestCase;
import org.apache.sis.test.DependsOn;
import org.apache.sis.test.DependsOnMethod;
import org.apache.sis.test.LoggingWatcher;
-import org.apache.sis.util.logging.Logging;
+import org.junit.After;
import org.junit.Rule;
import org.junit.Test;
@@ -52,19 +52,22 @@ import static org.junit.Assert.*;
public final strictfp class CC_GeneralOperationParameterTest extends XMLTestCase {
/**
* A JUnit rule for listening to log events emitted during execution of {@link #testGroupMergeBecauseExtraParameter()}.
- * This rule verifies that the log message contains the expected information. The expected message is something like
- * "No parameter named "Parameter B" was found".
+ * This rule is used by test methods for verifying that the log message contains the expected information.
+ * The expected message is something like "No parameter named "Parameter B" was found".
*
* <p>This field is public because JUnit requires us to do so, but should be considered as an implementation details
* (it should have been a private field).</p>
*/
@Rule
- public final LoggingWatcher listener = new LoggingWatcher(Logging.getLogger(Loggers.XML)) {
- @Override protected void verifyMessage(final String message) {
- assertTrue(message, message.contains("Parameter B"));
- assertTrue(message, message.contains("Group"));
- }
- };
+ public final LoggingWatcher loggings = new LoggingWatcher(Loggers.XML);
+
+ /**
+ * Verifies that no unexpected warning has been emitted in any test defined in this class.
+ */
+ @After
+ public void assertNoUnexpectedLog() {
+ loggings.assertNoUnexpectedLog();
+ }
/**
* Creates a parameter descriptor as unmarshalled by JAXB, without {@code valueClass}.
@@ -305,7 +308,7 @@ public final strictfp class CC_GeneralOp
create("Parameter A", "Remarks A.", false, 3),
create("Parameter C", "Remarks C.", false, 4));
- listener.maximumLogCount = 1;
+ loggings.assertNoUnexpectedLog();
final ParameterDescriptorGroup merged =
(ParameterDescriptorGroup) CC_GeneralOperationParameter.merge(provided, complete);
assertNotSame(complete, provided);
@@ -313,6 +316,8 @@ public final strictfp class CC_GeneralOp
assertSame ("remarks", complete.getRemarks(), merged.getRemarks());
assertEquals ("minimumOccurs", 1, merged.getMinimumOccurs());
assertEquals ("maximumOccurs", 2, merged.getMaximumOccurs());
+ loggings.assertNextLogContains("Parameter B", "Group");
+ loggings.assertNoUnexpectedLog();
final Iterator<GeneralParameterDescriptor> itc = complete.descriptors().iterator();
final Iterator<GeneralParameterDescriptor> itm = merged .descriptors().iterator();
Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/AuthorityFactoriesTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/AuthorityFactoriesTest.java?rev=1730366&r1=1730365&r2=1730366&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/AuthorityFactoriesTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/AuthorityFactoriesTest.java [UTF-8] Sun Feb 14 18:20:58 2016
@@ -24,7 +24,6 @@ import org.opengis.referencing.crs.CRSAu
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import org.opengis.referencing.crs.GeographicCRS;
import org.apache.sis.util.ComparisonMode;
-import org.apache.sis.util.logging.Logging;
import org.apache.sis.internal.system.Loggers;
import org.apache.sis.internal.util.Constants;
import org.apache.sis.referencing.crs.HardCodedCRS;
@@ -35,6 +34,7 @@ import org.apache.sis.referencing.factor
import org.apache.sis.test.DependsOnMethod;
import org.apache.sis.test.LoggingWatcher;
import org.apache.sis.test.TestCase;
+import org.junit.After;
import org.junit.Rule;
import org.junit.Test;
@@ -51,26 +51,18 @@ import static org.apache.sis.test.Assert
*/
public final strictfp class AuthorityFactoriesTest extends TestCase {
/**
- * A JUnit {@linkplain Rule rule} for listening to log events. This field is public because JUnit requires
- * us to do so, but should be considered as an implementation details (it should have been a private field).
+ * A JUnit {@link Rule} for listening to log events. This field is public because JUnit requires us to
+ * do so, but should be considered as an implementation details (it should have been a private field).
*/
@Rule
- public final LoggingWatcher listener = new Listener();
+ public final LoggingWatcher loggings = new LoggingWatcher(Loggers.CRS_FACTORY);
/**
- * Implementation of the {@link AuthorityFactoriesTest#listener} rule.
+ * Verifies that no unexpected warning has been emitted in any test defined in this class.
*/
- private static final class Listener extends LoggingWatcher {
- /** The logged message. */
- String message;
-
- /** Creates a new log listener. */
- Listener() {super(Logging.getLogger(Loggers.CRS_FACTORY));}
-
- /** Stores the log message. */
- @Override protected void verifyMessage(final String message) {
- this.message = message;
- }
+ @After
+ public void assertNoUnexpectedLog() {
+ loggings.assertNoUnexpectedLog();
}
/**
@@ -108,25 +100,23 @@ public final strictfp class AuthorityFac
public void testVersionedEPSG() throws FactoryException {
final CRSAuthorityFactory factory = AuthorityFactories.ALL;
final GeographicCRS crs = factory.createGeographicCRS("EPSG:4326");
+ loggings.assertNoUnexpectedLog();
- listener.maximumLogCount = 1;
assertSame(crs, factory.createGeographicCRS("urn:ogc:def:crs:EPSG:6.11.2:4326"));
assertSame(crs, factory.createGeographicCRS("urn:ogc:def:crs:EPSG:6.11.2:4326"));
- String message = ((Listener) listener).message;
- assertTrue(message, message.contains("6.11.2"));
+ loggings.assertNextLogContains("6.11.2");
+ loggings.assertNoUnexpectedLog();
- listener.maximumLogCount = 1;
assertSame(crs, factory.createGeographicCRS("urn:ogc:def:crs:EPSG:7.04:4326"));
- message = ((Listener) listener).message;
- assertTrue(message, message.contains("7.04"));
+ loggings.assertNextLogContains("7.04");
+ loggings.assertNoUnexpectedLog();
- listener.maximumLogCount = 1;
assertSame(crs, factory.createGeographicCRS("urn:ogc:def:crs:EPSG:7.10:4326"));
- message = ((Listener) listener).message;
- assertTrue(message, message.contains("7.10"));
+ loggings.assertNextLogContains("7.10");
+ loggings.assertNoUnexpectedLog();
- assertEquals(0, listener.maximumLogCount);
assertSame(crs, factory.createGeographicCRS("urn:ogc:def:crs:EPSG::4326"));
+ loggings.assertNoUnexpectedLog();
}
/**
Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/CRSTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/CRSTest.java?rev=1730366&r1=1730365&r2=1730366&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/CRSTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/CRSTest.java [UTF-8] Sun Feb 14 18:20:58 2016
@@ -84,13 +84,7 @@ public final strictfp class CRSTest exte
verifyForCode(CommonCRS.WGS72 .geographic3D(), "EPSG:4985");
verifyForCode(CommonCRS.ETRS89.geographic3D(), "EPSG:4937");
verifyForCode(CommonCRS.Vertical.MEAN_SEA_LEVEL.crs(), "EPSG:5714");
- /*
- * Following test is skipped when using the EPSG factory because EPSG uses
- * the "Gravity-related depth" axis name while ISO 19111 mandates "Depth".
- */
- if (EPSGFactoryFallback.PENDING_NEXT_EPSG) {
- verifyForCode(CommonCRS.Vertical.DEPTH.crs(), "EPSG:5715");
- }
+ verifyForCode(CommonCRS.Vertical.DEPTH.crs(), "EPSG:5715");
}
/**
Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/CommonCRSTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/CommonCRSTest.java?rev=1730366&r1=1730365&r2=1730366&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/CommonCRSTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/CommonCRSTest.java [UTF-8] Sun Feb 14 18:20:58 2016
@@ -167,9 +167,6 @@ public final strictfp class CommonCRSTes
assertSame (name, crs.getDatum(), e.datum()); // Datum after CRS creation.
assertEquals(name, datumName, datum.getName().getCode());
assertEquals(name, datumType, datum.getVerticalDatumType());
- if (!EPSGFactoryFallback.PENDING_NEXT_EPSG && e == CommonCRS.Vertical.DEPTH) {
- continue; // Pending the renaming of "Gravity-related depth" as "Depth" in EPSG database.
- }
assertEquals(name, axisName, crs.getCoordinateSystem().getAxis(0).getName().getCode());
}
}
Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/EPSGFactoryFallbackTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/EPSGFactoryFallbackTest.java?rev=1730366&r1=1730365&r2=1730366&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/EPSGFactoryFallbackTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/EPSGFactoryFallbackTest.java [UTF-8] Sun Feb 14 18:20:58 2016
@@ -125,9 +125,6 @@ public final strictfp class EPSGFactoryF
final ArrayList<String> codes = new ArrayList<>(EPSGFactoryFallback.INSTANCE.getAuthorityCodes(CoordinateReferenceSystem.class));
Collections.shuffle(codes, TestUtilities.createRandomNumberGenerator());
for (final String code : codes) {
- if (!EPSGFactoryFallback.PENDING_NEXT_EPSG && code.equals("5715")) {
- continue;
- }
final CoordinateReferenceSystem crs = EPSGFactoryFallback.INSTANCE.createCoordinateReferenceSystem(code);
final CoordinateReferenceSystem expected = EPSG.createCoordinateReferenceSystem(code);
assertTrue(code, Utilities.deepEquals(expected, crs, ComparisonMode.DEBUG));
Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultProjectedCRSTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultProjectedCRSTest.java?rev=1730366&r1=1730365&r2=1730366&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultProjectedCRSTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultProjectedCRSTest.java [UTF-8] Sun Feb 14 18:20:58 2016
@@ -33,7 +33,6 @@ import org.apache.sis.internal.referenci
import org.apache.sis.internal.util.Constants;
import org.apache.sis.internal.system.Loggers;
import org.apache.sis.io.wkt.Convention;
-import org.apache.sis.util.logging.Logging;
import org.apache.sis.util.ComparisonMode;
import org.apache.sis.util.LenientComparable;
@@ -43,6 +42,7 @@ import org.apache.sis.test.LoggingWatche
import org.apache.sis.test.DependsOnMethod;
import org.apache.sis.test.DependsOn;
import org.apache.sis.test.XMLTestCase;
+import org.junit.After;
import org.junit.Test;
import org.junit.Rule;
@@ -64,19 +64,23 @@ import static org.apache.sis.test.Refere
public final strictfp class DefaultProjectedCRSTest extends XMLTestCase {
/**
* A JUnit rule for listening to log events emitted during execution of {@link #testWKT1_WithExplicitAxisLength()}.
- * This rule verifies that the message logged contains the expected information. The expected message is something
- * like "Parameter semi_minor could have been omitted but got a value that does not match the WGS84 ellipsoid".
+ * This rule is used by the test methods for verifying that the logged messages contain the expected information.
+ * The expected message is something like "Parameter semi_minor could have been omitted but got a value that does
+ * not match the WGS84 ellipsoid".
*
* <p>This field is public because JUnit requires us to do so, but should be considered as an implementation details
* (it should have been a private field).</p>
*/
@Rule
- public final LoggingWatcher listener = new LoggingWatcher(Logging.getLogger(Loggers.COORDINATE_OPERATION)) {
- @Override protected void verifyMessage(final String message) {
- assertTrue(message, message.contains("semi_minor"));
- assertTrue(message, message.contains("WGS84"));
- }
- };
+ public final LoggingWatcher loggings = new LoggingWatcher(Loggers.COORDINATE_OPERATION);
+
+ /**
+ * Verifies that no unexpected warning has been emitted in any test defined in this class.
+ */
+ @After
+ public void assertNoUnexpectedLog() {
+ loggings.assertNoUnexpectedLog();
+ }
/**
* An XML file in this package containing a projected CRS definition.
@@ -356,7 +360,6 @@ public final strictfp class DefaultProje
@Test
@DependsOnMethod("testWKT1")
public void testWKT1_WithExplicitAxisLength() throws FactoryException {
- listener.maximumLogCount = 1;
final ProjectedCRS crs = new GeodeticObjectBuilder()
.setConversionMethod("Mercator (variant A)")
.setConversionName("Popular Visualisation Pseudo-Mercator")
@@ -386,7 +389,8 @@ public final strictfp class DefaultProje
" AXIS[“Northing”, NORTH]]",
crs);
- assertEquals("A warning should have been logged.", 0, listener.maximumLogCount);
+ loggings.assertNextLogContains("semi_minor", "WGS84");
+ loggings.assertNoUnexpectedLog();
}
/**