hello,
could you please help me to configure similar situation? I need to read index base location from database.
Problem is that in our project we are using automatic hibernate configuration (annotation 3.3.x) and so there is no hibernate configuration file - only persistence.xml. So, I have no experience with hibernate configuration at all. I do not know how and where to tell hibernate that I want to use my own FullTextIndexEventListener.
Code:
public class MyFullTextIndexEventListener extends FullTextIndexEventListener {
@Override
public void initialize(Configuration cfg) {
// Read index location from database
ConfigReader cr = ConfigReader.getInstance(Constants.hotlineParamReaderJNDI);
String indexDirectory = cr.getStringValue(Constants.INDEX_LOCATION);
cfg.setProperty("hibernate.search.default.indexBase", indexDirectory);
searchFactoryImplementor = SearchFactoryImpl.getSearchFactory(cfg);
String indexingStrategy = cfg.getProperties().getProperty(Environment.INDEXING_STRATEGY, "event");
if ("event".equals(indexingStrategy)) {
used = !searchFactoryImplementor.getDocumentBuilders().isEmpty();
} else if ("manual".equals(indexingStrategy)) {
used = false;
} else {
throw new SearchException(Environment.INDEXING_STRATEGY + " unknown: " + indexingStrategy);
}
}
}
Thanks in advance and have a nice day (-:
Jan
PS: I know that our environment is old. But hibernate-core could not be updated (glassfish2 has problems with JPA2.0) - so I was forced to choose old hibernate-search/lucene too.
hibernate 3.2.6 (hibernate-annotation 3.3.1) using JPA
hibernate-search 3.0.1
lucene 2.4.1
glassfish 2.1.1