jberet / jsr352

Implementation of Jakarta Batch Specification and API
Eclipse Public License 2.0
126 stars 76 forks source link

jberet.properties: extract other database configuration from environment variables #472

Closed DaScheid closed 7 months ago

DaScheid commented 7 months ago

Proposing a similar enhancement to #367 to extract other database configuration parameters from environment variables as well. So based on the environment a different database-url, table-prefix/suffix etc. can be used. E.g.:

db-url = ${DB_URL:jdbc:h2:./target/jberet-repo}
db-user = ${DB_USER}
db-password = ${DB_PASS}
db-table-prefix = ${DB_TABLE_PREFIX:default_prefix}
db-table-suffix = ${DB_TABLE_SUFFIX:default_suffix_123}

This would have the benefit, that jberet would be able to connect to the database in multiple environments without any change to the artifact. A possible scenario might be an additional test-environment with its own database.

One obeservation: The existing regex for extracting the default-values does not allow a colon : (and some other special characters like ; or =) inside the definition of the default-value: https://github.com/jberet/jsr352/blob/a1798cff3ad405e34c700e1e42e2cc7184a2b4b4/jberet-se/src/main/java/org/jberet/se/BatchSEEnvironment.java#L65 Which might be needed when defining default-values for database-urls like: jdbc:h2:mem:jberet;DB_CLOSE_DELAY=-1