diff --git a/src/main/java/com/syncleus/ferma/framefactories/annotation/AbstractAnnotationFrameFactory.java b/src/main/java/com/syncleus/ferma/framefactories/annotation/AbstractAnnotationFrameFactory.java index 88bbaa5652..ffc573f25f 100644 --- a/src/main/java/com/syncleus/ferma/framefactories/annotation/AbstractAnnotationFrameFactory.java +++ b/src/main/java/com/syncleus/ferma/framefactories/annotation/AbstractAnnotationFrameFactory.java @@ -38,13 +38,19 @@ public class AbstractAnnotationFrameFactory implements FrameFactory { protected final Map, MethodHandler> methodHandlers = new HashMap<>(); private final ReflectionCache reflectionCache; private final Map constructedClassCache = new HashMap<>(); + private final ClassLoader defaultClassLoader; - protected AbstractAnnotationFrameFactory(final ReflectionCache reflectionCache, Set handlers) { + protected AbstractAnnotationFrameFactory(final ClassLoader defaultClassLoader, final ReflectionCache reflectionCache, Set handlers) { + this.defaultClassLoader = defaultClassLoader; this.reflectionCache = reflectionCache; for(MethodHandler handler : handlers) this.methodHandlers.put(handler.getAnnotationType(), handler); } + protected AbstractAnnotationFrameFactory(final ReflectionCache reflectionCache, Set handlers) { + this(AnnotationFrameFactory.class.getClassLoader(), reflectionCache, handlers); + } + private static boolean isAbstract(final Class clazz) { return Modifier.isAbstract(clazz.getModifiers()); } @@ -108,7 +114,7 @@ else if (element instanceof Edge && !EdgeFrame.class.isAssignableFrom(clazz)) } } - constructedClass = classBuilder.make().load(AnnotationFrameFactory.class.getClassLoader(), ClassLoadingStrategy.Default.WRAPPER).getLoaded(); + constructedClass = classBuilder.make().load(defaultClassLoader, ClassLoadingStrategy.Default.WRAPPER).getLoaded(); this.constructedClassCache.put(clazz, constructedClass); return constructedClass; } diff --git a/src/main/java/com/syncleus/ferma/framefactories/annotation/AnnotationFrameFactory.java b/src/main/java/com/syncleus/ferma/framefactories/annotation/AnnotationFrameFactory.java index 7cd9f69fcd..a65dde72d1 100644 --- a/src/main/java/com/syncleus/ferma/framefactories/annotation/AnnotationFrameFactory.java +++ b/src/main/java/com/syncleus/ferma/framefactories/annotation/AnnotationFrameFactory.java @@ -15,25 +15,16 @@ */ package com.syncleus.ferma.framefactories.annotation; -import com.syncleus.ferma.framefactories.FrameFactory; import com.syncleus.ferma.*; -import net.bytebuddy.ByteBuddy; -import net.bytebuddy.description.modifier.FieldManifestation; -import net.bytebuddy.description.modifier.Visibility; -import net.bytebuddy.dynamic.DynamicType; -import net.bytebuddy.dynamic.loading.ClassLoadingStrategy; -import net.bytebuddy.implementation.FieldAccessor; -import org.apache.tinkerpop.gremlin.structure.Edge; -import org.apache.tinkerpop.gremlin.structure.Element; -import org.apache.tinkerpop.gremlin.structure.Vertex; -import java.lang.annotation.Annotation; -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; import java.util.*; public class AnnotationFrameFactory extends AbstractAnnotationFrameFactory { + public AnnotationFrameFactory(final ClassLoader defaultClassLoader, final ReflectionCache reflectionCache) { + super(defaultClassLoader, reflectionCache, collectHandlers(null)); + } + public AnnotationFrameFactory(final ReflectionCache reflectionCache) { super(reflectionCache, collectHandlers(null)); }