Make Kundera OSGi aware
As today Kundera's jars are not OSGi ready but it would be really nice to be able to use Kundera tecnologies inside OSGi applications.
I'm currently working on a simple project to experiment with JPA and OSGi: https://github.com/lburgazzoli/lb-karaf-examples and Kundera would be a really nice addition.
It is planned for 2.5 release. Will post an update on this.
-Vivek
Hi, kundera-2.5 is out but it is not yet OSGi ready, any forecast for this implementation?
Hi, Can you please give it a try with latest trunk?Also, please refer my last comment on: https://github.com/impetus-opensource/Kundera/issues/305
Fixed and releasing with 2.6. Please verify. -Vivek
Hi, the issue is not fixed, at least for the jars pushed on maven central:
[ 236] [Installed ] [ ] [ 80] mvn:com.impetus.core/kundera-core/2.6
[ 239] [Installed ] [ ] [ 80] mvn:com.impetus.client/kundera-rdbms/2.6
The headers are still not osgi-compliant:
karaf@kha-1> headers 236
Bundle 236
----------
Manifest-Version = 1.0
Archiver-Version = Plexus Archiver
Built-By = impadmin
Build-Jdk = 1.6.0_26
Created-By = Apache Maven
karaf@kha-1> headers 239
Bundle 239
----------
Manifest-Version = 1.0
Archiver-Version = Plexus Archiver
Built-By = impadmin
Build-Jdk = 1.6.0_26
Created-By = Apache Maven
My Bad. Issue related to jboss AS 7 deployment has been fixed.
Could you please discuss bit more for what issues you are facing with this?
-Vivek
In fact I'm not having an issue now but as stated in the first comment, I'm playing with OSGi (with Apache Karaf) and JPA to find out which implementation has the best support for OSGi.
About Kundera, I found out that the JARs are not even OSGi compliant:
Bundle-Vendor = FasterXML
Bundle-Name = Jackson-core
Bundle-DocURL = http://wiki.fasterxml.com/JacksonHome
Bundle-Description = Core Jackson abstractions, basic JSON streaming API implementation
Bundle-SymbolicName = com.fasterxml.jackson.core.jackson-core
Bundle-Version = 2.2.1
Bundle-License = http://www.apache.org/licenses/LICENSE-2.0.txt, http://www.gnu.org/licenses/lgpl-2.1.html
Bundle-ManifestVersion = 2
Export-Package =
com.fasterxml.jackson.core;version=2.2.1,
com.fasterxml.jackson.core.io;version=2.2.1,
com.fasterxml.jackson.core.json;version=2.2.1,
com.fasterxml.jackson.core.util;version=2.2.1,
com.fasterxml.jackson.core.base;version=2.2.1,
com.fasterxml.jackson.core.sym;version=2.2.1,
com.fasterxml.jackson.core.type;version=2.2.1,
com.fasterxml.jackson.core.format;version=2.2.1
Then there should be a PersistenceProvider service, here you can find an example of a BundleActivator for EclipseLink:
public class Activator implements BundleActivator {
private static BundleContext context = null;
private static ServiceRegistration serviceReg = null;
@Override
public void start(BundleContext context) throws Exception {
this.context = context;
Hashtable<String,String> props = new Hashtable<String, String>();
props.put(
"javax.persistence.provider",
"org.eclipse.persistence.jpa.PersistenceProvider");
props.put(
"javax.persistence.spi.PersistenceProvider",
"org.eclipse.persistence.jpa.PersistenceProvider");
props.put(
"javax.persistence.PersistenceProvider",
"org.eclipse.persistence.jpa.PersistenceProvider");
serviceReg = context.registerService(
"javax.persistence.spi.PersistenceProvider",
new org.eclipse.persistence.jpa.PersistenceProvider(),
props);
}
@Override
public void stop(BundleContext context) throws Exception {
if (this.serviceReg != null) {
this.serviceReg.unregister();
this.serviceReg = null;
}
this.context = null;
}
}
To generate a OSGi-ready bundle you can use maven-bundle-plugin, something like:
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>${project.groupId}.${project.artifactId}</Bundle-SymbolicName>
<Bundle-Name>${project.artifactId}</Bundle-Name>
<Bundle-Version>${project.version}</Bundle-Version>
<Bundle-Activator>com.impetus.kundera....osgi.PersistenceActivator</Bundle-Activator>
<Export-Package>
com.impetus.kundera.*
</Export-Package>
<Import-Package>
!com.impetus.kundera.*
</Import-Package>
</instructions>
</configuration>
</plugin>
After a couple of hours I've finally succeeded to prepare some changes to "OSGfy" Kundera
-
Added a compliant Manifest
-
Did a very quick workaround around ClassLoader to load META-INF/persistence.xml from other bundles
-
Entity classes are loaded via DynamicImport-Package: *, which is not good. But turned out to be a quick fix for now..
-
Also added an Activator to comply with OSGI JPA (tested on Aries)
And luckily none of the tests broke :+1:
If anyone is interested, I'll be more than happy to share my adjustments... Maybe it can be included in 2.11?
@dzalbo :+1: Great! Please share your pull request and let me have a look and plan with 2.11
Great!
Once ready, I'll try to add an example on my Karaf JPA Examples repository (https://github.com/lburgazzoli/lb-karaf-examples-jpa).
Duplicate of #525. Closing.