Package org.apache.sis.storage
Class DataStoreRegistry
java.lang.Object
org.apache.sis.storage.DataStoreRegistry
Creates
DataStore instances for a given storage object by scanning all providers on the classpath.
Storage objects are typically File or DataSource instances, but can also
be any other objects documented in the StorageConnector class.
API note:
this class is package-private for now in order to get more experience about what could be a good API.
This class may become public in a future SIS version.
Thread safety
The sameDataStoreRegistry instance can be safely used by many threads without synchronization
on the part of the caller.- Since:
- 0.4
- Version:
- 1.1
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static enumThe kind of providers to test. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ServiceLoader<DataStoreProvider>The loader to use for searching forDataStoreProviderimplementations. -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new registry which will look for data stores accessible to the default class loader.DataStoreRegistry(ClassLoader loader) Creates a new registry which will look for data stores accessible to the given class loader. -
Method Summary
Modifier and TypeMethodDescriptionprivate ProbeProviderPairImplementation ofprobeContentType(Object)andopen(Object).Creates aDataStorefor reading the given storage.probeContentType(Object storage) Returns the MIME type of the storage file format, ornullif unknown or not applicable.Returns the list of data store providers available at this method invocation time.
-
Field Details
-
loader
The loader to use for searching forDataStoreProviderimplementations. Note thatServiceLoaderare not thread-safe - usage of this field must be protected in a synchronized block.
-
-
Constructor Details
-
DataStoreRegistry
public DataStoreRegistry()Creates a new registry which will look for data stores accessible to the default class loader. The default is the current thread context class loader, provided that it can access at least the Apache SIS stores. -
DataStoreRegistry
Creates a new registry which will look for data stores accessible to the given class loader.- Parameters:
loader- the class loader to use for loadingDataStoreProviderimplementations.
-
-
Method Details
-
providers
Returns the list of data store providers available at this method invocation time. More providers may be added later if new modules are added on the classpath.- Returns:
- descriptions of available data stores.
- Since:
- 0.8
-
probeContentType
Returns the MIME type of the storage file format, ornullif unknown or not applicable.- Parameters:
storage- the input/output object as a URL, file, image input stream, etc..- Returns:
- the storage MIME type, or
nullif unknown or not applicable. - Throws:
DataStoreException- if an error occurred while opening the storage.
-
open
Creates aDataStorefor reading the given storage. Thestorageargument can be any of the following types:- A
Pathor aFilefor a file or a directory. - A
URIor aURLto a distant resource. - A
CharSequenceinterpreted as a filename or a URL. - A
Channel,DataInput,InputStreamorReader. - A
DataSourceor aConnectionto a JDBC database. - Any other
DataStore-specific object, for exampleucar.nc2.NetcdfFile. - An existing
StorageConnectorinstance.
- Parameters:
storage- the input/output object as a URL, file, image input stream, etc..- Returns:
- the object to use for reading geospatial data from the given storage.
- Throws:
UnsupportedStorageException- if noDataStoreProvideris found for a given storage object.DataStoreException- if an error occurred while opening the storage.
- A
-
lookup
Implementation ofprobeContentType(Object)andopen(Object).- Parameters:
storage- the input/output object as a URL, file, image input stream, etc..open-truefor creating aDataStore, orfalseif not needed.- Returns:
- the result, or
nullif the format is not recognized andopenisfalse. - Throws:
UnsupportedStorageException- if noDataStoreProvideris found for a given storage object.DataStoreException- if an error occurred while opening the storage.
-