Skip to content

Commit

Permalink
fix: add settings for future jdk/groovy compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
tglman committed Nov 26, 2024
1 parent f6d8e6e commit 0e7b85d
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,34 @@
*/
package org.apache.tinkerpop.gremlin.orientdb.executor;

import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;

import javax.script.Bindings;
import javax.script.Invocable;
import javax.script.ScriptContext;
import javax.script.ScriptEngine;
import javax.script.ScriptException;

import org.apache.commons.configuration2.BaseConfiguration;
import org.apache.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngineFactory;
import org.apache.tinkerpop.gremlin.groovy.jsr223.GroovyCompilerGremlinPlugin;
import org.apache.tinkerpop.gremlin.jsr223.CachedGremlinScriptEngineManager;
import org.apache.tinkerpop.gremlin.orientdb.OrientEdge;
import org.apache.tinkerpop.gremlin.orientdb.OrientElement;
import org.apache.tinkerpop.gremlin.orientdb.OrientGraph;
import org.apache.tinkerpop.gremlin.orientdb.OrientVertex;
import org.apache.tinkerpop.gremlin.orientdb.OrientVertexProperty;
import org.apache.tinkerpop.gremlin.orientdb.executor.transformer.OElementTransformer;
import org.apache.tinkerpop.gremlin.orientdb.executor.transformer.OGremlinTransformer;
import org.apache.tinkerpop.gremlin.orientdb.executor.transformer.OTraversalMetricTransformer;
import org.apache.tinkerpop.gremlin.orientdb.executor.transformer.OrientPropertyTransformer;
import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
import org.apache.tinkerpop.gremlin.process.traversal.util.DefaultTraversalMetrics;
import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalExplanation;
import org.codehaus.groovy.control.MultipleCompilationErrorsException;

import com.orientechnologies.common.exception.OException;
import com.orientechnologies.common.util.OCommonConst;
import com.orientechnologies.orient.core.command.OCommandContext;
Expand All @@ -40,27 +68,8 @@
import com.orientechnologies.orient.core.sql.executor.OInternalResultSet;
import com.orientechnologies.orient.core.sql.executor.OResultInternal;
import com.orientechnologies.orient.core.sql.executor.OResultSet;

import groovy.lang.MissingPropertyException;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import javax.script.Bindings;
import javax.script.Invocable;
import javax.script.ScriptContext;
import javax.script.ScriptEngine;
import javax.script.ScriptException;
import org.apache.commons.configuration2.BaseConfiguration;
import org.apache.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngineFactory;
import org.apache.tinkerpop.gremlin.jsr223.CachedGremlinScriptEngineManager;
import org.apache.tinkerpop.gremlin.orientdb.*;
import org.apache.tinkerpop.gremlin.orientdb.executor.transformer.OElementTransformer;
import org.apache.tinkerpop.gremlin.orientdb.executor.transformer.OGremlinTransformer;
import org.apache.tinkerpop.gremlin.orientdb.executor.transformer.OTraversalMetricTransformer;
import org.apache.tinkerpop.gremlin.orientdb.executor.transformer.OrientPropertyTransformer;
import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
import org.apache.tinkerpop.gremlin.process.traversal.util.DefaultTraversalMetrics;
import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalExplanation;
import org.codehaus.groovy.control.MultipleCompilationErrorsException;

/**
* Executes a GREMLIN command.
Expand All @@ -79,7 +88,14 @@ public class OCommandGremlinExecutor extends OAbstractScriptExecutor
public OCommandGremlinExecutor(OScriptManager scriptManager, OScriptTransformer transformer) {
super("gremlin");
factory = new GremlinGroovyScriptEngineFactory();
factory.setCustomizerManager(new CachedGremlinScriptEngineManager());
CachedGremlinScriptEngineManager customizationManager = new CachedGremlinScriptEngineManager();
Map<String, Object> compilerConfigs = new HashMap<>();
Map<String, Object> optimizationConfigs = new HashMap<>();
optimizationConfigs.put("asmResolving", false);
compilerConfigs.put("OptimizationOptions", optimizationConfigs);
customizationManager.addPlugin(
GroovyCompilerGremlinPlugin.build().compilerConfigurationOptions(compilerConfigs).create());
factory.setCustomizerManager(customizationManager);
this.scriptManager = scriptManager;
this.transformer = new OGremlinTransformer(transformer);

Expand Down
6 changes: 5 additions & 1 deletion server/src/test/resources/gremlin-server.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ scriptEngines: {
plugins: { org.apache.tinkerpop.gremlin.server.jsr223.GremlinServerGremlinPlugin: {},
org.apache.tinkerpop.gremlin.orientdb.jsr223.OrientDBGremlinPlugin: {},
org.apache.tinkerpop.gremlin.jsr223.ImportGremlinPlugin: {classImports: [java.lang.Math], methodImports: [java.lang.Math#*]},
org.apache.tinkerpop.gremlin.jsr223.ScriptFileGremlinPlugin: {files: []}}}}
org.apache.tinkerpop.gremlin.jsr223.ScriptFileGremlinPlugin: {files: []},
org.apache.tinkerpop.gremlin.groovy.jsr223.GroovyCompilerGremlinPlugin: {compilerConfigurationOptions: { OptimizationOptions: { asmResolving: false}}}
}
}
}
serializers:
- { className: org.apache.tinkerpop.gremlin.util.ser.GraphSONMessageSerializerV3, config: { ioRegistries: [org.apache.tinkerpop.gremlin.orientdb.io.OrientIoRegistry] }} # application/json
processors:
Expand Down

0 comments on commit 0e7b85d

Please sign in to comment.