[hibernate-dev] [Search] OSGi split packages
hardy at hibernate.org
Tue Mar 25 17:11:18 EDT 2014
As part of my work for making Search OSGi ready , I am looking into addressing HSEARCH-1560  which is about
split packages which we have between some of our Search bundles (or modules to use Maven lingo).
Basically a split package "is caused where two or more bundles export the same package name and version, usually with different contents”. 
In terms of OSGi, split packages are bad and should be avoided. There exists a work around , but afaiu it is frowned upon.
While working on an integration test trying to run Search in Apache Karaf, I was running into this problem and basically needed (for the time being)
revert to the mentioned work around.
The biggest for getting rid of split packages is org.hibernate.search which is a split packages between the engine and orm bundle. In org.hibernate.search of engine
org.hibernate.search of orm contains:
As you can see, these are quite central classes and moving any of them around will break existing code (even though updating just requires
to change import statements). If we are serious with OSGi we should address this. We always said, that Search 5 is the release where we can break
API backwards compatibility. So if we want to do this, we should do it now. On the other hand, it is a big change.
I went ahead and tried to refactor org.hibernate.search in engine, applying the following changes:
org.hibernate.search.Environment -> org.hibernate.search.cfg.Environment
org.hibernate.search.SearchFactory -> org.hibernate.search.spi.SearchFactory
org.hibernate.search.SearchException -> org.hibernate.search.exception.SearchException
org.hibernate.search.FullTextFilter -> org.hibernate.search.filter.FullTextFilter
org.hibernate.search.Version -> org.hibernate.search.engine.Version
Some of these changes I actually find quite fitting independently of the split package problem. FullTextFilter seems to have found its true home now
and Version and Environment don’t seem too bad either. The big change is SearchFactory and .SearchException.
WDYT? Is this package refactoring something worth doing and if so what do you think about the new locations of the classes? Any better suggestions?
Or do you think the orm bundle should be refactored instead?
You can see the preliminary result here .
More information about the hibernate-dev