Issue Details (XML | Word | Printable)

Key: NUCJPA-87
Type: Improvement Improvement
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Andy Jefferson
Reporter: Ioannis Canellos
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
DataNucleus API JPA

JPA OSGi Bundle should be usable via the OSGi enterprise blueprint.

Created: 18/Nov/10 01:41 AM   Updated: 08/Dec/10 03:28 PM   Resolved: 18/Nov/10 09:14 AM
Component/s: None
Affects Version/s: 2.1.3
Fix Version/s: 2.1.4

File Attachments: 1. Text File NUCJPA-87-patch.txt (2 kB)



 Description  « Hide
org.datanucleus.PersistenceProviderImpl should be registered in the OSGi service registry as described by the OSGi JPA service spec.


Sort Order: Ascending order - Click to sort in descending order
Ioannis Canellos added a comment - 18/Nov/10 01:46 AM
Attaching a patch which adds a blueprint.xml file under OSGI-INF, that create a service of the interface javax.persisistence.spi.PersistenceProvider.

Andy Jefferson added a comment - 18/Nov/10 09:14 AM
Patch applied, thx. Perhaps you can contribute some simple documentation on the "OSGi JPA service spec" ? even if just a few lines. Add it here as a comment and I'll add to the main docs.

Ioannis Canellos added a comment - 18/Nov/10 10:01 AM
In a non OSGi world the persitence provider implementation is loaded using the service provider pattern. The full qualified name of the implementation is stored in a file under META-INF/services/javax.persistence.spi.PersistenceProvider (inside the jar of the implementation) and each time the persistence provider is required it gets loaded with a Class.forName using the the name of the implementing class found inside the META-INF/services/javax.persistence.spi.PersistenceProvider.

In the OSGi world that doesn't work. The bundle that needs to load the persistence provider implementation cannot load META-INF/services/javax.persistence.spi.PersistenceProvider.

A work around is to copy that file inside each bundle that requires access to the peristence provider.

An other work around is to export the persistence provider as OSGi service.

Here is a link that explains things better than me:
http://www.google.gr/url?sa=t&source=web&cd=3&ved=0CCQQFjAC&url=http%3A%2F%2Fwww.osgi.org%2Fwiki%2Fuploads%2FCommunityEvent2008%2F17_MikeKeith%2520-%2520Persistence%2520in%2520OSGi.pdf&rct=j&q=persistnece%20in%20OSGi&ei=pOrkTKLDJMHDhAfqxPW8DA&usg=AFQjCNEwbJO5-bdlDUGJNMEAvT6PHb5Lcw&cad=rja


Ioannis Canellos added a comment - 19/Nov/10 08:53 AM
I think that the patch I supplied breaks the pom.xml file. Please let me know if you wish me to resend an updated patch.

Andy Jefferson added a comment - 19/Nov/10 08:57 AM
The patch had a missing </...> yes, but i spotted it when my XML editor complained ;-). SVN trunk should be fine