mirror of
https://github.com/russ-p/external-sql.git
synced 2025-12-14 09:24:25 +00:00
add classloader as param for factory
This commit is contained in:
@@ -11,6 +11,16 @@ import net.bytebuddy.matcher.ElementMatchers;
|
|||||||
|
|
||||||
public class ExternalSQLFactory {
|
public class ExternalSQLFactory {
|
||||||
|
|
||||||
|
private final ClassLoader classLoader;
|
||||||
|
|
||||||
|
public ExternalSQLFactory() {
|
||||||
|
this(ExternalSQLFactory.class.getClassLoader());
|
||||||
|
}
|
||||||
|
|
||||||
|
public ExternalSQLFactory(ClassLoader classLoader) {
|
||||||
|
this.classLoader = classLoader;
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public <T> T create(Class<T> clazz) throws IOException, InstantiationException, IllegalAccessException {
|
public <T> T create(Class<T> clazz) throws IOException, InstantiationException, IllegalAccessException {
|
||||||
ExternalSQL anno = clazz.getAnnotation(ExternalSQL.class);
|
ExternalSQL anno = clazz.getAnnotation(ExternalSQL.class);
|
||||||
@@ -35,7 +45,7 @@ public class ExternalSQLFactory {
|
|||||||
|
|
||||||
Class<?> dynamicType = intercept
|
Class<?> dynamicType = intercept
|
||||||
.make()
|
.make()
|
||||||
.load(getClass().getClassLoader())
|
.load(classLoader)
|
||||||
.getLoaded();
|
.getLoaded();
|
||||||
|
|
||||||
return (T) dynamicType.newInstance();
|
return (T) dynamicType.newInstance();
|
||||||
|
|||||||
Reference in New Issue
Block a user