HHH-10346 cleanup
This commit is contained in:
parent
d1e93c4a1b
commit
49e62304da
|
@ -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<ClassLoader> classLoaders = new LinkedHashSet<ClassLoader>();
|
||||
private Set<Bundle> bundles = new LinkedHashSet<Bundle>();
|
||||
|
||||
private Map<String, Class<?>> classCache = new HashMap<String, Class<?>>();
|
||||
|
||||
|
@ -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<URL> findResources(String name) {
|
||||
final List<Enumeration<URL>> enumerations = new ArrayList<Enumeration<URL>>();
|
||||
|
||||
for ( Bundle bundle : bundles ) {
|
||||
try {
|
||||
Enumeration<URL> resources = bundle.getResources( name );
|
||||
if ( resources != null ) {
|
||||
enumerations.add( resources );
|
||||
}
|
||||
}
|
||||
catch ( Exception ignore ) {
|
||||
}
|
||||
}
|
||||
|
||||
for ( ClassLoader classLoader : classLoaders ) {
|
||||
try {
|
||||
Enumeration<URL> 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() {
|
||||
|
|
Loading…
Reference in New Issue