当前位置: 首页>>代码示例>>Java>>正文


Java ReflectionCache类代码示例

本文整理汇总了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());
}
 
开发者ID:Syncleus,项目名称:Ferma,代码行数:17,代码来源:AnnotationFrameFactoryTest.java

示例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();
	}
}
 
开发者ID:Syncleus,项目名称:Ferma-OrientDB,代码行数:21,代码来源:OrientTransactionFactoryImpl.java

示例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);
}
 
开发者ID:windup,项目名称:windup,代码行数:8,代码来源:AbstractAnnotationFrameFactory.java

示例4: setUp

import com.syncleus.ferma.ReflectionCache; //导入依赖的package包/类
@Before
public void setUp() {
    frameFactory = new AnnotationFrameFactory(new ReflectionCache());
    fg = new DelegatingFramedGraph(TinkerGraph.open());
}
 
开发者ID:Syncleus,项目名称:Ferma,代码行数:6,代码来源:AnnotationFrameFactoryTest.java

示例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;
        }
    };
}
 
开发者ID:windup,项目名称:windup,代码行数:53,代码来源:GraphContextImpl.java

示例6: AnnotationFrameFactory

import com.syncleus.ferma.ReflectionCache; //导入依赖的package包/类
public AnnotationFrameFactory(final ClassLoader classLoader, final ReflectionCache reflectionCache) {
    super(classLoader, reflectionCache, collectHandlers(null));
}
 
开发者ID:windup,项目名称:windup,代码行数:4,代码来源:AnnotationFrameFactory.java

示例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;
}
 
开发者ID:windup,项目名称:windup,代码行数:66,代码来源:AbstractAnnotationFrameFactory.java

示例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;
   }
 
开发者ID:Syncleus,项目名称:Ferma,代码行数:12,代码来源:PolymorphicTypeResolver.java

示例9: getReflectionCache

import com.syncleus.ferma.ReflectionCache; //导入依赖的package包/类
ReflectionCache getReflectionCache(); 
开发者ID:Syncleus,项目名称:Ferma,代码行数:2,代码来源:CachesReflection.java

示例10: setReflectionCache

import com.syncleus.ferma.ReflectionCache; //导入依赖的package包/类
void setReflectionCache(ReflectionCache hierarchy); 
开发者ID:Syncleus,项目名称:Ferma,代码行数:2,代码来源:CachesReflection.java


注:本文中的com.syncleus.ferma.ReflectionCache类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。