HHH-8759 removed java 7 dependency in OsgiClassLoader

This commit is contained in:
Brett Meyer 2013-12-02 10:19:08 -05:00
parent d430846076
commit 685e33ae0c
1 changed files with 23 additions and 25 deletions

View File

@ -62,35 +62,33 @@ public class OsgiClassLoader extends ClassLoader {
@Override
@SuppressWarnings("rawtypes")
protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException {
synchronized (getClassLoadingLock(name)) {
if ( classCache.containsKey( name ) ) {
return classCache.get( name );
}
for ( Bundle bundle : bundles ) {
try {
final Class clazz = bundle.loadClass( name );
if ( clazz != null ) {
classCache.put( name, clazz );
return clazz;
}
}
catch ( Exception ignore ) {
if ( classCache.containsKey( name ) ) {
return classCache.get( name );
}
for ( Bundle bundle : bundles ) {
try {
final Class clazz = bundle.loadClass( name );
if ( clazz != null ) {
classCache.put( name, clazz );
return clazz;
}
}
for ( ClassLoader classLoader : classLoaders ) {
try {
final Class clazz = classLoader.loadClass( name );
if ( clazz != null ) {
classCache.put( name, clazz );
return clazz;
}
}
catch ( Exception ignore ) {
catch ( Exception ignore ) {
}
}
for ( ClassLoader classLoader : classLoaders ) {
try {
final Class clazz = classLoader.loadClass( name );
if ( clazz != null ) {
classCache.put( name, clazz );
return clazz;
}
}
}
catch ( Exception ignore ) {
}
}
throw new ClassNotFoundException( "Could not load requested class : " + name );
}