TINKERPOP-1562 Added SparkGremlinPlugin SparkGremlinPlugin required binding injections so a BindingCustomizer was added along with two implementations - one for direct assignment and one for lazy assignment.
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/f88af07a Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/f88af07a Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/f88af07a Branch: refs/heads/TINKERPOP-1562 Commit: f88af07abd131e9973887d9945a438de985906c0 Parents: 05727e2 Author: Stephen Mallette <sp...@genoprime.com> Authored: Tue Nov 22 10:57:32 2016 -0500 Committer: Stephen Mallette <sp...@genoprime.com> Committed: Thu Dec 1 06:41:42 2016 -0500 ---------------------------------------------------------------------- .../gremlin/console/plugin/PluggedIn.groovy | 3 + .../groovy/plugin/GremlinPluginAdapterTest.java | 63 ++++++++++++++ .../gremlin/jsr223/BindingsCustomizer.java | 33 +++++++ .../jsr223/DefaultBindingsCustomizer.java | 40 +++++++++ .../gremlin/jsr223/ImportGremlinPlugin.java | 16 ++++ .../jsr223/console/LazyBindingsCustomizer.java | 41 +++++++++ .../gremlin/groovy/engine/GremlinExecutor.java | 6 +- .../spark/groovy/plugin/SparkGremlinPlugin.java | 2 + .../spark/jsr223/SparkGremlinPlugin.java | 92 ++++++++++++++++++++ .../jsr223/TinkerGraphGremlinPlugin.java | 46 +++++----- 10 files changed, 317 insertions(+), 25 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f88af07a/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/plugin/PluggedIn.groovy ---------------------------------------------------------------------- diff --git a/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/plugin/PluggedIn.groovy b/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/plugin/PluggedIn.groovy index d298cd7..b707226 100644 --- a/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/plugin/PluggedIn.groovy +++ b/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/plugin/PluggedIn.groovy @@ -24,6 +24,7 @@ import org.apache.tinkerpop.gremlin.groovy.plugin.PluginAcceptor import org.apache.tinkerpop.gremlin.groovy.plugin.PluginInitializationException import org.apache.tinkerpop.gremlin.groovy.plugin.RemoteAcceptor import org.apache.tinkerpop.gremlin.groovy.plugin.RemoteException +import org.apache.tinkerpop.gremlin.jsr223.BindingsCustomizer import org.apache.tinkerpop.gremlin.jsr223.ImportCustomizer import org.apache.tinkerpop.gremlin.jsr223.ScriptCustomizer import org.apache.tinkerpop.gremlin.jsr223.console.ConsoleCustomizer @@ -88,6 +89,8 @@ class PluggedIn { pluginAcceptor.addImports(imports) } else if (it instanceof ScriptCustomizer) { it.getScripts().collect { it.join(LINE_SEPARATOR) }.each { pluginAcceptor.eval(it) } + } else if (it instanceof BindingsCustomizer) { + it.bindings.entrySet().each { k, v -> pluginAcceptor.addBinding(k,v) } } } } http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f88af07a/gremlin-console/src/test/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/GremlinPluginAdapterTest.java ---------------------------------------------------------------------- diff --git a/gremlin-console/src/test/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/GremlinPluginAdapterTest.java b/gremlin-console/src/test/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/GremlinPluginAdapterTest.java new file mode 100644 index 0000000..77422da --- /dev/null +++ b/gremlin-console/src/test/java/org/apache/tinkerpop/gremlin/console/groovy/plugin/GremlinPluginAdapterTest.java @@ -0,0 +1,63 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tinkerpop.gremlin.console.groovy.plugin; + +import org.apache.tinkerpop.gremlin.console.plugin.PluggedIn; +import org.apache.tinkerpop.gremlin.jsr223.BindingsCustomizer; +import org.apache.tinkerpop.gremlin.jsr223.ImportGremlinPlugin; +import org.apache.tinkerpop.gremlin.jsr223.ScriptCustomizer; +import org.apache.tinkerpop.gremlin.jsr223.ScriptFileGremlinPlugin; +import org.junit.Test; + +import java.time.DayOfWeek; +import java.time.temporal.TemporalAccessor; +import java.util.Set; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.IsCollectionContaining.hasItems; +import static org.junit.Assert.assertEquals; + +/** + * @author Stephen Mallette (http://stephen.genoprime.com) + */ +public class GremlinPluginAdapterTest { + + @Test + public void shouldAdaptForImportCustomizer() throws Exception { + final ImportGremlinPlugin plugin = ImportGremlinPlugin.build() + .classImports(java.awt.Color.class, java.sql.CallableStatement.class) + .enumImports(DayOfWeek.SATURDAY, DayOfWeek.SUNDAY) + .methodImports(DayOfWeek.class.getMethod("from", TemporalAccessor.class), DayOfWeek.class.getMethod("values")).create(); + final PluggedIn.GremlinPluginAdapter adapter = new PluggedIn.GremlinPluginAdapter(plugin); + + assertEquals(plugin.getName(), adapter.getName()); + + final SpyPluginAcceptor spy = new SpyPluginAcceptor(); + adapter.pluginTo(spy); + + final Set<String> imports = spy.getImports(); + assertEquals(6, imports.size()); + assertThat(imports, hasItems("import " + java.awt.Color.class.getCanonicalName())); + assertThat(imports, hasItems("import " + java.sql.CallableStatement.class.getCanonicalName())); + assertThat(imports, hasItems("import static " + DayOfWeek.class.getCanonicalName() + "." + DayOfWeek.SATURDAY.name())); + assertThat(imports, hasItems("import static " + DayOfWeek.class.getCanonicalName() + "." + DayOfWeek.SUNDAY.name())); + assertThat(imports, hasItems("import static " + DayOfWeek.class.getCanonicalName() + ".from")); + assertThat(imports, hasItems("import static " + DayOfWeek.class.getCanonicalName() + ".values")); + } +} http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f88af07a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/BindingsCustomizer.java ---------------------------------------------------------------------- diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/BindingsCustomizer.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/BindingsCustomizer.java new file mode 100644 index 0000000..02c129e --- /dev/null +++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/BindingsCustomizer.java @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tinkerpop.gremlin.jsr223; + +import javax.script.Bindings; + +/** + * Provides a way to alter the bindings on a {@link GremlinScriptEngine}. + * + * @author Stephen Mallette (http://stephen.genoprime.com) + */ +public interface BindingsCustomizer extends Customizer { + /** + * Gets the bindings to add to a {@link GremlinScriptEngine}. + */ + public Bindings getBindings(); +} http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f88af07a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/DefaultBindingsCustomizer.java ---------------------------------------------------------------------- diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/DefaultBindingsCustomizer.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/DefaultBindingsCustomizer.java new file mode 100644 index 0000000..0073d39 --- /dev/null +++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/DefaultBindingsCustomizer.java @@ -0,0 +1,40 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tinkerpop.gremlin.jsr223; + +import javax.script.Bindings; + +/** + * Default implementation of the {@link BindingsCustomizer}. + * + * @author Stephen Mallette (http://stephen.genoprime.com) + */ +public class DefaultBindingsCustomizer implements BindingsCustomizer { + + private final Bindings bindings; + + public DefaultBindingsCustomizer(final Bindings bindings) { + this.bindings = bindings; + } + + @Override + public Bindings getBindings() { + return bindings; + } +} http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f88af07a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/ImportGremlinPlugin.java ---------------------------------------------------------------------- diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/ImportGremlinPlugin.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/ImportGremlinPlugin.java index a5ac278..26290d3 100644 --- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/ImportGremlinPlugin.java +++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/ImportGremlinPlugin.java @@ -20,6 +20,7 @@ package org.apache.tinkerpop.gremlin.jsr223; import java.lang.reflect.Method; import java.lang.reflect.Modifier; +import java.util.Arrays; import java.util.Collection; import java.util.HashSet; import java.util.List; @@ -69,6 +70,11 @@ public final class ImportGremlinPlugin extends AbstractGremlinPlugin { return this; } + public Builder classImports(final Class<?>... classes) { + classImports.addAll(Arrays.asList(classes)); + return this; + } + public Builder classImports(final Collection<String> classes) { for (String clazz : classes) { try { @@ -108,6 +114,11 @@ public final class ImportGremlinPlugin extends AbstractGremlinPlugin { return this; } + public Builder methodImports(final Method... methods) { + methodImports.addAll(Arrays.asList(methods)); + return this; + } + public Builder enumImports(final Collection<String> enums) { for (String enumItem : enums) { try { @@ -138,6 +149,11 @@ public final class ImportGremlinPlugin extends AbstractGremlinPlugin { return this; } + public Builder enumImports(final Enum... enums) { + enumImports.addAll(Arrays.asList(enums)); + return this; + } + public ImportGremlinPlugin create() { if (enumImports.isEmpty() && classImports.isEmpty() && methodImports.isEmpty()) throw new IllegalStateException("At least one import must be specified"); http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f88af07a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/console/LazyBindingsCustomizer.java ---------------------------------------------------------------------- diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/console/LazyBindingsCustomizer.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/console/LazyBindingsCustomizer.java new file mode 100644 index 0000000..f21a2ab --- /dev/null +++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/console/LazyBindingsCustomizer.java @@ -0,0 +1,41 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tinkerpop.gremlin.jsr223.console; + +import org.apache.tinkerpop.gremlin.jsr223.BindingsCustomizer; + +import javax.script.Bindings; +import java.util.function.Supplier; + +/** + * @author Stephen Mallette (http://stephen.genoprime.com) + */ +public class LazyBindingsCustomizer implements BindingsCustomizer { + + private final Supplier<Bindings> bindingsSupplier; + + public LazyBindingsCustomizer(final Supplier<Bindings> bindingsSupplier) { + this.bindingsSupplier = bindingsSupplier; + } + + @Override + public Bindings getBindings() { + return bindingsSupplier.get(); + } +} http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f88af07a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/engine/GremlinExecutor.java ---------------------------------------------------------------------- diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/engine/GremlinExecutor.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/engine/GremlinExecutor.java index 84f1992..87d5728 100644 --- a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/engine/GremlinExecutor.java +++ b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/engine/GremlinExecutor.java @@ -447,7 +447,11 @@ public class GremlinExecutor implements AutoCloseable { final Map<String, Object> customizerConfigs = pluginConfig.getValue(); final Method[] methods = builderClazz.getMethods(); for (Map.Entry<String, Object> customizerConfig : customizerConfigs.entrySet()) { - final Method configMethod = Stream.of(methods).filter(m -> m.getName().equals(customizerConfig.getKey())).findFirst() + final Method configMethod = Stream.of(methods).filter(m -> { + final Class<?> type = customizerConfig.getValue().getClass(); + return m.getName().equals(customizerConfig.getKey()) && m.getParameters().length <= 1 + && m.getParameters()[0].getType().isAssignableFrom(type); + }).findFirst() .orElseThrow(() -> new IllegalStateException("Could not find builder method on " + builderClazz.getCanonicalName())); if (null == customizerConfig.getValue()) pluginBuilder = configMethod.invoke(pluginBuilder); http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f88af07a/spark-gremlin/src/main/java/org/apache/tinkerpop/gremlin/spark/groovy/plugin/SparkGremlinPlugin.java ---------------------------------------------------------------------- diff --git a/spark-gremlin/src/main/java/org/apache/tinkerpop/gremlin/spark/groovy/plugin/SparkGremlinPlugin.java b/spark-gremlin/src/main/java/org/apache/tinkerpop/gremlin/spark/groovy/plugin/SparkGremlinPlugin.java index 1fe23e3..c6eb682 100644 --- a/spark-gremlin/src/main/java/org/apache/tinkerpop/gremlin/spark/groovy/plugin/SparkGremlinPlugin.java +++ b/spark-gremlin/src/main/java/org/apache/tinkerpop/gremlin/spark/groovy/plugin/SparkGremlinPlugin.java @@ -34,7 +34,9 @@ import java.util.Set; /** * @author Marko A. Rodriguez (http://markorodriguez.com) + * @deprecated As of release 3.2.4, replaced by {@link org.apache.tinkerpop.gremlin.spark.jsr223.SparkGremlinPlugin}. */ +@Deprecated public final class SparkGremlinPlugin extends AbstractGremlinPlugin { protected static String NAME = "tinkerpop.spark"; http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f88af07a/spark-gremlin/src/main/java/org/apache/tinkerpop/gremlin/spark/jsr223/SparkGremlinPlugin.java ---------------------------------------------------------------------- diff --git a/spark-gremlin/src/main/java/org/apache/tinkerpop/gremlin/spark/jsr223/SparkGremlinPlugin.java b/spark-gremlin/src/main/java/org/apache/tinkerpop/gremlin/spark/jsr223/SparkGremlinPlugin.java new file mode 100644 index 0000000..840f593 --- /dev/null +++ b/spark-gremlin/src/main/java/org/apache/tinkerpop/gremlin/spark/jsr223/SparkGremlinPlugin.java @@ -0,0 +1,92 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tinkerpop.gremlin.spark.jsr223; + +import org.apache.tinkerpop.gremlin.jsr223.AbstractGremlinPlugin; +import org.apache.tinkerpop.gremlin.jsr223.BindingsCustomizer; +import org.apache.tinkerpop.gremlin.jsr223.DefaultImportCustomizer; +import org.apache.tinkerpop.gremlin.jsr223.ImportCustomizer; +import org.apache.tinkerpop.gremlin.jsr223.console.LazyBindingsCustomizer; +import org.apache.tinkerpop.gremlin.spark.process.computer.CombineIterator; +import org.apache.tinkerpop.gremlin.spark.process.computer.MapIterator; +import org.apache.tinkerpop.gremlin.spark.process.computer.MemoryAccumulator; +import org.apache.tinkerpop.gremlin.spark.process.computer.ReduceIterator; +import org.apache.tinkerpop.gremlin.spark.process.computer.SparkExecutor; +import org.apache.tinkerpop.gremlin.spark.process.computer.SparkGraphComputer; +import org.apache.tinkerpop.gremlin.spark.process.computer.SparkMemory; +import org.apache.tinkerpop.gremlin.spark.process.computer.SparkMessenger; +import org.apache.tinkerpop.gremlin.spark.structure.Spark; +import org.apache.tinkerpop.gremlin.spark.structure.io.InputFormatRDD; +import org.apache.tinkerpop.gremlin.spark.structure.io.InputOutputHelper; +import org.apache.tinkerpop.gremlin.spark.structure.io.InputRDD; +import org.apache.tinkerpop.gremlin.spark.structure.io.InputRDDFormat; +import org.apache.tinkerpop.gremlin.spark.structure.io.OutputFormatRDD; +import org.apache.tinkerpop.gremlin.spark.structure.io.OutputRDD; +import org.apache.tinkerpop.gremlin.spark.structure.io.PersistedInputRDD; +import org.apache.tinkerpop.gremlin.spark.structure.io.PersistedOutputRDD; +import org.apache.tinkerpop.gremlin.spark.structure.io.SparkContextStorage; + +import javax.script.Bindings; +import javax.script.SimpleBindings; + +/** + * @author Marko A. Rodriguez (http://markorodriguez.com) + * @author Stephen Mallette (http://stephen.genoprime.com) + */ +public final class SparkGremlinPlugin extends AbstractGremlinPlugin { + + protected static String NAME = "tinkerpop.spark"; + + private static final ImportCustomizer imports = DefaultImportCustomizer.build().addClassImports( + SparkGraphComputer.class, + CombineIterator.class, + MapIterator.class, + MemoryAccumulator.class, + ReduceIterator.class, + SparkExecutor.class, + SparkGraphComputer.class, + SparkMemory.class, + SparkMessenger.class, + Spark.class, + InputFormatRDD.class, + InputOutputHelper.class, + InputRDD.class, + InputRDDFormat.class, + OutputFormatRDD.class, + OutputRDD.class, + PersistedInputRDD.class, + PersistedOutputRDD.class, + SparkContextStorage.class).create(); + + private static final BindingsCustomizer bindings = new LazyBindingsCustomizer(() -> { + final Bindings bindings = new SimpleBindings(); + bindings.put("spark", SparkContextStorage.open()); + return bindings; + }); + + public SparkGremlinPlugin() { + super(NAME, imports, bindings); + } + + @Override + public boolean requireRestart() { + return true; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f88af07a/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/jsr223/TinkerGraphGremlinPlugin.java ---------------------------------------------------------------------- diff --git a/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/jsr223/TinkerGraphGremlinPlugin.java b/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/jsr223/TinkerGraphGremlinPlugin.java index 16a6cb5..68e649c 100644 --- a/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/jsr223/TinkerGraphGremlinPlugin.java +++ b/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/jsr223/TinkerGraphGremlinPlugin.java @@ -21,6 +21,7 @@ package org.apache.tinkerpop.gremlin.tinkergraph.jsr223; import org.apache.tinkerpop.gremlin.jsr223.AbstractGremlinPlugin; import org.apache.tinkerpop.gremlin.jsr223.Customizer; import org.apache.tinkerpop.gremlin.jsr223.DefaultImportCustomizer; +import org.apache.tinkerpop.gremlin.jsr223.ImportCustomizer; import org.apache.tinkerpop.gremlin.tinkergraph.process.computer.TinkerGraphComputer; import org.apache.tinkerpop.gremlin.tinkergraph.process.computer.TinkerGraphComputerView; import org.apache.tinkerpop.gremlin.tinkergraph.process.computer.TinkerMapEmitter; @@ -48,30 +49,27 @@ import java.util.Optional; public final class TinkerGraphGremlinPlugin extends AbstractGremlinPlugin { private static final String MODULE_NAME = "tinkerpop.tinkergraph"; - public TinkerGraphGremlinPlugin() { - super(MODULE_NAME, DefaultImportCustomizer.build().addClassImports( - TinkerEdge.class, - TinkerElement.class, - TinkerFactory.class, - TinkerGraph.class, - TinkerGraphVariables.class, - TinkerHelper.class, - TinkerIoRegistry.class, - TinkerIoRegistryV2d0.class, - TinkerProperty.class, - TinkerVertex.class, - TinkerVertexProperty.class, - TinkerGraphComputer.class, - TinkerGraphComputerView.class, - TinkerMapEmitter.class, - TinkerMemory.class, - TinkerMessenger.class, - TinkerReduceEmitter.class, - TinkerWorkerPool.class).create()); - } + private static final ImportCustomizer imports = DefaultImportCustomizer.build() + .addClassImports(TinkerEdge.class, + TinkerElement.class, + TinkerFactory.class, + TinkerGraph.class, + TinkerGraphVariables.class, + TinkerHelper.class, + TinkerIoRegistry.class, + TinkerIoRegistryV2d0.class, + TinkerProperty.class, + TinkerVertex.class, + TinkerVertexProperty.class, + TinkerGraphComputer.class, + TinkerGraphComputerView.class, + TinkerMapEmitter.class, + TinkerMemory.class, + TinkerMessenger.class, + TinkerReduceEmitter.class, + TinkerWorkerPool.class).create(); - @Override - public Optional<Customizer[]> getCustomizers() { - return null; + public TinkerGraphGremlinPlugin() { + super(MODULE_NAME, imports); } }