Salome HOME
Refactoring continues: UserService is created instead of UserDirectory. Database...
[tools/siman.git] / Workspace / Siman-Common / src / org / splat / dal / dao / kernel / Database.java
index 08642029c5841b005420e2179093d61bd052806c..9f13ef351bb3cdbae9193b92283c248b670a1a08 100644 (file)
@@ -1,4 +1,5 @@
 package org.splat.dal.dao.kernel;
+
 /**
  * 
  * @author    Daniel Brunier-Coulin
@@ -6,14 +7,16 @@ package org.splat.dal.dao.kernel;
  */
 
 import org.hibernate.Session;
-import org.hibernate.SessionFactory;
+import org.splat.service.technical.IndexService;
+import org.splat.service.technical.RepositoryService;
 import org.springframework.beans.BeansException;
 import org.springframework.context.ApplicationContext;
 import org.springframework.context.ApplicationContextAware;
+import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
 import org.apache.log4j.Logger;
 
-
-public abstract class Database implements ApplicationContextAware {
+public abstract class Database extends HibernateDaoSupport implements
+               ApplicationContextAware {
 
        /**
         * The ApplicationContext.
@@ -22,67 +25,51 @@ public abstract class Database implements ApplicationContextAware {
 
        /**
         * Spring will call this method for initialize the applicationContext.
-        * @param ctx the application context
-        * @throws BeansException the BeanException
+        * 
+        * @param ctx
+        *            the application context
+        * @throws BeansException
+        *             the BeanException
         */
-       public void setApplicationContext(final ApplicationContext ctx) throws BeansException {
+       public void setApplicationContext(final ApplicationContext ctx)
+                       throws BeansException {
                _context = ctx;
        }
 
        /**
         * Static for getting the context.
+        * 
         * @return ApplicationContext the application context
         */
        public static ApplicationContext getContext() {
                return _context;
        }
-       
-//     private   static  String          CONFIG_FILE      = "/hibernate.cfg.xml";
-    private   static  SessionFactory  mySessionFactory = null;
 
-    protected final static Logger   logger = Logger.getLogger(Database.class);
-    
-//  ==============================================================================================================================
-//  Public services
-//  ==============================================================================================================================
+       // private static String CONFIG_FILE = "/hibernate.cfg.xml";
+       protected final static Logger logger = Logger.getLogger(Database.class);
 
-    public static Session getSession () {
-//  -----------------------------------        
-      return getInstance().getCurrentSession();
-       }
-       
-//  ==============================================================================================================================
-//  Protected services
-//  ==============================================================================================================================
+       // ==============================================================================================================================
+       // Protected services
+       // ==============================================================================================================================
 
-    protected String getSchemaVersion () {
-//  ------------------------------------
-      return null;//TODO: Get schema version into specific object/table: getIDPool().getSchemaVersion();
-    }
+       protected String getSchemaVersion() {
+               // ------------------------------------
+               return null;// TODO: Get schema version into specific object/table: getIDPool().getSchemaVersion();
+       }
 
-    protected void setSchemaVersion (String version) {
-//  ------------------------------------------------
-//TODO: Set schema version into specific object/table:      myIDpool = new IDPool(version);
-//      getSession().save(myIDpool);
-    }
+       protected void setSchemaVersion(String version) {
+               // ------------------------------------------------
+               // TODO: Set schema version into specific object/table: myIDpool = new IDPool(version);
+               // getSession().save(myIDpool);
+       }
 
-//  ==============================================================================================================================
-//  Private services
-//  ==============================================================================================================================
-       
-    private static SessionFactory getInstance () {
-//  --------------------------------------------
-      if (mySessionFactory == null) {
-//     org.hibernate.cfg.Configuration cfg = new org.hibernate.cfg.Configuration();
-        try {
-               mySessionFactory = getContext().getBean(SessionFactory.class);
-//          cfg.configure();   // The configuration file (hibernate.cfg.xml)) is supposed to be on the classpath
-//          mySessionFactory = cfg.buildSessionFactory();
-        }
-        catch (Exception error) {
-          logger.fatal("Could not initialize the Hibernate configuration, reason:", error);
-        }
-      }
-      return mySessionFactory;
-    }
+       // ==============================================================================================================================
+       // Private services
+       // ==============================================================================================================================
+//{
+//             if (myDB == null) {
+//                     myDB = new Database();
+//             }
+//             return myDB;
+//     }
 }
\ No newline at end of file