Ejemplo n.º 1
0
        private static SearchFactoryImpl GetSearchFactory(IEnumerable listeners)
        {
            FullTextIndexEventListener listener = null;

            // this sucks since the event listener use is mandated
            foreach (var eventListener in listeners.OfType <FullTextIndexEventListener>())
            {
                listener = eventListener;
                return(listener.SearchFactory as SearchFactoryImpl);
            }

            throw new HibernateException(
                      "Hibernate Search Event listeners not configured, please check the reference documentation and the "
                      + "application's hibernate.cfg.xml");
        }
        public void Contribute(Configuration cfg)
        {
            if (!cfg.Properties.ContainsKey(NHibernate.Search.Environment.AnalyzerClass))
            {
                return;
            }

            var eventlistener           = new FullTextIndexEventListener();
            var collectioneventlistener = new FullTextIndexCollectionEventListener();

            cfg.AppendListeners(ListenerType.PostDelete, new IPostDeleteEventListener[] { eventlistener });
            cfg.AppendListeners(ListenerType.PostInsert, new IPostInsertEventListener[] { eventlistener });
            cfg.AppendListeners(ListenerType.PostUpdate, new IPostUpdateEventListener[] { eventlistener });
            cfg.AppendListeners(ListenerType.PostCollectionRecreate, new IPostCollectionRecreateEventListener[] { collectioneventlistener });
            cfg.AppendListeners(ListenerType.PostCollectionRemove, new IPostCollectionRemoveEventListener[] { collectioneventlistener });
            cfg.AppendListeners(ListenerType.PostCollectionUpdate, new IPostCollectionUpdateEventListener[] { collectioneventlistener });
        }
Ejemplo n.º 3
0
        private FullTextIndexEventListener GetLuceneEventListener()
        {
            IPostInsertEventListener[] listeners = ((SessionFactoryImpl)sessions).EventListeners.PostInsertEventListeners;
            FullTextIndexEventListener listener  = null;

            // HACK: this sucks since we mandate the event listener use
            foreach (IPostInsertEventListener candidate in listeners)
            {
                if (typeof(FullTextIndexEventListener).IsAssignableFrom(candidate.GetType()))
                {
                    listener = (FullTextIndexEventListener)candidate;
                    break;
                }
            }

            if (listener == null)
            {
                throw new HibernateException("Lucene event listener not initialized");
            }

            return(listener);
        }
Ejemplo n.º 4
0
        public static ISearchFactoryImplementor GetSearchFactoryBySFI(ISessionImplementor session)
        {
            IPostInsertEventListener[] listeners = session.Listeners.PostInsertEventListeners;
            FullTextIndexEventListener listener  = null;

            // FIXME this sucks since we mandante the event listener use
            foreach (IPostInsertEventListener candidate in listeners)
            {
                if (candidate is FullTextIndexEventListener)
                {
                    listener = (FullTextIndexEventListener)candidate;
                    break;
                }
            }

            if (listener == null)
            {
                throw new HibernateException(
                          "Hibernate Search Event listeners not configured, please check the reference documentation and the "
                          + "application's hibernate.cfg.xml");
            }

            return(listener.SearchFactory);
        }
Ejemplo n.º 5
0
 public override void Given()
 {
     base.Given();
     this.listener = new FullTextIndexEventListener();
 }