This commit has been excluded from SIS since we do not port the Hints
system,
and the work previously done in FactoryUsingAnsiSQL
(for example) will be merged
directly into EPSGDataAccess
.
Command line:
svn diff --extensions "--unified --ignore-space-change --ignore-all-space --ignore-eol-style" -r26095:26786 https://svn.osgeo.org/geotools/trunk/modules/library/referencing/src/main/java/org/geotools/referencing/factory/epsg/ThreadedEpsgFactory.java
Revision 26095 | Revision 26786 |
---|---|
import java.util.Iterator; import java.util.Comparator; import java.util.Collections; import java.util.logging.Level; import java.util.logging.LogRecord; import javax.imageio.spi.ServiceRegistry; |
import java.util.Iterator;
import java.util.Comparator;
import java.util.Collections;
import java.util.jar.Attributes.Name;
import java.util.logging.Level;
import java.util.logging.LogRecord;
import javax.imageio.spi.ServiceRegistry; |
import org.opengis.referencing.operation.CoordinateOperationAuthorityFactory;
// Geotools dependencies
import org.geotools.factory.JNDI;
import org.geotools.factory.Hints;
import org.geotools.factory.FactoryRegistry;
import org.geotools.metadata.iso.citation.Citations; |
import org.opengis.referencing.operation.CoordinateOperationAuthorityFactory;
// Geotools dependencies
import org.geotools.factory.GeoTools;
import org.geotools.factory.Hints;
import org.geotools.factory.FactoryRegistry;
import org.geotools.metadata.iso.citation.Citations; |
*
* @see #createDataSource
*/
public static final String DATASOURCE_NAME = "jdbc/EPSG"; //TODO: default should be provided by the Hint
/**
* {@code true} if automatic registration of {@link #datasourceName} is allowed. |
*
* @see #createDataSource
*/
public static final String DATASOURCE_NAME = "jdbc/EPSG";
/**
* {@code true} if automatic registration of {@link #datasourceName} is allowed. |
*/ public ThreadedEpsgFactory(final Hints userHints, final int priority) { super(userHints, priority); if (userHints != null) { datasourceName = (String) userHints.get(Hints.EPSG_DATA_SOURCE); } if (datasourceName == null) { datasourceName = DATASOURCE_NAME; } hints.put(Hints.EPSG_DATA_SOURCE, datasourceName); factories = FactoryGroup.createInstance(userHints); setTimeout(30*60*1000L); // Close the connection after at least 30 minutes of inactivity. } |
*/ public ThreadedEpsgFactory(final Hints userHints, final int priority) { super(userHints, priority); Object hint = userHints == null ? null : userHints.get( Hints.EPSG_DATA_SOURCE ); if( hint == null ){ datasourceName = DATASOURCE_NAME; //datasourceName = GeoTools.fixName( DATASOURCE_NAME ); hints.put(Hints.EPSG_DATA_SOURCE, datasourceName); } else if( hint instanceof String ){ datasourceName = (String) hint; //datasourceName = GeoTools.fixName( datasourceName ); hints.put(Hints.EPSG_DATA_SOURCE, datasourceName); } else if (hint instanceof Name ){ Name name = (Name) hint; hints.put( Hints.EPSG_DATA_SOURCE, name ); datasourceName = name.toString(); //datasourceName = GeoTools.fixName( name.toString() ); } else if ( hint instanceof DataSource ){ datasource = (DataSource) hint; hints.put( Hints.EPSG_DATA_SOURCE, datasource ); datasourceName = DATASOURCE_NAME; //datasourceName = GeoTools.fixName( DATASOURCE_NAME ); } factories = FactoryGroup.createInstance(userHints); setTimeout(30*60*1000L); // Close the connection after at least 30 minutes of inactivity. } |
InitialContext context = null;
DataSource source = null;
try {
context = JNDI.getInitialContext(new Hints(hints));
source = (DataSource) context.lookup(datasourceName);
} catch (NoInitialContextException exception) {
// Fall back on 'return null' below. |
InitialContext context = null;
DataSource source = null;
try {
context = GeoTools.getInitialContext(new Hints(hints));
source = (DataSource) context.lookup(datasourceName);
} catch (NoInitialContextException exception) {
// Fall back on 'return null' below. |
* a way to distinguish the two cases. However I'm not sure that it is a robust * criterion. Subclasses should always override as a safety. */ return new AnsiDialectEpsgFactory(hints, connection); } return new AccessDialectEpsgFactory(hints, connection); } /** |
* a way to distinguish the two cases. However I'm not sure that it is a robust * criterion. Subclasses should always override as a safety. */ return new FactoryUsingAnsiSQL(hints, connection); } return new FactoryUsingSQL(hints, connection); } /** |