Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Make BatooJPA OSGi friendly #175

Closed
lburgazzoli opened this Issue · 2 comments

2 participants

Luca Burgazzoli Asım Arslan
Luca Burgazzoli

It would be nice to be able to use BatooJPA in OSGi environments like Karaf

Asım Arslan
Owner

Batoo JPA is designed and coded OSGi in mind so it should be OSGi compatible. But there may exist bugs as it is in incubation . Please, can you send more specific details on the issue. Thanks.

Luca Burgazzoli

I've tried to install BatooJPA in Apache Karaf and as you can see, the MANIFEST is not OSGi compliant:

karaf@root> install mvn:org.batoo.jpa/batoo-jpa/2.0.1.0-RTM
[ 199] [Active     ] [            ] [   80] mvn:org.batoo.jpa/batoo-jpa/2.0.1.0-RTM
karaf@root> headers 199

Bundle 199
----------

Manifest-Version = 1.0
Archiver-Version = Plexus Archiver
Built-By = hceylan
Build-Jdk = 1.7.0_09
Created-By = Apache Maven

In addition it does not export any PersistenceProvider service to be Enterprise OSGi compliant, here a simple example of an Activator 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;
    }
}
Luca Burgazzoli lburgazzoli closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.