tinkerpop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rd...@apache.org
Subject [40/50] tinkerpop git commit: Fixed some issues with the plugin system.
Date Tue, 12 Sep 2017 23:52:49 GMT
Fixed some issues with the plugin system.

LabelP from neo4j needed to be imported as a class so that gremlin-python scriptengine could
load it. Enforced order on plugin application to ScriptEngines. Added javadocs. CTR


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/5ab53acc
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/5ab53acc
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/5ab53acc

Branch: refs/heads/TINKERPOP-1692
Commit: 5ab53acceac7b934dde94bbb4a5b0a0ceedec6bf
Parents: 6d34054
Author: Stephen Mallette <spmva@genoprime.com>
Authored: Tue Aug 29 08:33:06 2017 -0400
Committer: Stephen Mallette <spmva@genoprime.com>
Committed: Tue Aug 29 08:35:12 2017 -0400

----------------------------------------------------------------------
 CHANGELOG.asciidoc                              |  2 ++
 .../gremlin/jsr223/DefaultImportCustomizer.java | 25 ++++++++++++++++++++
 .../jsr223/GremlinJythonScriptEngine.java       |  2 +-
 .../tinkerpop/gremlin/server/Settings.java      |  4 +++-
 .../neo4j/jsr223/Neo4jGremlinPlugin.java        |  6 ++---
 5 files changed, 33 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/5ab53acc/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index 9fff535..d62df5c 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -26,6 +26,8 @@ image::https://raw.githubusercontent.com/apache/tinkerpop/master/docs/static/ima
 TinkerPop 3.2.7 (Release Date: NOT OFFICIALLY RELEASED YET)
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
+* Ensured that plugins were applied in the order they were configured.
+* Fixed a bug in `Neo4jGremlinPlugin` that prevented it from loading properly in the `GremlinPythonScriptEngine`.
 * Fixed a bug that prevented Gremlin from ordering lists and streams made of mixed number
types.
 
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/5ab53acc/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/DefaultImportCustomizer.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/DefaultImportCustomizer.java
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/DefaultImportCustomizer.java
index 74dc5b1..f6da9bf 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/DefaultImportCustomizer.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/DefaultImportCustomizer.java
@@ -65,31 +65,56 @@ public class DefaultImportCustomizer implements ImportCustomizer {
 
         private Builder() {}
 
+        /**
+         * Adds classes that will be imported to the {@code ScriptEngine}.
+         */
         public Builder addClassImports(final Class... clazz) {
             classImports.addAll(Arrays.asList(clazz));
             return this;
         }
 
+        /**
+         * Overload to {@link #addClassImports(Class[])}.
+         */
         public Builder addClassImports(final Collection<Class> classes) {
             classImports.addAll(classes);
             return this;
         }
 
+        /**
+         * Adds methods that are meant to be imported statically to the engine. When adding
methods be sure that
+         * the classes of those methods are added to the {@link #addClassImports(Class[])}
or
+         * {@link #addClassImports(Collection)}. If they are not added then the certain {@code
ScriptEngine} instances
+         * may have problems importing the methods (e.g. gremlin-python).
+         */
         public Builder addMethodImports(final Method... method) {
             methodImports.addAll(Arrays.asList(method));
             return this;
         }
 
+        /**
+         * Overload to {@link #addMethodImports(Method...)}.
+         */
         public Builder addMethodImports(final Collection<Method> methods) {
             methodImports.addAll(methods);
             return this;
         }
 
+
+        /**
+         * Adds methods that are meant to be imported statically to the engine. When adding
methods be sure that
+         * the classes of those methods are added to the {@link #addClassImports(Class[])}
or
+         * {@link #addClassImports(Collection)}. If they are not added then the certain {@code
ScriptEngine} instances
+         * may have problems importing the methods (e.g. gremlin-python).
+         */
         public Builder addEnumImports(final Enum... e) {
             enumImports.addAll(Arrays.asList(e));
             return this;
         }
 
+        /**
+         * Overload to {@link #addEnumImports(Enum[])}.
+         */
         public Builder addEnumImports(final Collection<Enum> enums) {
             enumImports.addAll(enums);
             return this;

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/5ab53acc/gremlin-python/src/main/java/org/apache/tinkerpop/gremlin/python/jsr223/GremlinJythonScriptEngine.java
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/java/org/apache/tinkerpop/gremlin/python/jsr223/GremlinJythonScriptEngine.java
b/gremlin-python/src/main/java/org/apache/tinkerpop/gremlin/python/jsr223/GremlinJythonScriptEngine.java
index f6ada6e..04473c0 100644
--- a/gremlin-python/src/main/java/org/apache/tinkerpop/gremlin/python/jsr223/GremlinJythonScriptEngine.java
+++ b/gremlin-python/src/main/java/org/apache/tinkerpop/gremlin/python/jsr223/GremlinJythonScriptEngine.java
@@ -83,7 +83,7 @@ public class GremlinJythonScriptEngine implements GremlinScriptEngine {
         final List<Customizer> listOfCustomizers = new ArrayList<>(Arrays.asList(customizers));
 
         // always need this plugin for a scriptengine to be "Gremlin-enabled"
-        CoreGremlinPlugin.instance().getCustomizers("gremlin-groovy").ifPresent(c -> listOfCustomizers.addAll(Arrays.asList(c)));
+        CoreGremlinPlugin.instance().getCustomizers("gremlin-jython").ifPresent(c -> listOfCustomizers.addAll(Arrays.asList(c)));
 
         final List<ImportCustomizer> importCustomizers = listOfCustomizers.stream()
                 .filter(p -> p instanceof ImportCustomizer)

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/5ab53acc/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/Settings.java
----------------------------------------------------------------------
diff --git a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/Settings.java
b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/Settings.java
index 336fd53..8690206 100644
--- a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/Settings.java
+++ b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/Settings.java
@@ -43,6 +43,7 @@ import java.io.InputStream;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
+import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Objects;
@@ -363,8 +364,9 @@ public class Settings {
 
         /**
          * A set of configurations for {@link GremlinPlugin} instances to apply to this {@link
GremlinScriptEngine}.
+         * Plugins will be applied in the order they are listed.
          */
-        public Map<String,Map<String,Object>> plugins = new HashMap<>();
+        public Map<String,Map<String,Object>> plugins = new LinkedHashMap<>();
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/5ab53acc/neo4j-gremlin/src/main/java/org/apache/tinkerpop/gremlin/neo4j/jsr223/Neo4jGremlinPlugin.java
----------------------------------------------------------------------
diff --git a/neo4j-gremlin/src/main/java/org/apache/tinkerpop/gremlin/neo4j/jsr223/Neo4jGremlinPlugin.java
b/neo4j-gremlin/src/main/java/org/apache/tinkerpop/gremlin/neo4j/jsr223/Neo4jGremlinPlugin.java
index 839a1d1..206a118 100644
--- a/neo4j-gremlin/src/main/java/org/apache/tinkerpop/gremlin/neo4j/jsr223/Neo4jGremlinPlugin.java
+++ b/neo4j-gremlin/src/main/java/org/apache/tinkerpop/gremlin/neo4j/jsr223/Neo4jGremlinPlugin.java
@@ -31,9 +31,6 @@ import org.apache.tinkerpop.gremlin.neo4j.structure.Neo4jProperty;
 import org.apache.tinkerpop.gremlin.neo4j.structure.Neo4jVertex;
 import org.apache.tinkerpop.gremlin.neo4j.structure.Neo4jVertexProperty;
 
-import java.util.HashSet;
-import java.util.Set;
-
 /**
  * @author Stephen Mallette (http://stephen.genoprime.com)
  */
@@ -53,7 +50,8 @@ public final class Neo4jGremlinPlugin extends AbstractGremlinPlugin {
                             Neo4jHelper.class,
                             Neo4jProperty.class,
                             Neo4jVertex.class,
-                            Neo4jVertexProperty.class)
+                            Neo4jVertexProperty.class,
+                            LabelP.class)
                     .addMethodImports(LabelP.class.getMethod("of", String.class)).create();
         } catch (Exception ex) {
             throw new RuntimeException(ex);


Mime
View raw message