tinkerpop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ok...@apache.org
Subject [04/20] tinkerpop git commit: Removed use of deprecated ScriptEngines class. CTR
Date Fri, 06 Jan 2017 00:00:32 GMT
Removed use of deprecated ScriptEngines class. CTR


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

Branch: refs/heads/TINKERPOP-1585
Commit: 65be461ad1f633896d938fe6de65fce8bbff9b09
Parents: 3064b93
Author: Stephen Mallette <spmva@genoprime.com>
Authored: Thu Jan 5 11:29:26 2017 -0500
Committer: Stephen Mallette <spmva@genoprime.com>
Committed: Thu Jan 5 11:29:26 2017 -0500

----------------------------------------------------------------------
 .../gremlin/groovy/engine/GremlinExecutor.java      | 16 ++++++++++++++++
 .../server/op/traversal/TraversalOpProcessor.java   |  9 +++------
 2 files changed, 19 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/65be461a/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 87d5728..486f19e 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
@@ -24,6 +24,8 @@ import org.apache.commons.lang3.concurrent.BasicThreadFactory;
 import org.apache.tinkerpop.gremlin.jsr223.CachedGremlinScriptEngineManager;
 import org.apache.tinkerpop.gremlin.jsr223.GremlinPlugin;
 import org.apache.tinkerpop.gremlin.jsr223.GremlinScriptEngineManager;
+import org.apache.tinkerpop.gremlin.process.traversal.Bytecode;
+import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
 import org.javatuples.Pair;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -349,6 +351,20 @@ public class GremlinExecutor implements AutoCloseable {
     }
 
     /**
+     * Evaluates bytecode with bindings for a specific language into a {@link Traversal}.
+     */
+    public Traversal.Admin eval(final Bytecode bytecode, final Bindings boundVars, final
String language) throws ScriptException {
+        final String lang = Optional.ofNullable(language).orElse("gremlin-groovy");
+
+        final Bindings bindings = new SimpleBindings();
+        bindings.putAll(globalBindings);
+        bindings.putAll(boundVars);
+
+        return useGremlinScriptEngineManager ?
+                gremlinScriptEngineManager.getEngineByName(lang).eval(bytecode, bindings)
: scriptEngines.eval(bytecode, bindings, lang);
+    }
+
+    /**
      * @deprecated As of release 3.2.4, replaced by {@link #getScriptEngineManager()}.
      */
     @Deprecated

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/65be461a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/traversal/TraversalOpProcessor.java
----------------------------------------------------------------------
diff --git a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/traversal/TraversalOpProcessor.java
b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/traversal/TraversalOpProcessor.java
index 5461007..c5a05e4 100644
--- a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/traversal/TraversalOpProcessor.java
+++ b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/traversal/TraversalOpProcessor.java
@@ -235,9 +235,7 @@ public class TraversalOpProcessor extends AbstractOpProcessor {
             throw new OpProcessorException(msg, ResponseMessage.build(message).code(ResponseStatusCode.REQUEST_ERROR_INVALID_REQUEST_ARGUMENTS).statusMessage(msg).create());
         }
 
-        final Optional<Map<String, String>> aliases = validatedAliases(message);
-
-        return aliases.get();
+        return validatedAliases(message).get();
     }
 
     private static Optional<Map<String, String>> validatedAliases(final RequestMessage
message) throws OpProcessorException {
@@ -328,7 +326,7 @@ public class TraversalOpProcessor extends AbstractOpProcessor {
         }
     }
 
-    private void iterateBytecodeTraversal(final Context context) throws OpProcessorException,
Exception {
+    private void iterateBytecodeTraversal(final Context context) throws Exception {
         final RequestMessage msg = context.getRequestMessage();
         logger.debug("Traversal request {} for in thread {}", msg.getRequestId(), Thread.currentThread().getName());
 
@@ -351,10 +349,9 @@ public class TraversalOpProcessor extends AbstractOpProcessor {
             if (!lambdaLanguage.isPresent())
                 traversal = JavaTranslator.of(g).translate(bytecode);
             else {
-                final ScriptEngines engines = context.getGremlinExecutor().getScriptEngines();
                 final SimpleBindings b = new SimpleBindings();
                 b.put(Tokens.VAL_TRAVERSAL_SOURCE_ALIAS, g);
-                traversal = engines.eval(bytecode, b, lambdaLanguage.get());
+                traversal = context.getGremlinExecutor().eval(bytecode, b, lambdaLanguage.get());
             }
         } catch (Exception ex) {
             logger.error("Could not deserialize the Traversal instance", context);


Mime
View raw message