Class BffDevDatabase
- All Implemented Interfaces:
org.springframework.beans.factory.config.BeanPostProcessor
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 ClassesModifier and TypeClassDescriptionprivate static final recordConnection details of the compose PostgreSQL, addressing thebffdatabase. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionpostProcessBeforeInitialization(Object bean, String beanName) Wraps the JDBC connection details so that they address thebffdatabase; any other bean is returned unchanged.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.beans.factory.config.BeanPostProcessor
postProcessAfterInitialization
-
Field Details
-
DATABASE
Name of the database of the BFF.- See Also:
-
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
Wraps the JDBC connection details so that they address thebffdatabase; any other bean is returned unchanged.- Specified by:
postProcessBeforeInitializationin interfaceorg.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.
-