Class Database

java.lang.Object
com.arpnetworking.utility.Database
All Implemented Interfaces:
Launchable

public class Database extends Object implements Launchable
Database instance abstraction across database technologies: HikariCP, Flyway and EBean. NOTE: The current configuration process of mapping to classes and then instantiating components from "safe" configuration is a complete falacy. Only by attempting to apply (e.g. restart) the system with the new configuration can you determine if it is truly safe. Once rewritten that way configuration classes can be eliminated in many cases and the raw Configuration object mapped directly to the consumer of that configuration. For example, in this class we could read a subkey for Hikari thus decoupling our configuration from Hikari's. The same can be done for Flyway by automatically converting a subkey into a Properties instance and giving it to Flyway.
Author:
Ville Koskela (ville dot koskela at inscopemetrics dot com)
  • Constructor Details

    • Database

      public Database(String name, DatabaseConfiguration configuration)
      Public constructor.
      Parameters:
      name - The name of the database instance.
      configuration - Configuration for the database instance.
  • Method Details

    • launch

      public void launch()
      Description copied from interface: Launchable
      Launch the component.
      Specified by:
      launch in interface Launchable
    • shutdown

      public void shutdown()
      Description copied from interface: Launchable
      Shutdown the component.
      Specified by:
      shutdown in interface Launchable
    • getName

      public String getName()
    • getDataSource

      public DataSource getDataSource()
    • getEbeanServer

      public io.ebean.Database getEbeanServer()
    • getFlyway

      public Optional<org.flywaydb.core.Flyway> getFlyway()
    • toString

      public String toString()
      Overrides:
      toString in class Object