Changeset 37191705f4c8bf1d54efbd9d9aed5e94da379484

Show
Ignore:
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
  • src/net/driftingsouls/ds2/server/framework/db/HibernateFacade.java

    r32c88d8 r3719170  
    2020 
    2121import java.io.File; 
     22import java.util.ArrayList; 
    2223import java.util.HashSet; 
    2324import java.util.Iterator; 
    2425import java.util.Set; 
     26 
     27import javax.management.MBeanServer; 
     28import javax.management.MBeanServerFactory; 
     29import javax.management.ObjectName; 
    2530 
    2631import net.driftingsouls.ds2.server.framework.Configuration; 
     
    3540import org.hibernate.dialect.function.StandardSQLFunction; 
    3641import org.hibernate.engine.EntityKey; 
     42import org.hibernate.jmx.StatisticsService; 
    3743import org.hibernate.stat.Statistics; 
    3844import org.w3c.dom.Document; 
     
    4854         
    4955        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; 
    5158         
    5259        static { 
     
    8592                        throw new ExceptionInInitializerError(e); 
    8693                } 
     94                 
     95                createStatisticsMBean(); 
    8796        } 
     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 
    88121         
    89122        /**