Class DefaultRepository

  • All Implemented Interfaces:
    Repository

    public class DefaultRepository
    extends Object
    implements Repository
    Default Repository implementation allows GeoTools to manage your DataStores.

    To use this implementation you can "registery" new DataStores:

    • load( File )
    • This also serves as a reminder that we need CrossDataStore functionality - at least for Locks. And possibly for "Query".
    Author:
    Jody Garnett DefaultRepository.java $
    • Field Detail

      • repository

        protected Map<Name,​DataAccess<?,​?>> repository
        Holds the DataStores so we can clean up when closed
    • Constructor Detail

      • DefaultRepository

        public DefaultRepository()
    • Method Detail

      • access

        public DataAccess<?,​?> access​(String name)
      • access

        public DataAccess<?,​?> access​(Name name)
        Description copied from interface: Repository
        Search for the DataAccess (may be a DataStore) by name.
        Specified by:
        access in interface Repository
        Parameters:
        name - The Name (namespace and name) to search for
        Returns:
        DataAccess
      • dataStore

        public DataStore dataStore​(String name)
      • dataStore

        public DataStore dataStore​(Name name)
        Description copied from interface: Repository
        Search for the DataStore by name.
        Specified by:
        dataStore in interface Repository
        Parameters:
        name - The typeName (namespace and name) to search for
        Returns:
        DataAccess api providing access to the indicatedTypeName (or null if not found)
      • load

        public void load​(File propertiesFile)
                  throws Exception
        Load a quick repository from a properties file.

        This is useful for test cases; the format is:

        
         nameA=param=value,param2=value2,...
         nameB=param=value,param2=value2,...
         
        Throws:
        Exception
      • lockExists

        public boolean lockExists​(String lockID)
        Check if a lock exists in any of the DataStores.
      • lockRefresh

        public boolean lockRefresh​(String lockID,
                                   Transaction transaction)
                            throws IOException
        Implement lockRefresh.

        Currently it is an error if the lockID is not found. Because if we can't find it we cannot refresh it.

        Since locks are time sensitive it is impossible to check if a lockExists and then be sure it will still exist when you try to refresh it. Nothing we do can protect client code from this fact, they will need to do with the IOException when (not if) this situation occurs.

        Parameters:
        lockID - Authorizataion of lock to refresh
        transaction - Transaction used to authorize refresh
        Throws:
        IOException - If opperation encounters problems, or lock not found
        IllegalArgumentException - if lockID is null
        See Also:
        org.geotools.data.Catalog#lockRefresh(java.lang.String, Transaction)
      • lockRelease

        public boolean lockRelease​(String lockID,
                                   Transaction transaction)
                            throws IOException
        Implement lockRelease.

        Currently it is not and error if the lockID is not found, it may have expired. Since locks are time sensitive it is impossible to check if a lockExists and then be sure it will still exist when you try to release it.

        Parameters:
        lockID - Authorizataion of lock to refresh
        transaction - Transaction used to authorize refresh
        Throws:
        IOException - If opperation encounters problems
        IllegalArgumentException - if lockID is null
        See Also:
        org.geotools.data.Catalog#lockRefresh(java.lang.String, Transaction)
      • register

        public void register​(String name,
                             DataAccess<?,​?> dataStore)
                      throws IOException
        Register a new DataStore with this registery

        Description ...

        Throws:
        IOException
        See Also:
        org.geotools.data.Catalog#registerDataStore(DataStore)
      • register

        public void register​(Name name,
                             DataAccess<?,​?> dataStore)
                      throws IOException
        Throws:
        IOException
      • datastore

        public DataStore datastore​(String id)
      • source

        public SimpleFeatureSource source​(String dataStoreId,
                                          String typeName)
                                   throws IOException
        Throws:
        IOException
      • getNames

        public Set<Name> getNames()
      • 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 interface Repository
        Returns:
        List of Managed DataStore instances