本文整理汇总了Java中com.syncleus.ferma.ReflectionCache类的典型用法代码示例。如果您正苦于以下问题:Java ReflectionCache类的具体用法?Java ReflectionCache怎么用?Java ReflectionCache使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ReflectionCache类属于com.syncleus.ferma包,在下文中一共展示了ReflectionCache类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testCustomHandlers
import com.syncleus.ferma.ReflectionCache; //导入依赖的package包/类
@Test
public void testCustomHandlers() {
MethodHandler custom = Mockito.mock(AbstractMethodHandler.class, Mockito.CALLS_REAL_METHODS);
Class<? extends Annotation> annotation = Adjacency.class;
custom = Mockito.when(custom.getAnnotationType()).then(inv -> annotation).getMock();
custom = Mockito
.when(custom.processMethod(Mockito.any(), Mockito.any(), Mockito.any()))
.thenAnswer(inv -> inv.getArgumentAt(0, DynamicType.Builder.class))
.getMock();
AbstractAnnotationFrameFactory frameFactory = new AbstractAnnotationFrameFactory(new ReflectionCache(), Collections.singleton(custom)) {
};
DelegatingFramedGraph framedGraph = new DelegatingFramedGraph(fg.getBaseGraph(), frameFactory, new PolymorphicTypeResolver());
framedGraph.addFramedVertex(God.class);
Mockito.verify(custom, Mockito.atLeast(0)).getAnnotationType();
Mockito.verify(custom, Mockito.atLeastOnce()).processMethod(Mockito.any(), Mockito.any(), Mockito.any());
}
示例2: OrientTransactionFactoryImpl
import com.syncleus.ferma.ReflectionCache; //导入依赖的package包/类
/**
* Create a new orientdb transaction factory.
*
* @param factory
* @param annotationsSupported
* True if annotated classes will be supported, false otherwise.
* @param basePaths
*
*/
public OrientTransactionFactoryImpl(OrientGraphFactory factory, boolean annotationsSupported, String... basePaths) {
this.factory = factory;
this.typeResolver = new OrientDBTypeResolver(basePaths);
if (annotationsSupported) {
final ReflectionCache reflections = new ReflectionCache();
this.frameFactory = new AnnotationFrameFactory(reflections);
} else {
this.frameFactory = new DefaultFrameFactory();
}
}
示例3: AbstractAnnotationFrameFactory
import com.syncleus.ferma.ReflectionCache; //导入依赖的package包/类
protected AbstractAnnotationFrameFactory(final ClassLoader classLoader, final ReflectionCache reflectionCache, Set<MethodHandler> handlers)
{
this.classLoader = classLoader;
this.reflectionCache = reflectionCache;
for (MethodHandler handler : handlers)
this.methodHandlers.put(handler.getAnnotationType(), handler);
}
示例4: setUp
import com.syncleus.ferma.ReflectionCache; //导入依赖的package包/类
@Before
public void setUp() {
frameFactory = new AnnotationFrameFactory(new ReflectionCache());
fg = new DelegatingFramedGraph(TinkerGraph.open());
}
示例5: createFramed
import com.syncleus.ferma.ReflectionCache; //导入依赖的package包/类
private void createFramed(JanusGraph janusGraph)
{
this.graph = janusGraph;
final ClassLoader compositeClassLoader = classLoaderProvider.getCompositeClassLoader();
final ReflectionCache reflections = new ReflectionCache();
Set<MethodHandler> handlers = new HashSet<>();
handlers.add(new MapInPropertiesHandler());
handlers.add(new MapInAdjacentPropertiesHandler());
handlers.add(new MapInAdjacentVerticesHandler());
handlers.add(new SetInPropertiesHandler());
handlers.add(new JavaHandlerHandler());
handlers.add(new WindupPropertyMethodHandler());
handlers.add(new WindupAdjacencyMethodHandler());
AnnotationFrameFactory frameFactory = new AnnotationFrameFactory(compositeClassLoader, reflections, handlers);
/*
* We override a couple of key methods here, just to insure that we always have access to the change events.
*
* Hopefully this will be fixed in a future version of Ferma.
*
* https://github.com/Syncleus/Ferma/issues/44
*/
framed = new DelegatingFramedGraph<JanusGraph>(janusGraph, frameFactory, this.graphTypeManager) {
@Override
public <T> T addFramedVertex(final ClassInitializer<T> initializer, final Object... keyValues) {
final Vertex vertex;
final T framedVertex;
if( keyValues != null ) {
vertex = this.getBaseGraph().addVertex(keyValues);
framedVertex = frameNewElement(vertex, initializer);
}
else {
vertex = this.getBaseGraph().addVertex();
framedVertex = frameNewElement(vertex, initializer);
}
GraphContextImpl.this.mutationListener.vertexAdded(vertex);
return framedVertex;
}
@Override
public <T> T addFramedVertexExplicit(final ClassInitializer<T> initializer) {
Vertex vertex = this.getBaseGraph().addVertex();
final T framedVertex = frameNewElementExplicit(vertex, initializer);
GraphContextImpl.this.mutationListener.vertexAdded(vertex);
return framedVertex;
}
};
}
示例6: AnnotationFrameFactory
import com.syncleus.ferma.ReflectionCache; //导入依赖的package包/类
public AnnotationFrameFactory(final ClassLoader classLoader, final ReflectionCache reflectionCache) {
super(classLoader, reflectionCache, collectHandlers(null));
}
示例7: constructClass
import com.syncleus.ferma.ReflectionCache; //导入依赖的package包/类
private <E> Class<? extends E> constructClass(final Element element, final Class<E> clazz)
{
Class constructedClass = constructedClassCache.get(clazz);
if (constructedClass != null)
return constructedClass;
DynamicType.Builder<? extends E> classBuilder;
if (clazz.isInterface())
{
if (element instanceof Vertex)
classBuilder = (DynamicType.Builder<? extends E>) new ByteBuddy().subclass(AbstractVertexFrame.class);
else if (element instanceof Edge)
classBuilder = (DynamicType.Builder<? extends E>) new ByteBuddy().subclass(AbstractEdgeFrame.class);
else
throw new IllegalStateException("class is neither an Edge or a vertex!");
if (clazz.getCanonicalName().contains("ByteBuddy"))
{
// if the input class is itself a bytebuddy class, only take its interfaces
classBuilder = classBuilder.implement(clazz.getInterfaces());
}
else
{
classBuilder = classBuilder.implement(clazz);
}
}
else
{
if (!(element instanceof Vertex || element instanceof Edge))
throw new IllegalStateException("element is neither an edge nor a vertex");
else if (element instanceof Vertex && !VertexFrame.class.isAssignableFrom(clazz))
throw new IllegalStateException(clazz.getName() + " Class is not a type of VertexFrame");
else if (element instanceof Edge && !EdgeFrame.class.isAssignableFrom(clazz))
throw new IllegalStateException(clazz.getName() + " Class is not a type of EdgeFrame");
classBuilder = new ByteBuddy().subclass(clazz);
}
classBuilder = classBuilder.defineField("reflectionCache", ReflectionCache.class, Visibility.PRIVATE, FieldManifestation.PLAIN)
.implement(CachesReflection.class).intercept(FieldAccessor.ofBeanProperty());
/*
* Just a hack so that our generified frame types can work.
*
* This information will not really be used by the generated class.
*/
classBuilder = classBuilder.typeVariable("T");
// try and construct any abstract methods that are left
for (final Method method : clazz.getMethods())
if (isAbstract(method))
annotation_loop: for (final Annotation annotation : method.getAnnotations())
{
final MethodHandler handler = methodHandlers.get(annotation.annotationType());
if (handler != null)
{
classBuilder = handler.processMethod(classBuilder, method, annotation);
break;
}
}
DynamicType.Unloaded unloadedClass = classBuilder.make();
constructedClass = unloadedClass.load(this.classLoader, ClassLoadingStrategy.Default.WRAPPER).getLoaded();
this.constructedClassCache.put(clazz, constructedClass);
return constructedClass;
}
示例8: PolymorphicTypeResolver
import com.syncleus.ferma.ReflectionCache; //导入依赖的package包/类
/**
* Creates a new SimpleTypeResolver with a typing engine that can recognize the specified types. While these types
* still need to be included in a separate TypedModule they must be created here as well to ensure proper look-ups
* occur.
*
* @since 2.0.0
*/
public PolymorphicTypeResolver() {
this.reflectionCache = new ReflectionCache();
this.typeResolutionKey = TYPE_RESOLUTION_KEY;
}
示例9: getReflectionCache
import com.syncleus.ferma.ReflectionCache; //导入依赖的package包/类
ReflectionCache getReflectionCache();
示例10: setReflectionCache
import com.syncleus.ferma.ReflectionCache; //导入依赖的package包/类
void setReflectionCache(ReflectionCache hierarchy);