[hibernate-dev] exposing statistics easier (HHH-3593 solution)

John Mazzitelli mazz at redhat.com
Thu Nov 20 20:00:35 EST 2008


You assume the hibernate app is always running in a container that 
supports that.

But, by definition, Hibernate is not required to be running in any kind 
of container environment - it is designed to be able to run even in a 
simple J2SE environment.

As such, it should not solely rely on its environment to do this kind of 
thing. It should have some configurable way to enable its statistics 
MBean for those times when there is no other way to do so.

Elias Ross wrote:
> Spring and a lot of other containers like JBoss's Microcontainer make
> it pretty easy to deploy the statistics MBean.
> 
> E.g. in Spring:
> 
>     <bean id="hibernateStatisticsService"
> class="org.hibernate.jmx.StatisticsService">
>         <property name="sessionFactory">
>             <bean factory-bean="entityManagerFactory"
> factory-method="getSessionFactory"/>
>         </property>
>     </bean>
> 
>   	<bean id="jmxBeanExporter"
> class="org.springframework.jmx.export.MBeanExporter">
>   		<property name="beans">
>   			<map>
> 				<entry key=":type=HibernateStatisticsService"
> value-ref="hibernateStatisticsService"/>
>   			</map>
>   		</property>
>   		<property name="server" ref="platformMBeanServer"/>
>   	</bean>
> 
> Probably it's more of a documentation issue to explain to users how to
> do this than to provide a configuration facility.
> 
> I don't see this as hard as a user.



More information about the hibernate-dev mailing list