Package org.geotools.data.complex
Class DataAccessRegistry
- Object
-
- DataAccessRegistry
-
- All Implemented Interfaces:
Repository
- Direct Known Subclasses:
AppSchemaDataAccessRegistry
public class DataAccessRegistry extends Object implements Repository
A registry that stores data access instances per application. This allows feature sources from different data accesses to be accessed globally.- Author:
- Rini Angreani (CSIRO Earth Science and Resource Engineering), Niels Charlier (Curtin University Of Technology)
-
-
Field Summary
Fields Modifier and Type Field Description protected InterpolationProperties
properties
Properties for interpolation / configuration settingsprotected List<DataAccess<FeatureType,Feature>>
registry
Data Access Resourcesprotected static DataAccessRegistry
theRegistry
Singleton instance
-
Constructor Summary
Constructors Modifier Constructor Description protected
DataAccessRegistry()
Sole constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description DataAccess<FeatureType,Feature>
access(Name name)
Search for the DataAccess (may be a DataStore) by name.void
clearProperties()
Clean-up properties, mainly used for cleaning up after testsDataStore
dataStore(Name name)
Search for the DataStore by name.void
disposeAndUnregisterAll()
Dispose and unregister all data accesses in the registry.FeatureSource<FeatureType,Feature>
featureSource(Name name)
Get a feature source for built features with supplied feature type name.Feature
findFeature(FeatureId id, Hints hints)
static DataAccess<FeatureType,Feature>
getDataAccess(Name featureTypeName)
List<DataStore>
getDataStores()
List of available DataStore instances; these are considered to be live/connected datastores under the management of the application and should not be closed or otherwise harmed by client code.static FeatureSource<FeatureType,Feature>
getFeatureSource(Name featureTypeName)
Get a feature source for built features with supplied feature type name.static DataAccessRegistry
getInstance()
Public method to get singleton instance to registry.InterpolationProperties
getProperties()
Get propertiesboolean
hasAccessName(Name name)
Return true if a type name is mapped in one of the registered data accesses.boolean
hasAppSchemaAccessName(Name name)
Return true if a type name is mapped in one of the registered app-schema data accesses.boolean
hasAppSchemaTargetElement(Name name)
Return true if a type name is mapped in one of the registered app-schema data accesses as targetElementName, regardless whether or not mappingName exists.static boolean
hasName(Name featureTypeName)
Return true if a type name is mapped in one of the registered data accesses.FeatureTypeMapping
mappingByElement(Name name)
FeatureTypeMapping
mappingByName(Name name)
Get a feature type mapping from a registered app-schema data access.static void
register(DataAccess<FeatureType,Feature> dataAccess)
Registers a data accessvoid
registerAccess(DataAccess<FeatureType,Feature> dataAccess)
Registers a data accessprotected void
throwDataSourceException(Name featureTypeName)
Throws data source exception if mapping is not found.static void
unregister(DataAccess<FeatureType,Feature> dataAccess)
Unregister a data access.void
unregisterAccess(DataAccess<FeatureType,Feature> dataAccess)
Unregister a data access.static void
unregisterAndDisposeAll()
Unregister * and dispose * all data accesses in the registry.
-
-
-
Field Detail
-
theRegistry
protected static volatile DataAccessRegistry theRegistry
Singleton instance
-
properties
protected InterpolationProperties properties
Properties for interpolation / configuration settings
-
registry
protected List<DataAccess<FeatureType,Feature>> registry
Data Access Resources
-
-
Method Detail
-
getInstance
public static DataAccessRegistry getInstance()
Public method to get singleton instance to registry.- Returns:
- An instance of this class
-
featureSource
public FeatureSource<FeatureType,Feature> featureSource(Name name) throws IOException
Get a feature source for built features with supplied feature type name.- Returns:
- feature source
- Throws:
IOException
-
access
public DataAccess<FeatureType,Feature> access(Name name)
Description copied from interface:Repository
Search for the DataAccess (may be a DataStore) by name.- Specified by:
access
in interfaceRepository
- Parameters:
name
- The Name (namespace and name) to search for- Returns:
- DataAccess
-
dataStore
public DataStore dataStore(Name name)
Description copied from interface:Repository
Search for the DataStore by name.- Specified by:
dataStore
in interfaceRepository
- Parameters:
name
- The typeName (namespace and name) to search for- Returns:
- DataAccess api providing access to the indicatedTypeName (or null if not found)
-
getDataStores
public List<DataStore> getDataStores()
Description copied from interface:Repository
List of available DataStore instances; these are considered to be live/connected datastores under the management of the application and should not be closed or otherwise harmed by client code.- Specified by:
getDataStores
in interfaceRepository
- Returns:
- List of Managed DataStore instances
-
registerAccess
public void registerAccess(DataAccess<FeatureType,Feature> dataAccess)
Registers a data access- Parameters:
dataAccess
- Data access to be registered
-
unregisterAccess
public void unregisterAccess(DataAccess<FeatureType,Feature> dataAccess)
Unregister a data access. This is important especially at the end of test cases, so that the mappings contained in the data access do not conflict with mappings of the same type used in other tests.- Parameters:
dataAccess
- Data access to be unregistered
-
disposeAndUnregisterAll
public void disposeAndUnregisterAll()
Dispose and unregister all data accesses in the registry. This is may be needed to prevent unit tests from conflicting with data accesses with the same type name registered for other tests.
-
hasAccessName
public boolean hasAccessName(Name name) throws IOException
Return true if a type name is mapped in one of the registered data accesses. If the type mapping has mappingName, then it will be the key that is matched in the search. If it doesn't, then it will match the targetElementName.- Parameters:
name
- Feature type name- Throws:
IOException
-
hasAppSchemaAccessName
public boolean hasAppSchemaAccessName(Name name) throws IOException
Return true if a type name is mapped in one of the registered app-schema data accesses. If the type mapping has mappingName, then it will be the key that is matched in the search. If it doesn't, then it will match the targetElementName.- Parameters:
name
- Feature type name- Throws:
IOException
-
mappingByName
public FeatureTypeMapping mappingByName(Name name) throws IOException
Get a feature type mapping from a registered app-schema data access. Please note that this is only possible for app-schema data access instances.- Returns:
- feature type mapping
- Throws:
IOException
-
mappingByElement
public FeatureTypeMapping mappingByElement(Name name) throws IOException
- Throws:
IOException
-
hasAppSchemaTargetElement
public boolean hasAppSchemaTargetElement(Name name) throws IOException
Return true if a type name is mapped in one of the registered app-schema data accesses as targetElementName, regardless whether or not mappingName exists.- Throws:
IOException
-
getProperties
public InterpolationProperties getProperties()
Get properties- Returns:
- properties
-
clearProperties
public void clearProperties()
Clean-up properties, mainly used for cleaning up after tests
-
getFeatureSource
public static FeatureSource<FeatureType,Feature> getFeatureSource(Name featureTypeName) throws IOException
Get a feature source for built features with supplied feature type name.- Returns:
- feature source
- Throws:
IOException
-
getDataAccess
public static DataAccess<FeatureType,Feature> getDataAccess(Name featureTypeName) throws IOException
- Throws:
IOException
-
register
public static void register(DataAccess<FeatureType,Feature> dataAccess)
Registers a data access- Parameters:
dataAccess
- Data access to be registered
-
unregister
public static void unregister(DataAccess<FeatureType,Feature> dataAccess)
Unregister a data access. This is important especially at the end of test cases, so that the mappings contained in the data access do not conflict with mappings of the same type used in other tests. * Does not dispose * This method should not be called directly, instead use dispose method from DataAccess- Parameters:
dataAccess
- Data access to be unregistered
-
unregisterAndDisposeAll
public static void unregisterAndDisposeAll()
Unregister * and dispose * all data accesses in the registry. This is may be needed to prevent unit tests from conflicting with data accesses with the same type name registered for other tests.
-
hasName
public static boolean hasName(Name featureTypeName) throws IOException
Return true if a type name is mapped in one of the registered data accesses. If the type mapping has mappingName, then it will be the key that is matched in the search. If it doesn't, then it will match the targetElementName.- Parameters:
featureTypeName
- Feature type name- Throws:
IOException
-
throwDataSourceException
protected void throwDataSourceException(Name featureTypeName) throws IOException
Throws data source exception if mapping is not found.- Parameters:
featureTypeName
- Name of feature type- Throws:
IOException
-
findFeature
public Feature findFeature(FeatureId id, Hints hints) throws IOException
- Throws:
IOException
-
-