3 Replies Latest reply on Apr 2, 2012 3:45 PM by yashendrac

    jboss ListenerInjector and custom hibernate event listener registration

    yashendrac

      Hi,

       

      Is there any alternative interface to org.jboss.hibernate.ListenerInjector in JBoss 7.1?

       

      Our project have a class which implements org.jboss.hibernate.ListenerInjector.

       

      Implemented method calls setProperty and setListener methods on passed hibernate Configuration object.

       

      I wonder how to migrate this code to JBoss 7.1.

       

      Do I need to configure those custom hibernate event listener in persistence.xml, something like this:

       

              <properties>
                 
      <property name="hibernate.ejb.event.post-collection-recreate" value="org.hibernate.search.event.impl.FullTextIndexEventListener"/>

                  <property name="hibernate.ejb.event.post-insert" value="org.hibernate.search.event.impl.FullTextIndexEventListener"/>

                  <property name="hibernate.ejb.event.post-delete" value="org.hibernate.search.event.impl.FullTextIndexEventListener"/>

              </properties>

       

      But how do I configure such things:

       

              configuration.setProperty("hibernate.search.default.indexBase", indexPath);

              configuration.setProperty("hibernate.search.worker.execution", "sync");

              configuration.setProperty("hibernate.search.reader.strategy", "shared-segments");

              configuration.setProperty("hibernate.search.default.directory_provider", "org.hibernate.search.store.impl.FSDirectoryProvider");

        • 1. Re: jboss ListenerInjector and custom hibernate event listener registration
          yashendrac

          Ok I think I can use same <property name="..."  value=".."/> for those code too. but I have some java code in my ListenerInjector implementation to calculate path before setting hibernate.search.default.indexBase. So I think I still need to find alternative interface to org.jboss.hibernate.ListenerInjector

          • 2. Re: jboss ListenerInjector and custom hibernate event listener registration
            ctomc

            Hi,

             

            There is no need to explicitly register hibernate search event listners anymore, they are registered automaticly.

             

            as for other properties go you just define them as you predicted:

            example from one of my apps:

             

            <property name="hibernate.search.default.directory_provider" value="filesystem" />

            <property name="hibernate.search.default.indexBase" value="/store/app/indexes" />

            --

            tomaz

            • 3. Re: jboss ListenerInjector and custom hibernate event listener registration
              yashendrac

              Thanks Tomaz.

              So do you mean I dont have to register FullTextIndexEventListener for any events, is it registered by default for all events?

              I had registered it for these events pre-insert, pre-update, post-insert, post-update, post-delete, post-collection-recreate, post-collection-remove, post-collection-update.

               

              So I think now only problem is setting hibernate.search.default.indexBase dynamically.

              We used find this path dynamically using java code, at server startup.

              Defining in persistence.xml means I need to define it statically or need to find a way to access hibernate Configuration object before SessionFactory is constructed?