Class EmbeddedDatabaseFactory

    • Method Detail

      • setDatabaseType

        public void setDatabaseType​(EmbeddedDatabaseType type)
        Set the type of embedded database to use.

        Call this when you wish to configure one of the pre-supported types.

        Defaults to HSQL.

        Parameters:
        type - the database type
      • setDatabaseConfigurer

        public void setDatabaseConfigurer​(EmbeddedDatabaseConfigurer configurer)
        Set the strategy that will be used to configure the embedded database instance.

        Call this when you wish to use an embedded database type not already supported.

      • setDatabasePopulator

        public void setDatabasePopulator​(DatabasePopulator populator)
        Set the strategy that will be used to initialize or populate the embedded database.

        Defaults to null.

      • initDatabase

        protected void initDatabase()
        Hook to initialize the embedded database.

        If the generateUniqueDatabaseName flag has been set to true, the current value of the database name will be overridden with an auto-generated name.

        Subclasses may call this method to force initialization; however, this method should only be invoked once.

        After calling this method, getDataSource() returns the DataSource providing connectivity to the database.

      • shutdownDatabase

        protected void shutdownDatabase()
        Hook to shutdown the embedded database. Subclasses may call this method to force shutdown.

        After calling, getDataSource() returns null.

        Does nothing if no embedded database has been initialized.

      • getDataSource

        @Nullable
        protected final DataSource getDataSource()
        Hook that gets the DataSource that provides the connectivity to the embedded database.

        Returns null if the DataSource has not been initialized or if the database has been shut down. Subclasses may call this method to access the DataSource instance directly.