[
http://opensource.atlassian.com/projects/hibernate/browse/HHH-3593?page=c...
]
John Mazzitelli commented on HHH-3593:
--------------------------------------
Oh, and one other thing to mention - the code also uses
ManagementFactory.getPlatformMBeanServer which is ONLY in JRE 5. Hence, that definintely
needed to be done by reflection because that doesn't even exist in the JDK 1.4, JMX
1.2 combination.
be able to configure statistics enablement
------------------------------------------
Key: HHH-3593
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-3593
Project: Hibernate Core
Issue Type: Improvement
Components: core
Reporter: John Mazzitelli
Priority: Minor
Attachments: HHH-3593.patch
Right now, in order to enable Hibernate to collect and emit statistics to monitoring
tools, your application has to manually execute code similar to the following:
StatisticsService mBean = new StatisticsService();
SessionFactory sessionFactory = ...get hibernate session factory...
mBean.setSessionFactory(sessionFactory);
ObjectName objectName = new
ObjectName("Hibernate:application=MY_APP_NAME,type=statistics");
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
mbs.registerMBean(mBean, objectName);
sessionFactory.getStatistics().setStatisticsEnabled(true);
It would be nice if this was configurable, so a user of Hibernate doesn't need to
write this code.
For example:
hibernate.statistics.enabled=true
hibernate.statistics.objectname=Hibernate:application=MY_APP_NAME,type=statistics
hibernate.statistics.mbeanserver=*platform*
This would turn on Hibernate statistics and tell it to register the Statistics MBean in
the JVM's platform MBean Server (ManagementFactory.getPlatformMBeanServer). Of course,
*platform* would only be valid on Java5 or higher VMs. Note that hibernate will need to
allow the object name to be configurable as well.
Or...
hibernate.statistics.enabled=true
hibernate.statistics.objectname=Hibernate:application=MY_APP_NAME,type=statistics
hibernate.statistics.mbeanserver=my_mbs_name
This tells Hibernate to register the MBean in the named MBeanServer where the
"my_mbs_name" is the default domain name of the MBeanServer you want (if it
doesn't exist, Hibernate should create the MBeanServer with the named default
domain).
In fact, I had the Remoting project do something similar, so you can see code that gets
the MBeanServer using these two ways by looking at the .patch attached to:
https://jira.jboss.org/jira/browse/JBREM-746 and its related fix.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira