Clover coverage report - JFox Service-Oriented Application Framework - 1.0-M2 Coverage timestamp: 星期四 十一月 25 2004 17:14:11 PST FRAMES NO FRAMES |
file stats: | LOC: | 84 |  | Methods: | 4
| NCLOC: | 40 |  | Classes: | 1
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover
Source file | Conditionals | Statements | Methods | TOTAL
HibernateServiceImpl.java | 25% | 80% | 100% | 73.9% |

1 |  |
     /**
2 |  |
      * JFoxSOAF, Service-Oriented Application Framework
3 |  |
      *
4 |  |
      * Copyright (C) www.huihoo.org
5 |  |
      *
6 |  |
      * Distributable under GNU LGPL
7 |  |
      *
8 |  |
      * For more information, please visit: http://www.huihoo.org/jfox/jfoxsoaf
9 |  |
      */
10 |  |
11 |  |
     package org.huihoo.jfox.soaf.services.persistence;
12 |  |
13 |  |
     import net.sf.hibernate.HibernateException;
14 |  |
     import net.sf.hibernate.Session;
15 |  |
     import net.sf.hibernate.SessionFactory;
16 |  |
     import net.sf.hibernate.cfg.Configuration;
17 |  |
18 |  |
     import org.huihoo.jfox.soaf.services.logging.LoggingService;
19 |  |
20 |  |
     /**
21 |  |
      * <p>
22 |  |
      * Hibernate persistence service implementation.
23 |  |
      * </p>
24 |  |
      *
25 |  |
      * @author <a href="mailto:founder_chen@yahoo.com.cn">Peter Cheng </a>
26 |  |
      * @version $Revision: 1.3 $ $Date: 2004/10/20 14:22:06 $
27 |  |
      * @version Revision: 1.0
28 |  |
      */
29 |  |
30 |  |
     public class HibernateServiceImpl implements HibernateService {
31 |  |
32 |  |
         private LoggingService loggingService;
33 |  |
34 |  |
         private Configuration config;
35 |  |
36 |  |
         private SessionFactory sessionFactory;
37 |  |
38 |  |
         /**
39 |  |
          * @param loggingService
40 |  |
          */
41 | 3 |
         public HibernateServiceImpl(LoggingService loggingService)
42 |  |
                 throws HibernateException {
43 | 3 |
             this.loggingService = loggingService;
44 | 3 |
             config = new Configuration();
45 | 3 |
             config.configure(getClass().getClassLoader().getResource(
46 |  |
                     "hibernate.cfg.xml"));
47 |  |
         }
48 |  |
49 |  |
         /**
50 |  |
          * @see org.huihoo.jfox.soaf.services.persistence.HibernateService#openSession()
51 |  |
          */
52 | 1 |
         public Session openSession() throws HibernateException {
53 | 1 |
             SessionFactory factory = getSessionFactory();
54 | 1 |
             Session session = factory.openSession();
55 | 1 |
             return session;
56 |  |
         }
57 |  |
58 |  |
         /**
59 |  |
          * @see org.huihoo.jfox.soaf.services.persistence.HibernateService#getConfiguration()
60 |  |
          */
61 | 1 |
         public Configuration getConfiguration() throws HibernateException {
62 | 1 |
             return config;
63 |  |
         }
64 |  |
65 |  |
         /**
66 |  |
          * @see org.huihoo.jfox.soaf.services.persistence.HibernateService#getSessionFactory()
67 |  |
          */
68 | 2 |
         public SessionFactory getSessionFactory() throws HibernateException {
69 | 2 |
             if (sessionFactory == null) {
70 | 2 |
                 synchronized (this) {
71 | 2 |
                     try {
72 | 2 |
                         sessionFactory = config.buildSessionFactory();
73 |  |
                     } catch (Throwable t) {
74 | 0 |
                         if (loggingService.isInfoEnabled()) {
75 | 0 |
                             loggingService.info("Could not configure hibernate ");
76 |  |
                         }
77 | 0 |
                         t.printStackTrace();
78 |  |
                     }
79 |  |
                 }
80 |  |
             }
81 | 2 |
             return sessionFactory;
82 |  |
         }
83 |  |
84 |  |
     }