Skip to content

Commit

Permalink
#796 Regression of #795: activejdbc_models.properties in Jar of War n…
Browse files Browse the repository at this point in the history
…ot found anymore - restoring ability to search for multiple `activejdbc_models/properties` file
  • Loading branch information
ipolevoy committed Nov 5, 2018
1 parent fc4c030 commit ea27f93
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions activejdbc/src/main/java/org/javalite/activejdbc/Configuration.java
Expand Up @@ -76,21 +76,21 @@ protected Configuration(){
loadConnectionsSpecs();

try {

String modelsFile = Util.readResource("/activejdbc_models.properties");
String[] lines = Util.split(modelsFile, System.getProperty("line.separator"));

for (String line: lines) {
String[] parts = split(line, ':');
String modelName = parts[0];
String dbName = parts[1];
List<String> modelNames = modelsMap.get(dbName);
if (modelNames == null) {
modelNames = new ArrayList<>();
modelsMap.put(dbName, modelNames);
Enumeration<URL> urls = getClass().getClassLoader().getResources("activejdbc_models.properties");
while (urls.hasMoreElements()){
URL url = urls.nextElement();
LogFilter.log(LOGGER, LogLevel.INFO, "Loading models from: {}", url.toExternalForm());
String modelsFile = Util.read(url.openStream());
String[] lines = Util.split(modelsFile, System.getProperty("line.separator"));
for (String line: lines) {
String[] parts = Util.split(line, ':');
String modelName = parts[0];
String dbName = parts[1];
List<String> modelNames = modelsMap.computeIfAbsent(dbName, k -> new ArrayList<>());
modelNames.add(modelName);
}
modelNames.add(modelName);
}

} catch (Exception e) {
throw new InitException(e);
}
Expand Down

0 comments on commit ea27f93

Please sign in to comment.