# HG changeset patch # User Sascha L. Teichmann # Date 1300296496 0 # Node ID aaac9c2910671b4882045f3104c5b5e25859e16c # Parent 82bc55666a979039469bd4f078ddd377b36cc5e5 Default connection parameters are now overwritable with system properties. flys-backend/trunk@1487 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 82bc55666a97 -r aaac9c291067 flys-backend/ChangeLog --- 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 + + * 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 * src/main/java/de/intevation/flys/backend/SessionFactoryProvider.java: diff -r 82bc55666a97 -r aaac9c291067 flys-backend/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,