Changeset 37191705f4c8bf1d54efbd9d9aed5e94da379484
- Timestamp:
- 03/02/08 13:14:37
(9 months ago)
- Author:
- Christopher Jung <bktheg@web.de>
- git-committer:
- Christopher Jung <bktheg@web.de> 1204460077 +0100
- git-parent:
[1c1f80d751261481bf2f15b2029807ce27045d8d]
- git-author:
- Christopher Jung <bktheg@web.de> 1204460077 +0100
- Message:
Statistik-MBean von Hibernate wird nun beim Start erstellt
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r32c88d8 |
r3719170 |
|
| 20 | 20 | |
|---|
| 21 | 21 | import java.io.File; |
|---|
| | 22 | import java.util.ArrayList; |
|---|
| 22 | 23 | import java.util.HashSet; |
|---|
| 23 | 24 | import java.util.Iterator; |
|---|
| 24 | 25 | import java.util.Set; |
|---|
| | 26 | |
|---|
| | 27 | import javax.management.MBeanServer; |
|---|
| | 28 | import javax.management.MBeanServerFactory; |
|---|
| | 29 | import javax.management.ObjectName; |
|---|
| 25 | 30 | |
|---|
| 26 | 31 | import net.driftingsouls.ds2.server.framework.Configuration; |
|---|
| … | … | |
| 35 | 40 | import org.hibernate.dialect.function.StandardSQLFunction; |
|---|
| 36 | 41 | import org.hibernate.engine.EntityKey; |
|---|
| | 42 | import org.hibernate.jmx.StatisticsService; |
|---|
| 37 | 43 | import org.hibernate.stat.Statistics; |
|---|
| 38 | 44 | import org.w3c.dom.Document; |
|---|
| … | … | |
| 48 | 54 | |
|---|
| 49 | 55 | private static SessionFactory sessionFactory; |
|---|
| 50 | | private static org.hibernate.cfg.AnnotationConfiguration conf; |
|---|
| | 56 | private static org.hibernate.cfg.AnnotationConfiguration conf; |
|---|
| | 57 | private static StatisticsService statisticsService = null; |
|---|
| 51 | 58 | |
|---|
| 52 | 59 | static { |
|---|
| … | … | |
| 85 | 92 | throw new ExceptionInInitializerError(e); |
|---|
| 86 | 93 | } |
|---|
| | 94 | |
|---|
| | 95 | createStatisticsMBean(); |
|---|
| 87 | 96 | } |
|---|
| | 97 | |
|---|
| | 98 | private static void createStatisticsMBean() { |
|---|
| | 99 | statisticsService = new StatisticsService(); |
|---|
| | 100 | statisticsService.setSessionFactory(getSessionFactory()); |
|---|
| | 101 | |
|---|
| | 102 | MBeanServer server = getServer(); |
|---|
| | 103 | try { |
|---|
| | 104 | ObjectName name = new ObjectName("org.hibernate:Type=Statistics"); |
|---|
| | 105 | server.registerMBean(statisticsService, name); |
|---|
| | 106 | } catch (Exception e) { |
|---|
| | 107 | e.printStackTrace(); |
|---|
| | 108 | } |
|---|
| | 109 | } |
|---|
| | 110 | |
|---|
| | 111 | private static MBeanServer getServer() { |
|---|
| | 112 | ArrayList<MBeanServer> mbservers = MBeanServerFactory.findMBeanServer(null); |
|---|
| | 113 | |
|---|
| | 114 | if( mbservers.size() > 0 ) { |
|---|
| | 115 | System.out.println("Found MBean server"); |
|---|
| | 116 | return mbservers.get(0); |
|---|
| | 117 | } |
|---|
| | 118 | return MBeanServerFactory.createMBeanServer(); |
|---|
| | 119 | } |
|---|
| | 120 | |
|---|
| 88 | 121 | |
|---|
| 89 | 122 | /** |
|---|