Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[eclipselink-users] Entities in multiple bundles

Hi Shaun,  thanks for the clarification.  I wrote a hack to start the necessary bundles, and EclipseLink is initializing correctly.

I'd like to finally start working on an enhancement that allows for the declaration of entities in an extension point, and the ability for a persistence unit to span multiple bundles: https://bugs.eclipse.org/bugs/show_bug.cgi?id=226425

One of the major issues that has to be resolved is the class loader.  I'm guessing that the notion of a single class loader is prevalent throughout the code and adding support for searching multiple class loaders would be prohibitive.  Correct?

I'm thinking the best approach might be to create an extension of PersistenceProvider.  I would use the class loader from the extension bundle as the class loader for the EntityManagerFactory, and use "Eclipse-BuddyPolicy: dependent" so that the entities could be found.  This approach does limit the use to Equinox; however, since it's an extension, it's optional.  I also believe there is interest in solving this class loading problem within OSGi which would then make this extension usable across other implementations of OSGi.

Thoughts?

Bryan

On Nov 4, 2008, at 12:36 PM, Shaun Smith wrote:

Hi Bryan,

   We've coded to generic OSGi and AFAIK there is no generic way to say a bundle should be started.  But I don't see any reason why we couldn't include an Equinox (or other implementation specific) manifest entry though.  Can you file bug for this?  We also need to start the org.eclipse.persistence.jpa bundle.

    In answer to your question: yes you do need to start the bundle yourself.  I set this as part of my launch configuration for OSGi apps using PDE.  It seems to be harder in an RCP app as the PDE launcher doesn't let you set start levels.  You seem to have to put everything into a config.ini file.  I'd love to hear about a simpler way.

    FYI, the resolver behind javax.persistence.Persistence sets up a service tracker that provides an OSGi friendly way of locating persistence providers.  If you don't care if you're directly coupled to EclipseLink then you can go around the JPA SPI interface and directly instantiate org.eclipse.persistence.jpa.osgi.PersistenceProvider and create your EntityManagerFactory.  This is probably the simplest thing to do in an RCP app as it is "service-less".  However you do need to pass in a classloader that can see your persistence.xml, orm.xml, and Entities, e.g.,

            HashMap<String, Object> properties = new HashMap<String, Object>();
            ClassLoader classLoader = this.getClass().getClassLoader();
            properties.put(PersistenceUnitProperties.CLASSLOADER, classLoader);
            new PersistenceProvider().createEntityManagerFactory(puName, properties);

    Shaun

Bryan Hunt wrote:
The Activator in javax.persistence sets the provider resolver to the Activator, but the manifest is set to not automatically activate the bundle.  Is the default provider resolver supposed to be used, or do I manually have to start the bundle?

Bryan
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users

--


<oracle_sig_logo.gif>
Shaun Smith | Principal Product Manager, TopLink | +1.905.502.3094
Oracle Fusion Middleware
110 Matheson Boulevard West, Suite 100
Mississauga, Ontario, Canada L5R 3P4
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users


Back to the top