I created the following class and config

public class HibernateExtensionPostProcessor extends
        org.appfuse.dao.spring.HibernateExtensionPostProcessor {

        private Map eventListeners;
        private String sessionFactoryBeanName = "sessionFactory";

        /**
         * Top level properties to add to the session factory.
         * 
         * @param eventListeners
         *            The list of additional properties.
         */
        public void setEventListeners(Map eventListeners) {
                this.eventListeners = eventListeners;
        }

        @SuppressWarnings("unchecked")
        public void postProcessBeanFactory(
                ConfigurableListableBeanFactory 
configurableListableBeanFactory) {
                if (configurableListableBeanFactory
                        .containsBean(sessionFactoryBeanName)) {
                        BeanDefinition sessionFactoryBeanDefinition =
configurableListableBeanFactory
                                .getBeanDefinition(sessionFactoryBeanName);
                        MutablePropertyValues propertyValues = 
sessionFactoryBeanDefinition
                                .getPropertyValues();

                        if (eventListeners != null) {
                                PropertyValue propertyValue = propertyValues
                                        .getPropertyValue("eventListeners");

                                if (propertyValue == null) {
                                        propertyValue = new 
PropertyValue("eventListeners",
                                                new HashMap());
                                        
propertyValues.addPropertyValue(propertyValue);
                                }

                                // loop over properties List and add top level 
property for each entry
                                Map existingListeners = (Map) 
propertyValue.getValue();
                                existingListeners.putAll(eventListeners);
                        }
                }
        }
}

        <bean id="textIndexEventListener"
                class="org.hibernate.search.event.FullTextIndexEventListener" />

        <bean
                
class="nl.myproject.dao.hibernate.HibernateExtensionPostProcessor">
                <property name="eventListeners">
                        <map>
                                <entry key="post-update"><ref 
local="textIndexEventListener" /></entry>
                                <entry key="post-insert"><ref 
local="textIndexEventListener" /></entry>
                                <entry key="post-delete"><ref 
local="textIndexEventListener" /></entry>
                        </map>
                </property>
        </bean>

I can see that they are being registered in Hibernate, but the events aren't
firing. Not sure why. My Service class is @Transactional. I'm wondering if
it has something to do with HibernateTemplate calling merge() in stead of
save() on the session.

Any ideas?

Cheers,

Marc

-- 
View this message in context: 
http://www.nabble.com/Hibernate-Search%2C-how-to-set-add-listeners-to-session-factory-tp19806181s2369p19824650.html
Sent from the AppFuse - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to