Skip to content

Commit

Permalink
HHH-10044 automatically add hibernate-core and hibernate-entitymanage…
Browse files Browse the repository at this point in the history
…r Bundles to OsgiClassLoader
  • Loading branch information
brmeyer committed Aug 25, 2015
1 parent 45cea33 commit 53e81a2
Showing 1 changed file with 10 additions and 0 deletions.
Expand Up @@ -6,7 +6,10 @@
*/
package org.hibernate.osgi;

import org.hibernate.SessionFactory;
import org.hibernate.jpa.HibernateEntityManagerFactory;
import org.osgi.framework.Bundle;
import org.osgi.framework.FrameworkUtil;
import org.osgi.framework.ServiceFactory;
import org.osgi.framework.ServiceRegistration;

Expand Down Expand Up @@ -36,8 +39,15 @@ public OsgiPersistenceProviderService(
@Override
public Object getService(Bundle requestingBundle, ServiceRegistration registration) {
final OsgiClassLoader osgiClassLoader = new OsgiClassLoader();

// First, add the client bundle that's requesting the OSGi services.
osgiClassLoader.addBundle( requestingBundle );

// Then, automatically add hibernate-core and hibernate-entitymanager. These are needed to load resources
// contained in those jars, such as em's persistence.xml schemas.
osgiClassLoader.addBundle( FrameworkUtil.getBundle( SessionFactory.class ) );
osgiClassLoader.addBundle( FrameworkUtil.getBundle( HibernateEntityManagerFactory.class ) );

// Some "boot time" code does still rely on TCCL. "run time" code should all be using
// ClassLoaderService now.

Expand Down

0 comments on commit 53e81a2

Please sign in to comment.