Skip to content

Commit

Permalink
Minor configuration changes.
Browse files Browse the repository at this point in the history
- Bumped the overlord commons version.
- Support system properties in bootstrap (db config)
  • Loading branch information
EricWittmann committed May 20, 2013
1 parent 8d67f8e commit 792c855
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
Expand Up @@ -33,11 +33,11 @@
*/
public class Bootstrap {

private static final String DB_DRIVER = "db.driver";
private static final String DB_URL = "db.url";
private static final String DB_USER = "db.user";
private static final String DB_PASSWORD = "db.password";
private static final String HIBERNATE_HBM2DDL_AUTO = "hibernate.hbm2ddl.auto";
protected static final String DB_DRIVER = "db.driver";
protected static final String DB_URL = "db.url";
protected static final String DB_USER = "db.user";
protected static final String DB_PASSWORD = "db.password";
protected static final String HIBERNATE_HBM2DDL_AUTO = "hibernate.hbm2ddl.auto";

private EntityManager entityManager;

Expand Down
Expand Up @@ -58,11 +58,23 @@ public CoreModule(EntityManager entityManager) {
try {
is = this.getClass().getClassLoader().getResourceAsStream(DEFAULT_PROPERTIES);
if (is == null) {
System.err.println("Cant locate properties");
System.err.println("Can't locate properties");
throw new IOException("Failed to open " + DEFAULT_PROPERTIES);
}
properties = new Properties();
properties.load(is);

// Now override with system properties
if (System.getProperty(Bootstrap.DB_DRIVER) != null)
properties.put(Bootstrap.DB_DRIVER, System.getProperty(Bootstrap.DB_DRIVER));
if (System.getProperty(Bootstrap.DB_URL) != null)
properties.put(Bootstrap.DB_URL, System.getProperty(Bootstrap.DB_URL));
if (System.getProperty(Bootstrap.DB_USER) != null)
properties.put(Bootstrap.DB_USER, System.getProperty(Bootstrap.DB_USER));
if (System.getProperty(Bootstrap.DB_PASSWORD) != null)
properties.put(Bootstrap.DB_PASSWORD, System.getProperty(Bootstrap.DB_PASSWORD));
if (System.getProperty(Bootstrap.HIBERNATE_HBM2DDL_AUTO) != null)
properties.put(Bootstrap.HIBERNATE_HBM2DDL_AUTO, System.getProperty(Bootstrap.HIBERNATE_HBM2DDL_AUTO));
} catch (IOException e) {
throw new RuntimeException( "Unable to load properties: " + DEFAULT_PROPERTIES);
} finally {
Expand All @@ -72,9 +84,9 @@ public CoreModule(EntityManager entityManager) {
} catch(Exception e) {
System.err.println("closed inputstream error.");
}

}

}
}

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Expand Up @@ -71,7 +71,7 @@
<joda-time.version>2.0</joda-time.version>
<commons-codec.version>1.5</commons-codec.version>
<xerces.version>2.9.1-jbossas-1</xerces.version>
<overlord-commons.version>1.0.6-SNAPSHOT</overlord-commons.version>
<overlord-commons.version>1.0.6</overlord-commons.version>
</properties>

<modules>
Expand Down

0 comments on commit 792c855

Please sign in to comment.