KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > fenyo > gnetwatch > Synchro


1
2 /*
3  * GNetWatch
4  * Copyright 2006, 2007 Alexandre Fenyo
5  * gnetwatch@fenyo.net
6  *
7  * This file is part of GNetWatch.
8  *
9  * GNetWatch is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * GNetWatch is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with GNetWatch; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22  */

23
24 package net.fenyo.gnetwatch;
25
26 import java.io.*;
27
28
29 import org.hibernate.*;
30 import org.hibernate.cfg.*;
31
32 import org.apache.commons.logging.*;
33
34 /**
35  * This class maintains object-relational mappings.
36  * @author Alexandre Fenyo
37  * @version $Id: Synchro.java,v 1.5 2007/03/03 00:38:20 fenyo Exp $
38  */

39
40 public class Synchro {
41   private static Log log = LogFactory.getLog(Synchro.class);
42   private final Config config;
43
44   /**
45    * Constructor.
46    * Reads the configuration properties from the initialization file.
47    * main thread
48    * @param config configuration.
49    */

50   public Synchro(final Config config) {
51       this.config = config;
52
53       final SessionFactory sessionFactory;
54
55       new Configuration().configure(new File("hibernate.cfg.xml"));
56
57       try {
58         // Création de la SessionFactory à partir de hibernate.cfg.xml
59
sessionFactory = new Configuration().configure(new File("hibernate.cfg.xml")).buildSessionFactory();
60       } catch (Throwable JavaDoc ex) {
61         // Make sure you log the exception, as it might be swallowed
62
System.err.println("Initial SessionFactory creation failed." + ex);
63         throw new ExceptionInInitializerError JavaDoc(ex);
64       }
65       final ThreadLocal JavaDoc session = new ThreadLocal JavaDoc();
66
67   }
68 }
69
Popular Tags