Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,19 @@ public class AbstractAnnotationFrameFactory implements FrameFactory {
protected final Map<Class<? extends Annotation>, MethodHandler> methodHandlers = new HashMap<>();
private final ReflectionCache reflectionCache;
private final Map<Class, Class> constructedClassCache = new HashMap<>();
private final ClassLoader defaultClassLoader;

protected AbstractAnnotationFrameFactory(final ReflectionCache reflectionCache, Set<MethodHandler> handlers) {
protected AbstractAnnotationFrameFactory(final ClassLoader defaultClassLoader, final ReflectionCache reflectionCache, Set<MethodHandler> handlers) {
this.defaultClassLoader = defaultClassLoader;
this.reflectionCache = reflectionCache;
for(MethodHandler handler : handlers)
this.methodHandlers.put(handler.getAnnotationType(), handler);
}

protected AbstractAnnotationFrameFactory(final ReflectionCache reflectionCache, Set<MethodHandler> handlers) {
this(AnnotationFrameFactory.class.getClassLoader(), reflectionCache, handlers);
}

private static boolean isAbstract(final Class<?> clazz) {
return Modifier.isAbstract(clazz.getModifiers());
}
Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down