Class ConnectionFactoryInitializer

java.lang.Object
org.springframework.r2dbc.connection.init.ConnectionFactoryInitializer
All Implemented Interfaces:
org.springframework.beans.factory.DisposableBean, org.springframework.beans.factory.InitializingBean

public class ConnectionFactoryInitializer extends Object implements org.springframework.beans.factory.InitializingBean, org.springframework.beans.factory.DisposableBean
Used to set up a database during initialization and clean up a database during destruction.
Since:
5.3
Author:
Dave Syer, Sam Brannen, Mark Paluch
See Also:
  • Constructor Details

    • ConnectionFactoryInitializer

      public ConnectionFactoryInitializer()
  • Method Details

    • setConnectionFactory

      public void setConnectionFactory(ConnectionFactory connectionFactory)
      The ConnectionFactory for the database to populate when this component is initialized and to clean up when this component is shut down.

      This property is mandatory with no default provided.

      Parameters:
      connectionFactory - the R2DBC ConnectionFactory
    • setDatabasePopulator

      public void setDatabasePopulator(DatabasePopulator databasePopulator)
      Set the DatabasePopulator to execute during the bean initialization phase.
      Parameters:
      databasePopulator - the DatabasePopulator to use during initialization
      See Also:
    • setDatabaseCleaner

      public void setDatabaseCleaner(DatabasePopulator databaseCleaner)
      Set the DatabasePopulator to execute during the bean destruction phase, cleaning up the database and leaving it in a known state for others.
      Parameters:
      databaseCleaner - the DatabasePopulator to use during destruction
      See Also:
    • setEnabled

      public void setEnabled(boolean enabled)
      Flag to explicitly enable or disable the database populator and database cleaner.
      Parameters:
      enabled - true if the database populator and database cleaner should be called on startup and shutdown, respectively
    • afterPropertiesSet

      public void afterPropertiesSet()
      Use the database populator to set up the database.
      Specified by:
      afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
    • destroy

      public void destroy()
      Use the database cleaner to clean up the database.
      Specified by:
      destroy in interface org.springframework.beans.factory.DisposableBean