Package org.apache.sis.setup
Class Configuration
java.lang.Object
org.apache.sis.setup.Configuration
Provides system-wide configuration for Apache SIS library.
Methods in this class can be used for overriding SIS default values.
Those methods can be used in final applications, but should not be used by libraries
in order to avoid interfering with user's settings.
Other system-wide configuration
The following properties are defined by the standard Java environment. Apache SIS does not modify those properties but read them:- Since:
- 1.0
- Version:
- 1.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Configuration
The default configuration instance. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
Do not allow instantiation except by methods in this class. -
Method Summary
Modifier and TypeMethodDescriptionstatic Configuration
current()
Returns the current configuration.Returns the data source for the SIS-wide "SpatialMetadata" database.void
setDatabase
(Supplier<DataSource> source) Specifies the data source to use if no"jdbc/SpatialMetadata"
source is binded to a JNDI environment.
-
Field Details
-
DEFAULT
The default configuration instance. We use instances instead of static methods in case we want different configuration modes in a future Apache SIS version (for example a "strict" mode versus a "lenient" mode), of for allowing configurations to be saved in a file and restored.
-
-
Constructor Details
-
Configuration
private Configuration()Do not allow instantiation except by methods in this class.
-
-
Method Details
-
current
Returns the current configuration.- Returns:
- the current configuration.
-
getDatabase
Returns the data source for the SIS-wide "SpatialMetadata" database. This method returns the first of the following steps that succeed:- If a JNDI context exists, use the data source registered under the
"jdbc/SpatialMetadata"
name. - Otherwise if a default data source has been supplied, use that data source.
- Otherwise if the
SIS_DATA
environment variable is defined, use the data source for"jdbc:derby:$SIS_DATA/Databases/SpatialMetadata"
. That database will be created if it does not exist. Note that this is the only case where Apache SIS may create the database since it is located in the directory managed by Apache SIS. - Otherwise if the
non-free:sis-embedded-data
module is present on the classpath, use the embedded database. - Otherwise if the "
derby.system.home
" property is defined, use the data source for"jdbc:derby:SpatialMetadata"
database. This database will not be created if it does not exist.
- Returns:
- the data source for the
"SpatialMetadata"
database. - Throws:
SQLException
- if an error occurred while fetching the database source.
- If a JNDI context exists, use the data source registered under the
-
setDatabase
Specifies the data source to use if no"jdbc/SpatialMetadata"
source is binded to a JNDI environment. Data source specified by JNDI has precedence over data source specified by this method in order to let users control their data source. The following example shows how to setup a connection to a PostgreSQL database: This method can be invoked only before the first attempt to get the database. If theDataSource
has already be obtained, then this method throwsIllegalStateException
.- Parameters:
source
- supplier of data source to set. The supplier may returnnull
, in which case it will be ignored.- Throws:
IllegalStateException
- ifDataSource
has already be obtained before this method call.- See Also:
-