FulltextSearchFactoryFactory implements Supplier<SearchFactory> { @Override public SearchFactory get() { logger.trace("Creating hibernate search factory."); return session.getSearchFactory(); } @Inject  FulltextSearchFactoryFactory(final FullTextSession fullTextSession); @Override SearchFactory get();  }
@Test public void testProvideDispose() { SessionFactory sessionFactory = injector.getInstance(SessionFactory.class); Session hibernateSession = sessionFactory.openSession(); FullTextSession ftSession = Search.getFullTextSession(hibernateSession); FulltextSearchFactoryFactory factory = new FulltextSearchFactoryFactory(ftSession); SearchFactory searchFactory = factory.get(); assertNotNull(searchFactory); if (hibernateSession.isOpen()) { hibernateSession.close(); } }