changeset 178:82bc55666a97

Expose the creation of the SessionFactory to the public to be useful when running without a artifact database. flys-backend/trunk@1486 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Wed, 16 Mar 2011 17:16:27 +0000
parents 31895d24387e
children aaac9c291067
files flys-backend/ChangeLog flys-backend/src/main/java/de/intevation/flys/backend/SessionFactoryProvider.java
diffstat 2 files changed, 26 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/flys-backend/ChangeLog	Wed Mar 16 17:01:55 2011 +0000
+++ b/flys-backend/ChangeLog	Wed Mar 16 17:16:27 2011 +0000
@@ -1,3 +1,9 @@
+2011-03-16	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
+
+	* src/main/java/de/intevation/flys/backend/SessionFactoryProvider.java:
+	  Expose createSessionFactory() as public to be usable without
+	  a artifact database running.
+
 2011-03-16	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
 
 	* src/main/java/de/intevation/flys/utils/FileTools.java: 
--- a/flys-backend/src/main/java/de/intevation/flys/backend/SessionFactoryProvider.java	Wed Mar 16 17:01:55 2011 +0000
+++ b/flys-backend/src/main/java/de/intevation/flys/backend/SessionFactoryProvider.java	Wed Mar 16 17:16:27 2011 +0000
@@ -65,13 +65,30 @@
 
     public static synchronized SessionFactory getSessionFactory() {
         if (sessionFactory == null) {
-            sessionFactory = createSessionFactory();
+            String user =
+                Config.getStringXPath(XPATH_USER, DEFAULT_USER);
+            String password =
+                Config.getStringXPath(XPATH_PASSWORD, DEFAULT_PASSWORD);
+            String dialect =
+                Config.getStringXPath(XPATH_DIALECT, DEFAULT_DIALECT);
+            String driver = 
+                Config.getStringXPath(XPATH_DRIVER, DEFAULT_DRIVER);
+            String url =
+                Config.getStringXPath(XPATH_URL, DEFAULT_URL);
+
+            sessionFactory = createSessionFactory(
+                user, password, dialect, driver, url);
         }
         return sessionFactory;
     }
 
-    private static SessionFactory createSessionFactory() {
-
+    public static SessionFactory createSessionFactory(
+        String user,
+        String password,
+        String dialect,
+        String driver,
+        String url
+    ) {
         Configuration cfg = new Configuration();
 
         // TODO: Use package reflection here.
@@ -92,17 +109,6 @@
         cfg.addAnnotatedClass(Wst.class);
         cfg.addAnnotatedClass(WstQRange.class);
 
-        String user =
-            Config.getStringXPath(XPATH_USER, DEFAULT_USER);
-        String password =
-            Config.getStringXPath(XPATH_PASSWORD, DEFAULT_PASSWORD);
-        String dialect =
-            Config.getStringXPath(XPATH_DIALECT, DEFAULT_DIALECT);
-        String driver = 
-            Config.getStringXPath(XPATH_DRIVER, DEFAULT_DRIVER);
-        String url =
-            Config.getStringXPath(XPATH_URL, DEFAULT_URL);
-
         if (log.isDebugEnabled()) {
             log.debug("user: "    + user);
             log.debug("dialect: " + dialect);

http://dive4elements.wald.intevation.org