branch develop updated (3765f2f -> 4cbda29)
This is an automated email from the git hooks/post-receive script. New change to branch develop in repository observe. See http://git.codelutin.com/observe.git from 3765f2f fixes #7007: Améliorer l'affichage des coordonnées Merge branch 'feature/7007' into develop new 4cbda29 faire refonctionner jmx sur hibernate The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: commit 4cbda2994694995d88460de67e617f1373127483 Author: Tony CHEMIT <chemit@codelutin.com> Date: Wed Apr 22 17:29:33 2015 +0200 faire refonctionner jmx sur hibernate Summary of changes: .../fr/ird/observe/db/impl/AbstractDataSource.java | 31 +++++++++++++++++----- 1 file changed, 24 insertions(+), 7 deletions(-) -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@list.forge.codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository observe. See http://git.codelutin.com/observe.git commit 4cbda2994694995d88460de67e617f1373127483 Author: Tony CHEMIT <chemit@codelutin.com> Date: Wed Apr 22 17:29:33 2015 +0200 faire refonctionner jmx sur hibernate --- .../fr/ird/observe/db/impl/AbstractDataSource.java | 31 +++++++++++++++++----- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/observe-business/src/main/java/fr/ird/observe/db/impl/AbstractDataSource.java b/observe-business/src/main/java/fr/ird/observe/db/impl/AbstractDataSource.java index ad55e06..0ee2567 100644 --- a/observe-business/src/main/java/fr/ird/observe/db/impl/AbstractDataSource.java +++ b/observe-business/src/main/java/fr/ird/observe/db/impl/AbstractDataSource.java @@ -46,7 +46,9 @@ import fr.ird.observe.entities.seine.SetSeine; import fr.ird.observe.entities.seine.TripSeine; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.hibernate.SessionFactory; import org.hibernate.cfg.Environment; +import org.hibernate.stat.Statistics; import org.nuiton.config.ApplicationConfig; import org.nuiton.decorator.Decorator; import org.nuiton.topia.TopiaContext; @@ -64,10 +66,14 @@ import org.nuiton.topia.persistence.TopiaEntity; import org.nuiton.util.version.Version; import javax.management.MBeanServer; +import javax.management.MXBean; import javax.management.MalformedObjectNameException; import javax.management.ObjectName; import javax.swing.event.EventListenerList; import java.lang.management.ManagementFactory; +import java.lang.reflect.InvocationHandler; +import java.lang.reflect.Method; +import java.lang.reflect.Proxy; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -795,20 +801,31 @@ public abstract class AbstractDataSource implements DataSource { } } + @MXBean + public interface StatisticsMXBean extends Statistics { + } + protected void createHibernateMBean() { try { ObjectName on = createMBean(); if (log.isInfoEnabled()) { log.info("attach MBean " + on); } - //FIXME - readd this! tchemit-2014-06-17 MBeanServer server = ManagementFactory.getPlatformMBeanServer(); - // MBean implementation -// StatisticsService stats = new StatisticsService(); -// // Bind the stats to a SessionFactory -// stats.setSessionFactory(((TopiaContextImplementor) getRootCtxt()).getHibernateFactory()); -// // Register the Mbean on the server -// server.registerMBean(stats, on); + SessionFactory sessionFactory = ((TopiaContextImplementor) getRootCtxt()).getHibernateFactory(); + + final Statistics stats = sessionFactory.getStatistics(); + stats.setStatisticsEnabled(true); + Object statisticsMBean = Proxy.newProxyInstance(getClass().getClassLoader(), new Class<?>[]{StatisticsMXBean.class}, new InvocationHandler() { + + @Override + public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { + return method.invoke(stats, args); + } + }); + + server.registerMBean(statisticsMBean, on); + } catch (Exception e) { if (log.isErrorEnabled()) { log.error("Could not attach hibernate session to JMX...", e); -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@list.forge.codelutin.com>.
participants (1)
-
codelutin.com scm