Skip to content

Commit

Permalink
kie server persistence - allow to add hibernate and javax.persistence…
Browse files Browse the repository at this point in the history
… properties when creating entity manager factory without modifying persistence.xml
  • Loading branch information
mswiderski committed Mar 14, 2017
1 parent 6c48563 commit cf08c33
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
Expand Up @@ -661,6 +661,11 @@ protected Map<String, String> getPersistenceProperties(KieServerConfig config) {
persistenceProperties.put("hibernate.transaction.jta.platform", config.getConfigItemValue(KieServerConstants.CFG_PERSISTANCE_TM, "org.hibernate.service.jta.platform.internal.JBossAppServerJtaPlatform"));
persistenceProperties.put("javax.persistence.jtaDataSource", config.getConfigItemValue(KieServerConstants.CFG_PERSISTANCE_DS, "java:jboss/datasources/ExampleDS"));

System.getProperties().stringPropertyNames()
.stream()
.filter(PersistenceUnitInfoLoader::isValidPersistenceKey)
.forEach(name -> persistenceProperties.put(name, System.getProperty(name)));

return persistenceProperties;
}

Expand Down
Expand Up @@ -149,4 +149,11 @@ public static PersistenceUnitInfo load(InputStream inputStream, InitialContext i
return persistenceUnitInfo;
}

public static Boolean isValidPersistenceKey(String propertyName) {
if (propertyName.startsWith("hibernate.") || propertyName.startsWith("javax.persistence")) {
return true;
}

return false;
}
}

0 comments on commit cf08c33

Please sign in to comment.