Skip to content

Commit

Permalink
Let database properties be loaded from classpath.
Browse files Browse the repository at this point in the history
Implements jpos#287.
  • Loading branch information
alcarraz committed Oct 27, 2023
1 parent 8c47d70 commit 939be2f
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions modules/dbsupport/src/main/java/org/jpos/ee/DB.java
Original file line number Diff line number Diff line change
Expand Up @@ -260,11 +260,16 @@ private Element readMappingElements(String moduleConfig) throws DocumentExceptio

private Properties loadProperties(String filename) throws IOException {
Properties props = new Properties();
final String s = filename.replaceAll("/", "\\" + File.separator);
final File f = new File(s);
if (f.exists()) {
try (FileReader fr = new FileReader(f)) {
props.load(fr);
if (filename.startsWith("jar:") && filename.length()>4) {
ClassLoader cl = Thread.currentThread().getContextClassLoader();
props.load(cl.getResourceAsStream(filename.substring(4)));
} else {
final String s = filename.replaceAll("/", "\\" + File.separator);
final File f = new File(s);
if (f.exists()) {
try (FileReader fr = new FileReader(f)) {
props.load(fr);
}
}
}
return props;
Expand Down

0 comments on commit 939be2f

Please sign in to comment.