Skip to content

Commit

Permalink
fix(jpa): introduce real defaults for DataSourceDefinition via MPCONF…
Browse files Browse the repository at this point in the history
…IG. IQSS#7980

Previously, with Dataverse software 5.3, the option to configure
the database connection has been moved into the codebase. Admins
can set details via MicroProfile Config.

With updating to Payara 5.2021.4, we can provide default values
for the connection details. Before, this had been tried with adding
them to META-INF/microprofile-config.properties. However, this is
not possible due to the timing of resource creation in the application
server vs. reading the properties file.

IQSS#7980
  • Loading branch information
poikilotherm committed Jun 30, 2021
1 parent c1fd39e commit 859ee1d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,12 @@
// HINT: PGSimpleDataSource would work too, but as we use a connection pool, go with a javax.sql.ConnectionPoolDataSource
// HINT: PGXADataSource is unnecessary (no distributed transactions used) and breaks ingest.
className = "org.postgresql.ds.PGConnectionPoolDataSource",
user = "${MPCONFIG=dataverse.db.user}",

// BEWARE: as this resource is created before defaults are read from META-INF/microprofile-config.properties,
// defaults must be provided in this Payara-proprietary manner.
user = "${MPCONFIG=dataverse.db.user:dataverse}",
password = "${MPCONFIG=dataverse.db.password}",
url = "jdbc:postgresql://${MPCONFIG=dataverse.db.host}:${MPCONFIG=dataverse.db.port}/${MPCONFIG=dataverse.db.name}",
url = "jdbc:postgresql://${MPCONFIG=dataverse.db.host:localhost}:${MPCONFIG=dataverse.db.port:5432}/${MPCONFIG=dataverse.db.name:dataverse}",
// If we ever need to change these pool settings, we need to remove this class and create the resource
// from web.xml. We can use MicroProfile Config in there for these values, impossible to do in the annotation.
//
Expand Down
5 changes: 1 addition & 4 deletions src/main/resources/META-INF/microprofile-config.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
dataverse.db.host=localhost
dataverse.db.port=5432
dataverse.db.user=dataverse
dataverse.db.name=dataverse
# Entries use key=value

0 comments on commit 859ee1d

Please sign in to comment.