java.lang.Object
com.irurueta.authserver.bff.infrastructure.session.dev.BffDevDatabase
All Implemented Interfaces:
org.springframework.beans.factory.config.BeanPostProcessor

@Component @Profile("dev") public class BffDevDatabase extends Object implements org.springframework.beans.factory.config.BeanPostProcessor
Points the BFF at its own bff database when, in the dev profile, Spring Boot's Docker Compose support supplies the datasource.

The root compose.yaml runs one PostgreSQL whose POSTGRES_DB is authserver, and the connection details derived from the service always name that database; the init script creates the bff one next to it. Connection details take precedence over spring.datasource.*, so the URL is rewritten here, keeping host, port, user and password exactly as Compose reports them (nothing is committed).

Every JdbcConnectionDetails bean is wrapped, with no test of where it comes from: under the dev profile there is exactly one, the one of Docker Compose, because Spring Boot's own properties-based connection details back off when Compose provides some. This class is inert outside the dev profile.

It is development-only code in src/main, like DevDataInitializer and DevKeyEncryptionSecret of the authorization server, and for the same reason: it cannot live in src/test, because the end-to-end tests run the packaged jar, and so does anyone starting the BFF with the dev profile (java -jar or spring-boot:run); a packaged jar contains no test classes.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    private static final record 
    Connection details of the compose PostgreSQL, addressing the bff database.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    (package private) static final String
    Name of the database of the BFF.
    private static final Pattern
    Database segment of a PostgreSQL JDBC URL: what follows the authority, up to the query string.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    Wraps the JDBC connection details so that they address the bff database; any other bean is returned unchanged.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.springframework.beans.factory.config.BeanPostProcessor

    postProcessAfterInitialization
  • Field Details

    • DATABASE

      static final String DATABASE
      Name of the database of the BFF.
      See Also:
    • DATABASE_SEGMENT

      private static final Pattern DATABASE_SEGMENT
      Database segment of a PostgreSQL JDBC URL: what follows the authority, up to the query string.
  • Constructor Details

    • BffDevDatabase

      public BffDevDatabase()
  • Method Details

    • postProcessBeforeInitialization

      public Object postProcessBeforeInitialization(Object bean, String beanName)
      Wraps the JDBC connection details so that they address the bff database; any other bean is returned unchanged.
      Specified by:
      postProcessBeforeInitialization in interface org.springframework.beans.factory.config.BeanPostProcessor
      Parameters:
      bean - the bean being initialized.
      beanName - the name of the bean.
      Returns:
      the wrapped connection details, or the bean itself.