hibernate 3.6.0.FINAL and OSGi

Hibernate does not come OSGi enabled from jboss. That’s okay. We can use bundlor to fix that. Grab bundlor from springsource and execute the following commands to make them available in maven. You can also add these to a maven pom.xml to have them automatically run. Note that the commands below assume the jar is in a specific subdirectory and the output goes to another subdirectory. Just replace yourprefix with the prefix you want to use. Springsource likes to use com.springsource but pick your own. Then just use your maven dependency declaration as you normally would.

bundlor.bat -i nonosgilibs/hibernate3.jar -o ./libs/hibernateuser.org.hibernate-3.6.0.Final.jar -m template-hibernate3.mf
mvn install:install-file -Dfile=libs/hibernateuser.org.hibernate-3.6.0.Final.jar -DgroupId=org.hibernate -DartifactId=hibernateuser.org.hibernate -Dversion=3.6.0.Final -Dpackaging=jar

bundlor.bat -i nonosgilibs/hibernate-jpa-2.0-api-1.0.0.Final.jar -o libs/hibernateuser.javax.persistence2-1.0.0.Final.jar -m template-hibernate-jpa.mf
mvn install:install-file -Dfile=libs/hibernateuser.javax.persistence2-1.0.0.Final.jar -DgroupId=javax.persistence -DartifactId=hibernateuser.javax.persistence2 -Dversion=1.0.0.Final -Dpackaging=jar

bundlor.bat -i nonosgilibs/hibernate-validator-4.1.0.Final.jar -o libs/hibernateuser.org.hibernate.validator-4.1.0.Final.jar -m template-hibernate-validator.mf
mvn install:install-file -Dfile=libs/hibernateuser.org.hibernate.validator-4.1.0.Final.jar -DgroupId=org.hibernate -DartifactId=hibernateuser.org.hibernate.validator -Dversion=4.1.0.Final -Dpackaging=jar

bundlor.bat -i nonosgilibs/validation-api-1.0.0.GA.jar -o libs/hibernateuser.javax.validation-1.0.0.GA.jar -m template-hibernate-validator-api.mf
mvn install:install-file -Dfile=libs/hibernateuser.javax.validation-1.0.0.GA.jar -DgroupId=javax.validation -DartifactId=hibernateuser.javax.validation -Dversion=1.0.0.GA -Dpackaging=jar
The template.mf files are below:

template-hibernate3.mf

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: JBoss Hibernate Objec-Relational Mapper
Built-By: hibernateuser
Bundle-Vendor: hibernateuser
Implementation-Vendor-Id: org.hibernate
Bundle-SymbolicName: hibernateuser.org.hibernate
Bundle-Version: 3.6.0.Final
Eclipse-BuddyPolicy: registered
Excluded-Exports: *.internal*
Import-Template: antlr*;version="[2.7.6,3)",
com.ibm.*;resolution:=optional,
javasssist.*;version="[3.12.0,4.0.0)",
javax.naming*,
javax.persistence*;version="[2,2.1)",
javax.security.auth*,
javax.security.jacc*,
java.sql*,
javax.transaction*;resolution:=optional;version="[1.1,2)",
javax.xml*,
javax.validation*;version="[1.0,1.1)",
net.sf.cglib*;version="[2.2,3]",
org.slf4j*;version="[1.6.1,2.0)",
org.dom4j*;version="[1.6.1,2)",
org.apache.commons.collections*;version="[3.1,4)",
org.w3c.dom*,
org.xml.sax*,
*
Export-Template: org.hibernate.*;version=3.6.0
Unversioned-Imports: *

and template-hibernate-jpa.mf:

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: JBoss Hibernate Objec-Relational Mapper
Built-By: hibernateuser
Bundle-Vendor: hibernateuser
Implementation-Vendor-Id: org.hibernate
Bundle-SymbolicName: hibernateuser.org.hibernate
Bundle-Version: 3.6.0.Final
Eclipse-BuddyPolicy: registered
Excluded-Exports: *.internal*
Import-Template: antlr*;version="[2.7.6,3)",
com.ibm.*;resolution:=optional,
javasssist.*;version="[3.12.0,4.0.0)",
javax.naming*,
javax.persistence*;version="[2,2.1)",
javax.security.auth*,
javax.security.jacc*,
java.sql*,
javax.transaction*;resolution:=optional;version="[1.1,2)",
javax.xml*,
javax.validation*;version="[1.0,1.1)",
net.sf.cglib*;version="[2.2,3]",
org.slf4j*;version="[1.6.1,2.0)",
org.dom4j*;version="[1.6.1,2)",
org.apache.commons.collections*;version="[3.1,4)",
org.w3c.dom*,
org.xml.sax*,
*
Export-Template: org.hibernate.*;version=3.6.0
Unversioned-Imports: *

You can do the same thing for the validator jars:

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: JBoss Hibernate Validator
Built-By: hibernateuser
Bundle-Vendor: hibernateuser
Bundle-SymbolicName: hibernateuser.org.hibernate.validator
Bundle-Version: 4.1.0.Final
Implementation-Vendor-Id: org.hibernate
Eclipse-BuddyPolicy: registered
Excluded-Exports: *.internal*
Export-Template: org.hibernate.validator.*;version=4.1.0.Final
Unversioned-Imports: *

and for the validator API

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Java Validaton API
Built-By: hibernateuser
Bundle-SymbolicName: hiberanteuser.javax.validation
Implementation-Vendor-Id: org.hibernate
Bundle-Version: 1.0.0.GA
Eclipse-BuddyPolicy: registered
Excluded-Exports: *.internal*
Export-Template: javax.validation.*;version=1.0.0.GA
Unversioned-Imports: *

I have not completely tested this but this is the basic idea.

Popular posts from this blog

React, Redux, Recompose and some simple steps to remove "some" boilerplate and improve reuse

graphql (facebook), falcor (netflix) and odata and ...

cats/cats-effect and webservices function composition