2.3. JMX Integration
JMX is the J2EE standard for the management of Java components. Hibernate can be managed via a JMX standard service. AN MBean implementation is provided in the distribution:
org.hibernate.jmx.HibernateService
.
For an example of how to deploy Hibernate as a JMX service on the JBoss Application Server, please see the JBoss User Guide. JBoss AS also provides these benefits if you deploy using JMX:
- Session Management: the Hibernate
Session
's life cycle can be automatically bound to the scope of a JTA transaction. This means that you no longer have to manually open and close theSession
; this becomes the job of a JBoss EJB interceptor. You also do not have to worry about transaction demarcation in your code (if you would like to write a portable persistence layer use the optional HibernateTransaction
API for this). You call theHibernateContext
to access aSession
. - HAR deployment: the Hibernate JMX service is deployed using a JBoss service deployment descriptor in an EAR and/or SAR file, as it supports all the usual configuration options of a Hibernate
SessionFactory
. However, you still need to name all your mapping files in the deployment descriptor. If you use the optional HAR deployment, JBoss will automatically detect all mapping files in your HAR file.
Consult the JBoss AS user guide for more information about these options.
Another feature available as a JMX service is runtime Hibernate statistics. See Section 3.4.6, “Hibernate statistics” for more information.