Package rife.database

Class Datasources

java.lang.Object
rife.database.Datasources
All Implemented Interfaces:
AutoCloseable

public class Datasources extends Object implements AutoCloseable
Contains a collection of Datasource instances.
Since:
1.0
See Also:
  • Constructor Details

  • Method Details

    • instance

      public static Datasources instance()
      Returns the shared singleton instance of the Datasources class.
      Returns:
      the singleton Datasources instance
      Since:
      1.0
    • getDatasource

      public Datasource getDatasource(String name)
      Retrieves the Datasource that corresponds to a provided name.
      Parameters:
      name - a String that identifies the Datasource that has to be retrieved
      Returns:
      the requested Datasource instance; or

      null if name isn't known

      Since:
      1.0
    • getDatasourceForSelector

      public Datasource getDatasourceForSelector(NameSelector selector, String fallbackName)
      Retrieves the Datasource that corresponds an automatically selected name, or a fallback datasource of none could be found that matches the selected name.
      Parameters:
      selector - a NameSelector that will automatically select a name based on the current environment
      fallbackName - a String that identifies the fallback Datasource that has to be used
      Returns:
      the requested Datasource instance; or

      null if no Datasource could be found

      Since:
      1.0
    • setDatasource

      public void setDatasource(String name, Datasource datasource)
      Stores a Datasource with a provided name to be able to reference it later.
      Parameters:
      name - a String that identifies the Datasource
      datasource - the Datasource instance that has to be stored
      Since:
      1.0
    • getDatasourceNames

      public Collection<String> getDatasourceNames()
      Retrieves a collection of all the Datasource names that are known by this Datasources instance.
      Returns:
      the requested Collection
      Since:
      1.0
    • cleanup

      public void cleanup() throws DatabaseException
      Cleans up all connections that have been reserved by this datasource.
      Throws:
      DatabaseException - when an error occurred during the cleanup
      Since:
      1.0
    • close

      public void close() throws DatabaseException
      Specified by:
      close in interface AutoCloseable
      Throws:
      DatabaseException