Mercurial > dive4elements > river
changeset 179:aaac9c291067
Default connection parameters are now overwritable with system properties.
flys-backend/trunk@1487 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Wed, 16 Mar 2011 17:28:16 +0000 |
parents | 82bc55666a97 |
children | 3908bfb2aa43 |
files | flys-backend/ChangeLog flys-backend/src/main/java/de/intevation/flys/backend/SessionFactoryProvider.java |
diffstat | 2 files changed, 36 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-backend/ChangeLog Wed Mar 16 17:16:27 2011 +0000 +++ b/flys-backend/ChangeLog Wed Mar 16 17:28:16 2011 +0000 @@ -1,3 +1,14 @@ +2011-03-16 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/backend/SessionFactoryProvider.java: + Default connection parameters are now overwritable with + system properties (defaults in brackets): + - user name: flys.backend.user (flys) + - user password: flys.backend.password (flys) + - db dialect: flys.backend.dialect (org.hibernate.dialect.PostgreSQLDialect) + - db driver: flys.backend.driver (org.postgresql.Driver) + - db url: flys.backend.url (jdbc:postgresql://localhost:5432/flys) + 2011-03-16 Sascha L. Teichmann <sascha.teichmann@intevation.de> * src/main/java/de/intevation/flys/backend/SessionFactoryProvider.java:
--- a/flys-backend/src/main/java/de/intevation/flys/backend/SessionFactoryProvider.java Wed Mar 16 17:16:27 2011 +0000 +++ b/flys-backend/src/main/java/de/intevation/flys/backend/SessionFactoryProvider.java Wed Mar 16 17:28:16 2011 +0000 @@ -47,16 +47,26 @@ public static final String XPATH_URL = "/artifact-database/backend-database/url/text()"; - public static final String DEFAULT_USER = "flys"; - public static final String DEFAULT_PASSWORD = "flys"; - public static final String DEFAULT_DIALECT = - "org.hibernate.dialect.PostgreSQLDialect"; + public static final String DEFAULT_USER = + System.getProperty("flys.backend.user", "flys"); + + public static final String DEFAULT_PASSWORD = + System.getProperty("flys.backend.password", "flys"); + + public static final String DEFAULT_DIALECT = + System.getProperty( + "flys.backend.dialect", + "org.hibernate.dialect.PostgreSQLDialect"); public static final String DEFAULT_DRIVER = - "org.postgresql.Driver"; + System.getProperty( + "flys.backend.driver", + "org.postgresql.Driver"); public static final String DEFAULT_URL = - "jdbc:postgresql://localhost:5432/flys"; + System.getProperty( + "flys.backend.url", + "jdbc:postgresql://localhost:5432/flys"); private static SessionFactory sessionFactory; @@ -82,6 +92,15 @@ return sessionFactory; } + public static SessionFactory createSessionFactory() { + return createSessionFactory( + DEFAULT_USER, + DEFAULT_PASSWORD, + DEFAULT_DIALECT, + DEFAULT_DRIVER, + DEFAULT_URL); + } + public static SessionFactory createSessionFactory( String user, String password,