Joined: Sat May 06, 2006 9:08 am Posts: 8
|
I am writing an Interceptor that needs the PersistentClass information of entities. Event listeners get access to Configuration information by implementing org.hibernate.event.Initializable. There doesn't appear to be a clean way to make this information available to an Interceptor.
I modified my Interceptor to also be an initializable Listener for an infrequent event: implements Initializable, PreDeleteEventListener
After configuring it in the application's applicationContext.xml as both an interceptor and a listener: <bean id="auditInterceptor" class="com.med.cdc.interceptor.ChangeInterceptor"/>
<bean id="eventListener" class="com.med.cdc.interceptor.ChangeInterceptor"/>
<bean id="hibernateSessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean" destroy-method="destroy">
<property name="eventListeners"> <map> <entry key="pre-delete"><ref local="eventListener" /></entry> </map> </property> ... </bean>
<bean id="hibernateTransactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory" ref="hibernateSessionFactory"/> <property name="entityInterceptorBeanName" value="auditInterceptor" /> </bean>
it is getting the Configuration information it needs.
Is there a better way for an Interceptor to get access to Configuration information?
|
|