diff --git a/hibernate-osgi/src/main/java/org/hibernate/osgi/OsgiClassLoader.java b/hibernate-osgi/src/main/java/org/hibernate/osgi/OsgiClassLoader.java index df77789489..376f6e5e00 100644 --- a/hibernate-osgi/src/main/java/org/hibernate/osgi/OsgiClassLoader.java +++ b/hibernate-osgi/src/main/java/org/hibernate/osgi/OsgiClassLoader.java @@ -23,6 +23,10 @@ */ package org.hibernate.osgi; +import org.osgi.framework.Bundle; +import org.osgi.framework.BundleReference; +import org.osgi.framework.wiring.BundleWiring; + import java.net.URL; import java.util.ArrayList; import java.util.Enumeration; @@ -33,10 +37,6 @@ import java.util.Map; import java.util.NoSuchElementException; import java.util.Set; -import org.osgi.framework.Bundle; -import org.osgi.framework.BundleReference; -import org.osgi.framework.wiring.BundleWiring; - /** * Custom OSGI ClassLoader helper which knows all the "interesting" * class loaders and bundles. Encapsulates the OSGi related CL capabilities. @@ -48,7 +48,6 @@ public class OsgiClassLoader extends ClassLoader { // Leave these as Sets -- addClassLoader or addBundle may be called more // than once if a SF or EMF is closed and re-created. private Set classLoaders = new LinkedHashSet(); - private Set bundles = new LinkedHashSet(); private Map> classCache = new HashMap>(); @@ -74,18 +73,6 @@ public class OsgiClassLoader extends ClassLoader { return classCache.get( name ); } - for ( Bundle bundle : bundles ) { - try { - Class clazz = bundle.loadClass( name ); - if ( clazz != null ) { - classCache.put( name, clazz ); - return clazz; - } - } - catch ( Exception ignore ) { - } - } - for ( ClassLoader classLoader : classLoaders ) { try { Class clazz = classLoader.loadClass( name ); @@ -113,18 +100,6 @@ public class OsgiClassLoader extends ClassLoader { return resourceCache.get( name ); } - for ( Bundle bundle : bundles ) { - try { - URL resource = bundle.getResource( name ); - if ( resource != null ) { - resourceCache.put( name, resource ); - return resource; - } - } - catch ( Exception ignore ) { - } - } - for ( ClassLoader classLoader : classLoaders ) { try { URL resource = classLoader.getResource( name ); @@ -154,17 +129,6 @@ public class OsgiClassLoader extends ClassLoader { protected Enumeration findResources(String name) { final List> enumerations = new ArrayList>(); - for ( Bundle bundle : bundles ) { - try { - Enumeration resources = bundle.getResources( name ); - if ( resources != null ) { - enumerations.add( resources ); - } - } - catch ( Exception ignore ) { - } - } - for ( ClassLoader classLoader : classLoaders ) { try { Enumeration resources = classLoader.getResources( name ); @@ -206,7 +170,7 @@ public class OsgiClassLoader extends ClassLoader { } public void addBundle( Bundle bundle ) { - addClassLoader( bundle.adapt(BundleWiring.class).getClassLoader() ); + addClassLoader( bundle.adapt( BundleWiring.class ).getClassLoader() ); } public void clear() {