Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] [OSGI] Using entity manager factory with entities discovered at runtime in an other bundle

Hi Guillaume,
You've ran into the same problem that many of us (the few) who use osgi have.

Here's how we handle it: We expose the EntityManagerFactory in each
plugin, this way if another plugin wants to use it, it simply grabs
it, and uses it to do all the persistence.

The trick is you can't merge an Entity from one bundle into another
bundle. So in cases where you need to do a bunch of stuff in the same
transaction you must duplicate your entities in the other
plugins....not an ideal solution but it works.

Also if you're interested in the general architecture of an OSGi RCP
app we've made a sample application that's currently under review on
bugzilla at:

Let me know if you have any questions.


On Thu, Jul 24, 2008 at 9:27 AM, Guillaume PRIN
<guillaume.prin@xxxxxxxxxxxxxxxxxxxxxxxx> wrote:
> Hi,
> I have built an OSGI bundle which can read and write annotated entities to a
> database inspired by the "OSGi Proof of Concept". Unfortunately, I can't
> find
> a satisfactory solution for my problem. I would like to use this bundle to
> persist entities defined in other bundles. These bundles may be considered
> as
> "plugins" of the first bundle, which is started at first. Plugins may be
> numerous, I cannot open as many database connections.
> My problem, is that in OSGI, without taking into account the problems of
> dependency, it seems that the entities must be defined in the
> persistence.xml
> and cannot be discovered at runtime when plugins register to the first
> bundle.
> And so the first bundle cannot persist entities from plugins.
> To use the factory, I thought the use of a OSGI service from the first
> bundle.
> Guillaume
> _______________________________________________
> eclipselink-users mailing list
> eclipselink-users@xxxxxxxxxxx

Back to the top