[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-3593) be able to configure statistics enablement

John Mazzitelli (JIRA) noreply at atlassian.com
Wed Nov 19 13:41:15 EST 2008


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-3593?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=31748#action_31748 ] 

John Mazzitelli commented on HHH-3593:
--------------------------------------

Because I did not want to introduce any JMX dependencies in the hibernate core build :)  There wasn't any up until this point and I didn't want to be the one to introduce them.  I wanted the build to work exactly the way it has always worked, with no additional runtime dependencies on optional libraries.

In addition, what if someone was running hibernate in a JRE 1.4 environment and did NOT have JMX libraries - I wanted to avoid any possiblity of getting a NoClassDefFound exception by simply loading the JmxStatistics class (which gets loaded by the SessionFactoryImpl - and since that is a uber-important class, I did not want to entertain the thought of possibly adding JMX dependencies on that even at runtime unless JMX stats are explicitly enabled).

In short, I was paranoid and wanted to maintain backward compatiblity (both build and runtime compatibliity) at all costs.

That code is written in such a way that you can strip off the bottom half of JmxStatistics class, fix the trivial compile errors that occur as a result (by importing the javax.management.* classes and calling  the proper JMX APIs) and it'll work - so long as you put JMX as a build dependency AND we won't run into the 1.4 runtime dependency issue I mention above.  I recommend we do not do this until such time as Hibernate deprecates the 1.4 requirement (thus ensuring that javax.management is always available).

> 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.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the hibernate-issues mailing list