Martin Neimeier contacted the Hibernate team on the hibernate-dev mailing list offering to help work on this and starting a discussion on it. His initial email:
because I need clean OSGI bundles for Hibernate and especially Envers, I am working on some patches for the 4.1 branch of hibernate-orm to enable generation of OSGI compatible jar files.
During the work I have found the following problems, and need some help and/or feedback. The problems are:
- The package org.hibernate.engine.spi is exported by two jar files, hibernate-core and hibernate-entitymanager, which is not possible in OSGI. The Problem is the STYLES map in CascadeStyle in hibernate-core which prevent that the package in hibernate-entitymanager can be refactored from org.hibernate.engine.spi to org.hibernate.ejb.engine.spi, to solve the duplicate export.
I think to fix this problem, the following steps should be done:
- Add a setter method to CascadeStyle to allow subclasses to add CascadeStyles to the map STYLES
- Refactor the package org.hibernate.engine.spi in hibernate-envers to org.hibernate.ejb.engine.spi
- Use the setter method to add the new CascadeStyle in EJB3CascadeStyle
- The package org.hibernate.tool.ant is exported by to jars, hibernate-tools (version: 3.2.0.ga) and hibernate-envers, which is also a duplicate export problem. The problem is that HibernateToolTask in hibernate-tools has no getters/setters for configurationTask and thus hibernate-envers is directly reading/modyifing the property configurationTask. I think to fix this problem, the following steps should be done:
- hibernate-tools should add public getters/setters for configurationTask in class HibernateToolTask
- the package org.hibernate.tool.ant in hibernate-envers should be refactored to org.hibernate.envers.tool.ant
- the property configurationTask should be accessed sole thru the getters/setters .
It would be nice if someone could check and comment my planned and already done changes.
I have already done the CascadeStyle fix, the configurationTask fix is outstanding because I need to know against which version of hibernate-tools I should create the fix.
In generally the following tasks are done until now:
- added configuration to gradle scripts to generate the osgi manifests for all jar files in hibernate-orm (needs maybe some cleanup) - right now the build files for hibernate-core, hibernate-entitymanager and hibernate-envers are modified.
- added blueprint.xml to hibernate-entitymanager to announce the availabillity of a javax.persistence.provider
Next steps:
- add osgi manifests to the other jars of hibernate-orm
- write integration tests with pax exam and karaf 2.2.x
- finish refactoring of hibernate-tools
- add patches for other needed dependencies (hibernate-commons-annotations and more)
- more testing, more integration tests
Help, reviews and comments are welcome, and if someone has already done the work or parts, please drop me a note.