Package rife.database
Class Datasources
java.lang.Object
rife.database.Datasources
- All Implemented Interfaces:
AutoCloseable
Contains a collection of
Datasource
instances.- Since:
- 1.0
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
cleanup()
Cleans up all connections that have been reserved by this datasource.void
close()
getDatasource
(String name) Retrieves theDatasource
that corresponds to a provided name.getDatasourceForSelector
(NameSelector selector, String fallbackName) Retrieves theDatasource
that corresponds an automatically selected name, or a fallback datasource of none could be found that matches the selected name.Retrieves a collection of all theDatasource
names that are known by thisDatasources
instance.static Datasources
instance()
Returns the shared singleton instance of theDatasources
class.void
setDatasource
(String name, Datasource datasource) Stores aDatasource
with a provided name to be able to reference it later.
-
Constructor Details
-
Datasources
Creates a new emptyDatasources
instance.- Throws:
DatasourcesException
- Since:
- 1.0
-
-
Method Details
-
instance
Returns the shared singleton instance of theDatasources
class.- Returns:
- the singleton
Datasources
instance - Since:
- 1.0
-
getDatasource
Retrieves theDatasource
that corresponds to a provided name.- Parameters:
name
- aString
that identifies theDatasource
that has to be retrieved- Returns:
- the requested
Datasource
instance; ornull
if name isn't known - Since:
- 1.0
-
getDatasourceForSelector
Retrieves theDatasource
that corresponds an automatically selected name, or a fallback datasource of none could be found that matches the selected name.- Parameters:
selector
- aNameSelector
that will automatically select a name based on the current environmentfallbackName
- aString
that identifies the fallbackDatasource
that has to be used- Returns:
- the requested
Datasource
instance; ornull
if noDatasource
could be found - Since:
- 1.0
-
setDatasource
Stores aDatasource
with a provided name to be able to reference it later.- Parameters:
name
- aString
that identifies theDatasource
datasource
- theDatasource
instance that has to be stored- Since:
- 1.0
-
getDatasourceNames
Retrieves a collection of all theDatasource
names that are known by thisDatasources
instance.- Returns:
- the requested
Collection
- Since:
- 1.0
-
cleanup
Cleans up all connections that have been reserved by this datasource.- Throws:
DatabaseException
- when an error occurred during the cleanup- Since:
- 1.0
-
close
- Specified by:
close
in interfaceAutoCloseable
- Throws:
DatabaseException
-