com.tinkerpop.frames.modules.javahandler.JavaMethodHandler Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of frames Show documentation
Show all versions of frames Show documentation
Frames is a framework for exposing the elements of a Blueprints graph as Java objects.
Instead of writing software in terms of vertices and edges, with Frames,
software is written in terms of domain objects and their relationships to each other.
package com.tinkerpop.frames.modules.javahandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import com.tinkerpop.blueprints.Element;
import com.tinkerpop.frames.FramedGraph;
import com.tinkerpop.frames.util.ExceptionUtils;
class JavaMethodHandler implements
com.tinkerpop.frames.modules.MethodHandler {
private JavaHandlerModule module;
JavaMethodHandler(JavaHandlerModule module) {
this.module = module;
}
@Override
public Class getAnnotationType() {
return JavaHandler.class;
}
@Override
public Object processElement(Object framedElement, Method method,
Object[] arguments, JavaHandler annotation,
FramedGraph> framedGraph, Element element) {
try {
Object handler = module.createHandler(framedElement, framedGraph, element, method.getDeclaringClass(), method);
return method.invoke(handler, arguments);
} catch (IllegalArgumentException e) {
throw new JavaHandlerException("Problem calling Java handler", e);
} catch (IllegalAccessException e) {
throw new JavaHandlerException("Problem calling Java handler", e);
} catch (InvocationTargetException e) {
ExceptionUtils.sneakyThrow(e.getTargetException());
return null;
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy