This content has been marked as final.
Show 3 replies
-
1. Re: JMX MBean for Hibernate Statistics and Seam
asookazian Jun 26, 2009 7:19 PM (in response to asookazian)I shut down JBoss and seeing the following in console:
09:48:18,743 INFO [SessionFactoryImpl] closing
So apparently the implementation of EntityManagerFactory interface is SessionFactoryImpl class when the persistence provider is Hibernate?
Anyways, so must I use a Hibernate interceptor to solve this now? How can I capture this event and continue my processing to unregister the MBean?
-
2. Re: JMX MBean for Hibernate Statistics and Seam
asookazian Jun 26, 2009 7:37 PM (in response to asookazian)Here is the code in org.hibernate.impl.SessionFactoryImpl class. Note the last lines:
observer.sessionFactoryClosed( this ); eventListeners.destroyListeners();
Has anyone actually used this part of the Hibernate Core API for event tracking purposes? thx.
/** * Closes the session factory, releasing all held resources. * * <ol> * <li>cleans up used cache regions and "stops" the cache provider. * <li>close the JDBC connection * <li>remove the JNDI binding * </ol> * * Note: Be aware that the sessionfactory instance still can * be a "heavy" object memory wise after close() has been called. Thus * it is important to not keep referencing the instance to let the garbage * collector release the memory. */ public void close() throws HibernateException { if ( isClosed ) { log.trace( "already closed" ); return; } log.info("closing"); isClosed = true; Iterator iter = entityPersisters.values().iterator(); while ( iter.hasNext() ) { EntityPersister p = (EntityPersister) iter.next(); if ( p.hasCache() ) { p.getCacheAccessStrategy().getRegion().destroy(); } } iter = collectionPersisters.values().iterator(); while ( iter.hasNext() ) { CollectionPersister p = (CollectionPersister) iter.next(); if ( p.hasCache() ) { p.getCacheAccessStrategy().getRegion().destroy(); } } if ( settings.isQueryCacheEnabled() ) { queryCache.destroy(); iter = queryCaches.values().iterator(); while ( iter.hasNext() ) { QueryCache cache = (QueryCache) iter.next(); cache.destroy(); } updateTimestampsCache.destroy(); } settings.getRegionFactory().stop(); if ( settings.isAutoDropSchema() ) { schemaExport.drop( false, true ); } try { settings.getConnectionProvider().close(); } finally { SessionFactoryObjectFactory.removeInstance(uuid, name, properties); } observer.sessionFactoryClosed( this ); eventListeners.destroyListeners(); }
-
3. Re: JMX MBean for Hibernate Statistics and Seam
asookazian Jun 26, 2009 7:41 PM (in response to asookazian)Seam in Action does not list any Hibernate events as built-in raised events:
Here’s a list of some of the events that Seam raises: ■ Seam container initialized ■ Context variable assignment (added, removed) ■ Component life-cycle events (created, destroyed) ■ Scope events (created, destroyed) ■ Authentication events ■ Transaction events (before complete, commit, rollback) ■ Exception events (handled, not handled) ■ Conversation, page flow, business process, and task boundaries ■ JSF phase transitions (before, after) ■ JSF validation failed ■ User preference change (theme, time zone, locale)
Unless possibly component life-cycle event for this? Not sure which component is involved here...