[#1572] Use Thread.currentThread().getContextClassLoader() to load

ExecuteListener classes as a workaround for experienced class
loading problems when using OSGi
This commit is contained in:
Lukas Eder 2012-07-15 15:44:55 +02:00
parent 15c5df4036
commit 33aa730bfd

View File

@ -55,8 +55,6 @@ import java.sql.Statement;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.regex.Pattern;
import javax.persistence.Column;
@ -107,11 +105,6 @@ final class Util {
*/
private static Boolean isJPAAvailable;
/**
* A cache for {@link ExecuteListener} classes
*/
private static final Map<String, Class<?>> EXECUTE_LISTENERS = new ConcurrentHashMap<String, Class<?>>();
/**
* A pattern for the JDBC escape syntax
*/
@ -945,13 +938,11 @@ final class Util {
private static final ExecuteListener getListener(String name) {
try {
Class<?> type = EXECUTE_LISTENERS.get(name);
if (type == null) {
type = Class.forName(name);
EXECUTE_LISTENERS.put(name, type);
}
// [#1572] Loading classes like this is needed for class loading to
// work with OSGi. [#1578] The current implementation of loading
// ExecuteListeners will be reworked in jOOQ 3.0, though
Class<?> type = Thread.currentThread().getContextClassLoader().loadClass(name);
return (ExecuteListener) Reflect.accessible(type.getDeclaredConstructor()).newInstance();
}
catch (Exception e) {