HHH-8818 TcclSafeAggregatedClassLoader

This commit is contained in:
Brett Meyer 2014-04-25 11:53:11 -04:00
parent 48d2c79889
commit 9d46f517dd
1 changed files with 27 additions and 1 deletions

View File

@ -387,7 +387,8 @@ public class ClassLoaderServiceImpl implements ClassLoaderService {
boolean set = false;
try {
Thread.currentThread().setContextClassLoader( aggregatedClassLoader );
Thread.currentThread().setContextClassLoader(
new TcclSafeAggregatedClassLoader( aggregatedClassLoader, tccl ) );
set = true;
}
catch (Exception ignore) {
@ -404,4 +405,29 @@ public class ClassLoaderServiceImpl implements ClassLoaderService {
}
// TODO: Remove in ORM 5! See HHH-8818
private class TcclSafeAggregatedClassLoader extends ClassLoader {
private final AggregatedClassLoader aggregatedClassLoader;
private TcclSafeAggregatedClassLoader(AggregatedClassLoader aggregatedClassLoader, ClassLoader tccl) {
super(tccl);
this.aggregatedClassLoader = aggregatedClassLoader;
}
@Override
public Enumeration<URL> getResources(String name) throws IOException {
return aggregatedClassLoader.getResources( name );
}
@Override
protected URL findResource(String name) {
return aggregatedClassLoader.findResource( name );
}
@Override
protected Class<?> findClass(String name) throws ClassNotFoundException {
return aggregatedClassLoader.findClass( name );
}
}
}