use of org.vertexium.GraphConfiguration in project vertexium by visallo.
the class KryoVertexiumSerializerTest method before.
@Before
public void before() {
System.gc();
Map<String, Object> config = new HashMap<>();
config.put(QuickKryoVertexiumSerializer.CONFIG_COMPRESS, compress);
shouldAssertTiming = !compress;
iterations = compress ? 100 : 100000;
graphConfiguration = new GraphConfiguration(config);
}
use of org.vertexium.GraphConfiguration in project vertexium by visallo.
the class ConfigurationUtils method createProvider.
@SuppressWarnings("unchecked")
public static <T> T createProvider(String className, Graph graph, GraphConfiguration config) throws VertexiumException {
checkNotNull(className, "className is required");
className = className.trim();
LOGGER.debug("creating provider '%s'", className);
Class<Graph> graphClass = Graph.class;
Class<GraphConfiguration> graphConfigurationClass = GraphConfiguration.class;
try {
Class<?> clazz = Class.forName(className);
try {
Constructor constructor;
try {
constructor = clazz.getConstructor(graphClass);
return (T) constructor.newInstance(graph);
} catch (NoSuchMethodException ignore1) {
try {
constructor = clazz.getConstructor(graphClass, graphConfigurationClass);
return (T) constructor.newInstance(graph, config);
} catch (NoSuchMethodException ignore2) {
try {
constructor = clazz.getConstructor(graphConfigurationClass);
return (T) constructor.newInstance(config);
} catch (NoSuchMethodException ignore3) {
try {
constructor = clazz.getConstructor(Map.class);
return (T) constructor.newInstance(config.getConfig());
} catch (NoSuchMethodException ignoreInner) {
constructor = clazz.getConstructor();
return (T) constructor.newInstance();
}
}
}
}
} catch (IllegalArgumentException e) {
StringBuilder possibleMatches = new StringBuilder();
for (Constructor<?> s : clazz.getConstructors()) {
possibleMatches.append(s.toGenericString());
possibleMatches.append(", ");
}
throw new VertexiumException("Invalid constructor for " + className + ". Expected <init>(" + graphConfigurationClass.getName() + "). Found: " + possibleMatches, e);
}
} catch (NoSuchMethodException e) {
throw new VertexiumException("Provider must have a single argument constructor taking a " + graphConfigurationClass.getName(), e);
} catch (ClassNotFoundException e) {
throw new VertexiumException("No provider found with class name " + className, e);
} catch (Exception e) {
throw new VertexiumException(e);
}
}
Aggregations