[
http://opensource.atlassian.com/projects/hibernate/browse/HHH-3593?page=c...
]
John Mazzitelli commented on HHH-3593:
--------------------------------------
Caching the MBeanServer should be OK if you were the one that created it with
MBeanServerFactory.createMBeanServer (since you'll control the lifecycle - i.e.
you'll be removing it from the MBeanServerFactory when it's no longer needed). If
you are using an existing MBeanServer that you did not create (i.e. in my code sample,
this would be if someone specified the hibernate setting
"hibernate.statistics.mbeanserver=my_mbs_name" where "my_mbs_name"
already existed), then you'd probably have to be careful. Your cache would now have a
reference to the MBeanServer and if the owner of that MBS removes it from the factory
(presumably because its no longer to be used), there's a potential for memory leakage
(you'd have to know to throw away your cache reference in order for the MBS and all
its MBeans to be GC'ed).
That's the only gotcha I can think of if caching the MBS reference.
Note: if the MBS is the Platform MBeanServer, you're probably OK caching that - that
MBS should always be available for use IIRC.
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