TINKERPOP-1612 Factored out all the adapters between old/new plugin system in 
the console.


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

Branch: refs/heads/TINKERPOP-1612
Commit: a40db6e0e6bb9465f8182738525ab1e575ec169f
Parents: af04171
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Mon Feb 27 12:36:11 2017 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Mon Feb 27 13:40:23 2017 -0500

----------------------------------------------------------------------
 docs/src/upgrade/release-3.3.x.asciidoc         |   2 +
 .../tinkerpop/gremlin/console/Console.groovy    |   2 +-
 .../tinkerpop/gremlin/console/Mediator.groovy   |   2 +-
 .../tinkerpop/gremlin/console/PluggedIn.groovy  | 115 +++---------
 .../console/commands/InstallCommand.groovy      |   2 +-
 .../console/commands/RemoteCommand.groovy       |   7 +-
 .../console/plugin/ConsolePluginAcceptor.groovy |  67 -------
 .../gremlin/console/plugin/PluggedIn.groovy     | 173 -------------------
 .../jsr223/UtilitiesGremlinPluginTest.java      |   7 +-
 .../jsr223/console/ConsoleCustomizer.java       |   4 +
 .../gremlin/jsr223/console/PluginAcceptor.java  |  64 -------
 11 files changed, 42 insertions(+), 403 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/a40db6e0/docs/src/upgrade/release-3.3.x.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/upgrade/release-3.3.x.asciidoc 
b/docs/src/upgrade/release-3.3.x.asciidoc
index 9a58f08..db35b9b 100644
--- a/docs/src/upgrade/release-3.3.x.asciidoc
+++ b/docs/src/upgrade/release-3.3.x.asciidoc
@@ -182,6 +182,7 @@ The following deprecated classes, methods or fields have 
been removed in this ve
 * `gremlin-console`
 ** `org.apache.tinkerpop.gremlin.console.Console(String)`
 ** `org.apache.tinkerpop.gremlin.console.ConsoleImportCustomizerProvider`
+** `org.apache.tinkerpop.gremlin.console.plugin.ConsolePluginAcceptor`
 ** `org.apache.tinkerpop.gremlin.console.plugin.GephiRemoteAcceptor`
 ** 
`org.apache.tinkerpop.gremlin.console.plugin.GephiTraversalVisualizationStrategy`
 ** `org.apache.tinkerpop.gremlin.console.groovy.plugin.DriverGremlinPlugin`
@@ -192,6 +193,7 @@ The following deprecated classes, methods or fields have 
been removed in this ve
 ** `org.apache.tinkerpop.gremlin.jsr223.CoreGremlinModule`
 ** `org.apache.tinkerpop.gremlin.jsr223.GremlinModule`
 ** 
`org.apache.tinkerpop.gremlin.jsr223.GremlinScriptEngineManager#addModule(GremlinModule)`
+** `org.apache.tinkerpop.gremlin.jsr223.console.PluginAcceptor`
 ** 
`org.apache.tinkerpop.gremlin.structure.Graph.OptIn#SUITE_GROOVY_PROCESS_STANDARD`
 ** 
`org.apache.tinkerpop.gremlin.structure.Graph.OptIn#SUITE_GROOVY_PROCESS_COMPUTER`
 ** 
`org.apache.tinkerpop.gremlin.structure.Graph.OptIn#SUITE_GROOVY_ENVIRONMENT`

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/a40db6e0/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/Console.groovy
----------------------------------------------------------------------
diff --git 
a/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/Console.groovy
 
b/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/Console.groovy
index 57eca8b..9e0b682 100644
--- 
a/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/Console.groovy
+++ 
b/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/Console.groovy
@@ -115,7 +115,7 @@ class Console {
         def activePlugins = Mediator.readPluginState()
         ServiceLoader.load(GremlinPlugin, 
groovy.getInterp().getClassLoader()).each { plugin ->
             if (!mediator.availablePlugins.containsKey(plugin.class.name)) {
-                def pluggedIn = new PluggedIn(new 
PluggedIn.GremlinPluginAdapter((GremlinPlugin) plugin, groovy, io), groovy, io, 
false)
+                def pluggedIn = new PluggedIn((GremlinPlugin) plugin, groovy, 
io, false)
 
                 mediator.availablePlugins.put(plugin.class.name, pluggedIn)
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/a40db6e0/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/Mediator.groovy
----------------------------------------------------------------------
diff --git 
a/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/Mediator.groovy
 
b/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/Mediator.groovy
index 3d01340..7c89ca4 100644
--- 
a/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/Mediator.groovy
+++ 
b/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/Mediator.groovy
@@ -18,7 +18,7 @@
  */
 package org.apache.tinkerpop.gremlin.console
 
-import org.apache.tinkerpop.gremlin.groovy.plugin.RemoteAcceptor
+import org.apache.tinkerpop.gremlin.jsr223.console.RemoteAcceptor
 
 /**
  * @author Stephen Mallette (http://stephen.genoprime.com)

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/a40db6e0/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/PluggedIn.groovy
----------------------------------------------------------------------
diff --git 
a/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/PluggedIn.groovy
 
b/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/PluggedIn.groovy
index a1e1ee7..e8a3b8a 100644
--- 
a/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/PluggedIn.groovy
+++ 
b/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/PluggedIn.groovy
@@ -18,13 +18,13 @@
  */
 package org.apache.tinkerpop.gremlin.console
 
-import org.apache.tinkerpop.gremlin.console.plugin.ConsolePluginAcceptor
-import org.apache.tinkerpop.gremlin.groovy.plugin.*
 import org.apache.tinkerpop.gremlin.jsr223.BindingsCustomizer
+import org.apache.tinkerpop.gremlin.jsr223.GremlinPlugin
 import org.apache.tinkerpop.gremlin.jsr223.ImportCustomizer
 import org.apache.tinkerpop.gremlin.jsr223.ScriptCustomizer
 import org.apache.tinkerpop.gremlin.jsr223.console.ConsoleCustomizer
 import org.apache.tinkerpop.gremlin.jsr223.console.GremlinShellEnvironment
+import org.apache.tinkerpop.gremlin.jsr223.console.RemoteAcceptor
 import org.codehaus.groovy.tools.shell.Groovysh
 import org.codehaus.groovy.tools.shell.IO
 
@@ -55,7 +55,17 @@ class PluggedIn {
     }
 
     void activate() {
-        plugin.pluginTo(new ConsolePluginAcceptor(shell, io))
+        plugin.getCustomizers("gremlin-groovy").get().each {
+            if (it instanceof ImportCustomizer) {
+                it.getClassPackages().collect {Mediator.IMPORT_SPACE + 
it.getName() + Mediator.IMPORT_WILDCARD }.each { shell.execute(it) }
+                it.getMethodClasses().collect {Mediator.IMPORT_STATIC_SPACE + 
it.getCanonicalName() + Mediator.IMPORT_WILDCARD}.each {shell.execute(it)}
+                it.getEnumClasses().collect {Mediator.IMPORT_STATIC_SPACE + 
it.getCanonicalName() + Mediator.IMPORT_WILDCARD}.each {shell.execute(it)}
+            } else if (it instanceof ScriptCustomizer) {
+                it.getScripts().collect { it.join(LINE_SEPARATOR) }.each { 
shell.execute(it) }
+            } else if (it instanceof BindingsCustomizer) {
+                it.bindings.entrySet().each { kv -> 
shell.getInterp().getContext().setProperty(kv.key, kv.value) }
+            }
+        }
         this.activated = true
     }
 
@@ -63,104 +73,35 @@ class PluggedIn {
         this.activated = false
     }
 
-    public static class GremlinPluginAdapter implements GremlinPlugin {
-        org.apache.tinkerpop.gremlin.jsr223.GremlinPlugin corePlugin
-        private final Groovysh shell
-        private final IO io
-
-        public GremlinPluginAdapter(final 
org.apache.tinkerpop.gremlin.jsr223.GremlinPlugin corePlugin, final Groovysh 
shell, final IO io) {
-            this.corePlugin = corePlugin
-            this.shell = shell
-            this.io = io
-        }
-
-        @Override
-        String getName() {
-            return corePlugin.getName()
-        }
-
-        @Override
-        void pluginTo(final PluginAcceptor pluginAcceptor) throws 
IllegalEnvironmentException, PluginInitializationException {
-            corePlugin.getCustomizers("gremlin-groovy").get().each {
-                if (it instanceof ImportCustomizer) {
-                    def imports = [] as Set
-                    it.getClassPackages().collect {Mediator.IMPORT_SPACE + 
it.getName() + Mediator.IMPORT_WILDCARD }.each { imports.add(it) }
-                    it.getMethodClasses().collect 
{Mediator.IMPORT_STATIC_SPACE + it.getCanonicalName() + 
Mediator.IMPORT_WILDCARD}.each {imports.add(it)}
-                    it.getEnumClasses().collect {Mediator.IMPORT_STATIC_SPACE 
+ it.getCanonicalName() + Mediator.IMPORT_WILDCARD}.each {imports.add(it)}
-                    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 { kv -> 
pluginAcceptor.addBinding(kv.key, kv.value) }
-                }
-            }
-        }
-
-        @Override
-        boolean requireRestart() {
-            return corePlugin.requireRestart()
-        }
-
-        @Override
-        Optional<RemoteAcceptor> remoteAcceptor() {
-            // find a consoleCustomizer if available
-            if (!corePlugin.getCustomizers("gremlin-groovy").isPresent() || 
!corePlugin.getCustomizers("gremlin-groovy").get().any{ it instanceof 
ConsoleCustomizer })
-                return Optional.empty()
-
-            ConsoleCustomizer customizer = (ConsoleCustomizer) 
corePlugin.getCustomizers("gremlin-groovy").get().find{ it instanceof 
ConsoleCustomizer }
-            return Optional.of(new 
RemoteAcceptorAdapter(customizer.getRemoteAcceptor(new 
GroovyGremlinShellEnvironment())))
-        }
-
-        public class GroovyGremlinShellEnvironment implements 
GremlinShellEnvironment {
-
-            @Override
-            def <T> T getVariable(final String variableName) {
-                return (T) shell.interp.context.getVariable(variableName)
-            }
-
-            @Override
-            def <T> void setVariable(final String variableName, final T 
variableValue) {
-                shell.interp.context.setVariable(variableName, variableValue)
-            }
+    Optional<RemoteAcceptor> remoteAcceptor() {
+        // find a consoleCustomizer if available
+        if (!plugin.getCustomizers("gremlin-groovy").isPresent() || 
!plugin.getCustomizers("gremlin-groovy").get().any{ it instanceof 
ConsoleCustomizer })
+            return Optional.empty()
 
-            @Override
-            void println(final String line) {
-                io.println(line)
-            }
-
-            @Override
-            def <T> T execute(final String line) {
-                return (T) shell.execute(line)
-            }
-        }
+        ConsoleCustomizer customizer = (ConsoleCustomizer) 
plugin.getCustomizers("gremlin-groovy").get().find{ it instanceof 
ConsoleCustomizer }
+        return Optional.of(customizer.getRemoteAcceptor(new 
GroovyGremlinShellEnvironment()))
     }
 
-    public static class RemoteAcceptorAdapter implements RemoteAcceptor {
-
-        private org.apache.tinkerpop.gremlin.jsr223.console.RemoteAcceptor 
remoteAcceptor
-
-        public 
RemoteAcceptorAdapter(org.apache.tinkerpop.gremlin.jsr223.console.RemoteAcceptor
 remoteAcceptor) {
-            this.remoteAcceptor = remoteAcceptor
-        }
+    public class GroovyGremlinShellEnvironment implements 
GremlinShellEnvironment {
 
         @Override
-        Object connect(final List<String> args) throws RemoteException {
-            return remoteAcceptor.connect(args)
+        def <T> T getVariable(final String variableName) {
+            return (T) shell.interp.context.getVariable(variableName)
         }
 
         @Override
-        Object configure(final List<String> args) throws RemoteException {
-            return remoteAcceptor.configure(args)
+        def <T> void setVariable(final String variableName, final T 
variableValue) {
+            shell.interp.context.setVariable(variableName, variableValue)
         }
 
         @Override
-        Object submit(final List<String> args) throws RemoteException {
-            return remoteAcceptor.submit(args)
+        void println(final String line) {
+            io.println(line)
         }
 
         @Override
-        void close() throws IOException {
-            remoteAcceptor.close()
+        def <T> T execute(final String line) {
+            return (T) shell.execute(line)
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/a40db6e0/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/commands/InstallCommand.groovy
----------------------------------------------------------------------
diff --git 
a/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/commands/InstallCommand.groovy
 
b/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/commands/InstallCommand.groovy
index 1188027..9736f44 100644
--- 
a/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/commands/InstallCommand.groovy
+++ 
b/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/commands/InstallCommand.groovy
@@ -66,7 +66,7 @@ class InstallCommand extends CommandSupport {
         // from within there given loading through Grape.
         ServiceLoader.load(GremlinPlugin, 
shell.getInterp().getClassLoader()).forEach { plugin ->
             if (!mediator.availablePlugins.containsKey(plugin.class.name)) {
-                mediator.availablePlugins.put(plugin.class.name, new 
PluggedIn(new PluggedIn.GremlinPluginAdapter((GremlinPlugin) plugin, shell, 
io), shell, io, false))
+                mediator.availablePlugins.put(plugin.class.name, new 
PluggedIn((GremlinPlugin) plugin, shell, io, false))
                 if (plugin.requireRestart())
                     pluginsThatNeedRestart << plugin.name
             }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/a40db6e0/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/commands/RemoteCommand.groovy
----------------------------------------------------------------------
diff --git 
a/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/commands/RemoteCommand.groovy
 
b/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/commands/RemoteCommand.groovy
index dccebd3..68e48d9 100644
--- 
a/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/commands/RemoteCommand.groovy
+++ 
b/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/commands/RemoteCommand.groovy
@@ -19,8 +19,8 @@
 package org.apache.tinkerpop.gremlin.console.commands
 
 import org.apache.tinkerpop.gremlin.console.Mediator
-import org.apache.tinkerpop.gremlin.groovy.plugin.RemoteAcceptor
-import org.apache.tinkerpop.gremlin.groovy.plugin.RemoteException
+import org.apache.tinkerpop.gremlin.jsr223.console.RemoteAcceptor
+import org.apache.tinkerpop.gremlin.jsr223.console.RemoteException
 import org.codehaus.groovy.tools.shell.ComplexCommandSupport
 import org.codehaus.groovy.tools.shell.Groovysh
 
@@ -47,8 +47,7 @@ class RemoteCommand extends ComplexCommandSupport {
         def pluggedIn = mediator.availablePlugins.values().find { 
it.plugin.name == arguments[0] }
         if (!pluggedIn.activated) return "Plugin is available but not 
activated with ':plugin use ${arguments[0]}'"
 
-        def plugin = pluggedIn.plugin
-        def Optional<RemoteAcceptor> remoteAcceptor = plugin.remoteAcceptor()
+        def Optional<RemoteAcceptor> remoteAcceptor = 
pluggedIn.remoteAcceptor()
         if (!remoteAcceptor.isPresent()) return "${arguments[0]} does not 
accept remote configuration"
 
         try {

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/a40db6e0/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/plugin/ConsolePluginAcceptor.groovy
----------------------------------------------------------------------
diff --git 
a/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/plugin/ConsolePluginAcceptor.groovy
 
b/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/plugin/ConsolePluginAcceptor.groovy
deleted file mode 100644
index bbb2dfd..0000000
--- 
a/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/plugin/ConsolePluginAcceptor.groovy
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * 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.plugin
-
-import org.apache.tinkerpop.gremlin.groovy.plugin.GremlinPlugin
-import org.apache.tinkerpop.gremlin.groovy.plugin.PluginAcceptor
-import org.codehaus.groovy.tools.shell.Groovysh
-import org.codehaus.groovy.tools.shell.IO
-
-/**
- * @author Stephen Mallette (http://stephen.genoprime.com)
- * @deprecated As of release 3.2.5, not replaced.
- */
-@Deprecated
-class ConsolePluginAcceptor implements PluginAcceptor, 
org.apache.tinkerpop.gremlin.jsr223.console.PluginAcceptor {
-
-    public static final String ENVIRONMENT_NAME = "console";
-    public static final String ENVIRONMENT_SHELL = 
"ConsolePluginAcceptor.shell"
-    public static final String ENVIRONMENT_IO = "ConsolePluginAcceptor.io"
-
-    private final Groovysh shell
-    private final IO io
-
-    public ConsolePluginAcceptor(final Groovysh shell, final IO io) {
-        this.shell = shell
-        this.io = io
-    }
-
-    @Override
-    void addBinding(final String key, final Object val) {
-        shell.interp.context.setVariable(key, val)
-    }
-
-    @Override
-    Map<String, Object> getBindings() {
-        return Collections.unmodifiableMap(shell.interp.context.variables)
-    }
-
-    @Override
-    void addImports(final Set<String> importStatements) {
-        importStatements.each { this.shell.execute(it) }
-    }
-
-    @Override
-    Object eval(final String script) throws javax.script.ScriptException { 
return this.shell.execute(script) }
-
-    @Override
-    Map<String, Object> environment() {
-        return [(GremlinPlugin.ENVIRONMENT): ENVIRONMENT_NAME, 
(ENVIRONMENT_IO): io, (ENVIRONMENT_SHELL): shell]
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/a40db6e0/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
deleted file mode 100644
index a4afb28..0000000
--- 
a/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/plugin/PluggedIn.groovy
+++ /dev/null
@@ -1,173 +0,0 @@
-/*
- * 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.plugin
-
-import org.apache.tinkerpop.gremlin.console.Mediator
-import org.apache.tinkerpop.gremlin.groovy.plugin.GremlinPlugin
-import org.apache.tinkerpop.gremlin.groovy.plugin.IllegalEnvironmentException
-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
-import org.apache.tinkerpop.gremlin.jsr223.console.GremlinShellEnvironment
-import org.codehaus.groovy.tools.shell.Groovysh
-import org.codehaus.groovy.tools.shell.IO
-
-/**
- * @author Stephen Mallette (http://stephen.genoprime.com)
- * @deprecated As of release 3.2.5, replaced by {@link 
org.apache.tinkerpop.gremlin.console.PluggedIn}
- */
-@Deprecated
-class PluggedIn {
-    private static final String LINE_SEPARATOR = 
System.getProperty("line.separator")
-    private final GremlinPlugin plugin
-    private boolean activated = false
-
-    private final Groovysh shell
-    private final IO io
-
-    public PluggedIn(final GremlinPlugin plugin, final Groovysh shell, final 
IO io, final boolean activated) {
-        this.plugin = plugin
-        this.activated = activated
-        this.shell = shell
-        this.io = io
-    }
-
-    GremlinPlugin getPlugin() {
-        return plugin
-    }
-
-    boolean getActivated() {
-        return activated
-    }
-
-    void activate() {
-        plugin.pluginTo(new ConsolePluginAcceptor(shell, io))
-        this.activated = true
-    }
-
-    void deactivate() {
-        this.activated = false
-    }
-
-    public static class GremlinPluginAdapter implements GremlinPlugin {
-        org.apache.tinkerpop.gremlin.jsr223.GremlinPlugin corePlugin
-        private final Groovysh shell
-        private final IO io
-
-        public GremlinPluginAdapter(final 
org.apache.tinkerpop.gremlin.jsr223.GremlinPlugin corePlugin, final Groovysh 
shell, final IO io) {
-            this.corePlugin = corePlugin
-            this.shell = shell
-            this.io = io
-        }
-
-        @Override
-        String getName() {
-            return corePlugin.getName()
-        }
-
-        @Override
-        void pluginTo(final PluginAcceptor pluginAcceptor) throws 
IllegalEnvironmentException, PluginInitializationException {
-            corePlugin.getCustomizers("gremlin-groovy").get().each {
-                if (it instanceof ImportCustomizer) {
-                    def imports = [] as Set
-                    it.getClassPackages().collect {Mediator.IMPORT_SPACE + 
it.getName() + Mediator.IMPORT_WILDCARD }.each { imports.add(it) }
-                    it.getMethodClasses().collect 
{Mediator.IMPORT_STATIC_SPACE + it.getCanonicalName() + 
Mediator.IMPORT_WILDCARD}.each {imports.add(it)}
-                    it.getEnumClasses().collect {Mediator.IMPORT_STATIC_SPACE 
+ it.getCanonicalName() + Mediator.IMPORT_WILDCARD}.each {imports.add(it)}
-                    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 { kv -> 
pluginAcceptor.addBinding(kv.key, kv.value) }
-                }
-            }
-        }
-
-        @Override
-        boolean requireRestart() {
-            return corePlugin.requireRestart()
-        }
-
-        @Override
-        Optional<RemoteAcceptor> remoteAcceptor() {
-            // find a consoleCustomizer if available
-            if (!corePlugin.getCustomizers("gremlin-groovy").isPresent() || 
!corePlugin.getCustomizers("gremlin-groovy").get().any{ it instanceof 
ConsoleCustomizer })
-                return Optional.empty()
-
-            ConsoleCustomizer customizer = (ConsoleCustomizer) 
corePlugin.getCustomizers("gremlin-groovy").get().find{ it instanceof 
ConsoleCustomizer }
-            return Optional.of(new 
RemoteAcceptorAdapter(customizer.getRemoteAcceptor(new 
GroovyGremlinShellEnvironment())))
-        }
-
-        public class GroovyGremlinShellEnvironment implements 
GremlinShellEnvironment {
-
-            @Override
-            def <T> T getVariable(final String variableName) {
-                return (T) shell.interp.context.getVariable(variableName)
-            }
-
-            @Override
-            def <T> void setVariable(final String variableName, final T 
variableValue) {
-                shell.interp.context.setVariable(variableName, variableValue)
-            }
-
-            @Override
-            void println(final String line) {
-                io.println(line)
-            }
-
-            @Override
-            def <T> T execute(final String line) {
-                return (T) shell.execute(line)
-            }
-        }
-    }
-
-    public static class RemoteAcceptorAdapter implements RemoteAcceptor {
-
-        private org.apache.tinkerpop.gremlin.jsr223.console.RemoteAcceptor 
remoteAcceptor
-
-        public 
RemoteAcceptorAdapter(org.apache.tinkerpop.gremlin.jsr223.console.RemoteAcceptor
 remoteAcceptor) {
-            this.remoteAcceptor = remoteAcceptor
-        }
-
-        @Override
-        Object connect(final List<String> args) throws RemoteException {
-            return remoteAcceptor.connect(args)
-        }
-
-        @Override
-        Object configure(final List<String> args) throws RemoteException {
-            return remoteAcceptor.configure(args)
-        }
-
-        @Override
-        Object submit(final List<String> args) throws RemoteException {
-            return remoteAcceptor.submit(args)
-        }
-
-        @Override
-        void close() throws IOException {
-            remoteAcceptor.close()
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/a40db6e0/gremlin-console/src/test/java/org/apache/tinkerpop/gremlin/console/jsr223/UtilitiesGremlinPluginTest.java
----------------------------------------------------------------------
diff --git 
a/gremlin-console/src/test/java/org/apache/tinkerpop/gremlin/console/jsr223/UtilitiesGremlinPluginTest.java
 
b/gremlin-console/src/test/java/org/apache/tinkerpop/gremlin/console/jsr223/UtilitiesGremlinPluginTest.java
index 65b2ee0..385e086 100644
--- 
a/gremlin-console/src/test/java/org/apache/tinkerpop/gremlin/console/jsr223/UtilitiesGremlinPluginTest.java
+++ 
b/gremlin-console/src/test/java/org/apache/tinkerpop/gremlin/console/jsr223/UtilitiesGremlinPluginTest.java
@@ -19,7 +19,6 @@
 package org.apache.tinkerpop.gremlin.console.jsr223;
 
 import org.apache.commons.io.input.NullInputStream;
-import org.apache.tinkerpop.gremlin.console.plugin.ConsolePluginAcceptor;
 import org.apache.tinkerpop.gremlin.console.PluggedIn;
 import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerFactory;
 import org.codehaus.groovy.tools.shell.Groovysh;
@@ -60,10 +59,8 @@ public class UtilitiesGremlinPluginTest {
         final Groovysh groovysh = new Groovysh();
         groovysh.getInterp().getContext().setProperty("g", 
TinkerFactory.createClassic());
 
-        final PluggedIn.GremlinPluginAdapter adapter = new 
PluggedIn.GremlinPluginAdapter(plugin, groovysh, io);
-        final ConsolePluginAcceptor acceptor = new 
ConsolePluginAcceptor(groovysh, io);
-
-        adapter.pluginTo(acceptor);
+        final PluggedIn pluggedIn = new PluggedIn(plugin, groovysh, io, false);
+        pluggedIn.activate();
 
         
assertThat(groovysh.execute("describeGraph(org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph)").toString(),
 containsString("IMPLEMENTATION - 
org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph"));
     }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/a40db6e0/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/console/ConsoleCustomizer.java
----------------------------------------------------------------------
diff --git 
a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/console/ConsoleCustomizer.java
 
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/console/ConsoleCustomizer.java
index 9204488..4ab851e 100644
--- 
a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/console/ConsoleCustomizer.java
+++ 
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/console/ConsoleCustomizer.java
@@ -19,8 +19,12 @@
 package org.apache.tinkerpop.gremlin.jsr223.console;
 
 import org.apache.tinkerpop.gremlin.jsr223.Customizer;
+import org.apache.tinkerpop.gremlin.jsr223.GremlinPlugin;
 
 /**
+ * A {@link Customizer} that allows a {@link RemoteAcceptor} to be used with a 
console implementation. Only one
+ * {@code ConsoleCustomizer} can be added to a particular {@link 
GremlinPlugin}.
+ *
  * @author Stephen Mallette (http://stephen.genoprime.com)
  */
 public interface ConsoleCustomizer extends Customizer {

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/a40db6e0/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/console/PluginAcceptor.java
----------------------------------------------------------------------
diff --git 
a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/console/PluginAcceptor.java
 
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/console/PluginAcceptor.java
deleted file mode 100644
index cd6951b..0000000
--- 
a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/console/PluginAcceptor.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * 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.GremlinPlugin;
-
-import javax.script.ScriptException;
-import java.util.Collections;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * A {@link GremlinPlugin} can be used in multiple environments (e.g. 
ScriptEngine implementation).  Any environment
- * wishing to allow plugins should implement the {@code PluginAcceptor}.  It 
acts as an adapter to those environments
- * and provides the abstractions required for a plugin to work regardless of 
the environmental implementations.
- *
- * @author Stephen Mallette (http://stephen.genoprime.com)
- * @deprecated As of release 3.2.5, not replaced.
- */
-@Deprecated
-public interface PluginAcceptor {
-
-    public void addImports(final Set<String> importStatements);
-
-    /**
-     * Add a variable binding for the plugin host.
-     */
-    public void addBinding(final String key, final Object val);
-
-    /**
-     * Gets the list of bindings from the plugin host.  These bindings will 
represent the "global" binding list.
-     */
-    public Map<String, Object> getBindings();
-
-    /**
-     * Evaluate a script in the {@code PluginAcceptor}.
-     */
-    public Object eval(final String script) throws ScriptException;
-
-    /**
-     * Returns a map of implementation specific variables that can be 
referenced by the plugin. Those writing
-     * plugins should examine the details of the various {@code 
PluginAcceptor} implementations for the variables
-     * that they pass, as they may provide important information useful to the 
plugin itself.
-     */
-    public default Map<String, Object> environment() {
-        return Collections.emptyMap();
-    }
-}

Reply via email to