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 enum
The kind of providers to test. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ServiceLoader
<DataStoreProvider> The loader to use for searching forDataStoreProvider
implementations. -
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 ProbeProviderPair
Implementation ofprobeContentType(Object)
andopen(Object)
.Creates aDataStore
for reading the given storage.probeContentType
(Object storage) Returns the MIME type of the storage file format, ornull
if 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 forDataStoreProvider
implementations. Note thatServiceLoader
are 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 loadingDataStoreProvider
implementations.
-
-
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, ornull
if unknown or not applicable.- Parameters:
storage
- the input/output object as a URL, file, image input stream, etc..- Returns:
- the storage MIME type, or
null
if unknown or not applicable. - Throws:
DataStoreException
- if an error occurred while opening the storage.
-
open
Creates aDataStore
for reading the given storage. Thestorage
argument can be any of the following types:- A
Path
or aFile
for a file or a directory. - A
URI
or aURL
to a distant resource. - A
CharSequence
interpreted as a filename or a URL. - A
Channel
,DataInput
,InputStream
orReader
. - A
DataSource
or aConnection
to a JDBC database. - Any other
DataStore
-specific object, for exampleinvalid reference
ucar.nc2.NetcdfFile
- An existing
StorageConnector
instance.
- 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 noDataStoreProvider
is 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
-true
for creating aDataStore
, orfalse
if not needed.- Returns:
- the result, or
null
if the format is not recognized andopen
isfalse
. - Throws:
UnsupportedStorageException
- if noDataStoreProvider
is found for a given storage object.DataStoreException
- if an error occurred while opening the storage.
-