Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Does OSGI work?

I have not tried #1 or #3. We use #2.

I posted this in an earlier thread today (maybe before you joined the
list, so I'll repeat).
--
I'll do my best, maybe explaining our set up will help you.

Project:
 util.jpa: Contains a special EntityManagerFactoryFactory :) This
takes care of all the config in one place.

 It takes 2 parameters:
  String persistenceUnitName,
  ClassLoader yourClassLoader

So let's say i have my project
 myproj.model which contains entities, and a persistence unit. To
"connect" this project to EclipseLink, I just call:
EmfFactory.createEntityManagerFactory(MyActivator.PLUGIN_ID,
this.getClass().getClassLoader());  in the Activator of the plugin,
now i have an EntityManagerFactory that can be used in my project to
get new EntityManagers. So the EmfFactory handles creating the
database connection and setting up an EntityManagerFactory.

The golden rule with the OSGI stuff is Managed Entities CANNOT cross
classloader boundries. However, you can keep mappedsuperclasses in a
different classloader, that's fine.

If you would like more details about our RCP/OSGi set up please let me
know, I plan on creating a blog post about it anyway.

Hope this helps.


That clear things up any?

./tch



On Wed, Aug 6, 2008 at 3:58 PM, Hugo Garcia <hgarcia@xxxxxxxxxxxx> wrote:
> Ok... lets document how the newbie does it :)
>
> First off....
>
> What is the difference between the following and is there one that is
> more recommended that the others?
>
> With the above features, it is possible for client code to obtain an
> EntityManagerFactory three different ways:
>
>   1. Using the standard Java Persistence API with configuration
> behind the scenes using OSGi services and Manifest properties for
> configuration. See "org.eclipse.persistence.demo.jpa.osgi.spi" for an
> example.


>   2. Using the standard Java Persistence API--classloader to use for
> a given persistence unit passed in a property to
> createEntityManagerFactory instead of Manifest configuration. See
> "org.eclipse.persistence.demo.jpa.osgi.spi.classloader" for an
> example.
>   3. Using EclipseLink OSGi specific JPA Persistence Provider
> requiring no OSGi configuration. See
> "org.eclipse.persistence.demo.jpa.osgi.provider" for an example
>
> -H
> _______________________________________________
> eclipselink-users mailing list
> eclipselink-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/eclipselink-users
>


Back to the top