Mercurial > dive4elements > river
comparison flys-backend/src/main/java/de/intevation/flys/backend/SessionFactoryProvider.java @ 5564:a2da78fdbec0
Removed obsolete imports.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Fri, 05 Apr 2013 08:59:35 +0200 |
parents | fd7285e3829b |
children |
comparison
equal
deleted
inserted
replaced
5563:673f68bb19a4 | 5564:a2da78fdbec0 |
---|---|
1 package de.intevation.flys.backend; | 1 package de.intevation.flys.backend; |
2 | 2 |
3 import java.lang.management.ManagementFactory; | |
4 | |
5 import java.util.Properties; | 3 import java.util.Properties; |
6 | |
7 import javax.management.InstanceAlreadyExistsException; | |
8 import javax.management.MBeanRegistrationException; | |
9 import javax.management.MBeanServer; | |
10 import javax.management.MalformedObjectNameException; | |
11 import javax.management.NotCompliantMBeanException; | |
12 import javax.management.ObjectName; | |
13 | 4 |
14 import org.apache.log4j.Logger; | 5 import org.apache.log4j.Logger; |
15 | 6 |
16 import org.hibernate.SessionFactory; | 7 import org.hibernate.SessionFactory; |
17 | 8 |
18 import org.hibernate.cfg.Configuration; | 9 import org.hibernate.cfg.Configuration; |
19 import org.hibernate.cfg.Environment; | 10 import org.hibernate.cfg.Environment; |
20 | 11 |
21 import org.hibernate.impl.SessionFactoryImpl; | 12 import org.hibernate.impl.SessionFactoryImpl; |
22 | 13 |
23 import org.hibernate.jmx.StatisticsService; | |
24 | |
25 public final class SessionFactoryProvider | 14 public final class SessionFactoryProvider |
26 { | 15 { |
27 private static Logger log = Logger.getLogger(SessionFactoryProvider.class); | 16 private static Logger log = Logger.getLogger(SessionFactoryProvider.class); |
28 | 17 |
29 public static final boolean ENABLE_JMX = | 18 //public static final boolean ENABLE_JMX = |
30 Boolean.getBoolean("flys.backend.enablejmx"); | 19 // Boolean.getBoolean("flys.backend.enablejmx"); |
31 | 20 |
32 private static SessionFactory flysSessionFactory; | 21 private static SessionFactory flysSessionFactory; |
33 private static SessionFactory sedDBSessionFactory; | 22 private static SessionFactory sedDBSessionFactory; |
34 | 23 |
35 private SessionFactoryProvider() { | 24 private SessionFactoryProvider() { |
64 ) { | 53 ) { |
65 Configuration cfg = createConfiguration(credentials); | 54 Configuration cfg = createConfiguration(credentials); |
66 | 55 |
67 SessionFactory factory = cfg.buildSessionFactory(); | 56 SessionFactory factory = cfg.buildSessionFactory(); |
68 | 57 |
58 /* | |
69 if (ENABLE_JMX) { | 59 if (ENABLE_JMX) { |
70 registerAsMBean(factory); | 60 registerAsMBean(factory); |
71 } | 61 } |
72 else { | 62 else { |
73 log.info("No JMX support for hibernate."); | 63 log.info("No JMX support for hibernate."); |
74 } | 64 } |
65 */ | |
75 | 66 |
76 return factory; | 67 return factory; |
77 } | 68 } |
78 | 69 |
70 /** XXX: Commented out till it is configured correctly. | |
79 public static void registerAsMBean(SessionFactory factory) { | 71 public static void registerAsMBean(SessionFactory factory) { |
80 | 72 |
81 /* XXX: Commented out till it is configured correctly. | 73 // |
82 | 74 |
83 StatisticsService statsMBean = new StatisticsService(); | 75 StatisticsService statsMBean = new StatisticsService(); |
84 statsMBean.setSessionFactory(factory); | 76 statsMBean.setSessionFactory(factory); |
85 statsMBean.setStatisticsEnabled(true); | 77 statsMBean.setStatisticsEnabled(true); |
86 | 78 |
102 log.warn(mbre, mbre); | 94 log.warn(mbre, mbre); |
103 } | 95 } |
104 catch (NotCompliantMBeanException ncmbe) { | 96 catch (NotCompliantMBeanException ncmbe) { |
105 log.warn(ncmbe, ncmbe); | 97 log.warn(ncmbe, ncmbe); |
106 } | 98 } |
107 */ | |
108 } | 99 } |
100 */ | |
109 | 101 |
110 public static Configuration createConfiguration() { | 102 public static Configuration createConfiguration() { |
111 return createConfiguration(FLYSCredentials.getInstance()); | 103 return createConfiguration(FLYSCredentials.getInstance()); |
112 } | 104 } |
113 | 105 |
114 public static Configuration createConfiguration( | 106 public static Configuration createConfiguration( |
115 Credentials credentials | 107 Credentials credentials |
116 ) { | 108 ) { |
117 Configuration cfg = new Configuration(); | 109 Configuration cfg = new Configuration(); |
118 | 110 |
119 for (Class clazz: credentials.getClasses()) { | 111 for (Class<?> clazz: credentials.getClasses()) { |
120 cfg.addAnnotatedClass(clazz); | 112 cfg.addAnnotatedClass(clazz); |
121 } | 113 } |
122 | 114 |
123 if (log.isDebugEnabled()) { | 115 if (log.isDebugEnabled()) { |
124 log.debug("user: " + credentials.getUser()); | 116 log.debug("user: " + credentials.getUser()); |