diff --git a/tools/shell/src/main/java/net/corda/tools/shell/FlowShellCommand.java b/tools/shell/src/main/java/net/corda/tools/shell/FlowShellCommand.java index 6fbf4cb003..53bb921d3d 100644 --- a/tools/shell/src/main/java/net/corda/tools/shell/FlowShellCommand.java +++ b/tools/shell/src/main/java/net/corda/tools/shell/FlowShellCommand.java @@ -37,7 +37,7 @@ public class FlowShellCommand extends InteractiveShellCommand { @Usage("The data to pass as input") @Argument(unquote = false) List input ) { logger.info("Executing command \"flow start {} {}\",", name, (input != null) ? input.stream().collect(joining(" ")) : ""); - startFlow(name, input, out, ops(), ansiProgressRenderer(), objectMapper()); + startFlow(name, input, out, ops(), ansiProgressRenderer(), objectMapper(null)); } // TODO Limit number of flows shown option? diff --git a/tools/shell/src/main/java/net/corda/tools/shell/RunShellCommand.java b/tools/shell/src/main/java/net/corda/tools/shell/RunShellCommand.java index 763d9181be..0597c2aa61 100644 --- a/tools/shell/src/main/java/net/corda/tools/shell/RunShellCommand.java +++ b/tools/shell/src/main/java/net/corda/tools/shell/RunShellCommand.java @@ -38,13 +38,13 @@ public class RunShellCommand extends InteractiveShellCommand { @Usage("runs a method from the CordaRPCOps interface on the node.") public Object main(InvocationContext context, @Usage("The command to run") @Argument(unquote = false) List command) { logger.info("Executing command \"run {}\",", (command != null) ? command.stream().collect(joining(" ")) : ""); - StringToMethodCallParser parser = new StringToMethodCallParser<>(CordaRPCOps.class, objectMapper()); + StringToMethodCallParser parser = new StringToMethodCallParser<>(CordaRPCOps.class, objectMapper(InteractiveShell.getCordappsClassloader())); if (command == null) { emitHelp(context, parser); return null; } - return InteractiveShell.runRPCFromString(command, out, context, ops(), objectMapper()); + return InteractiveShell.runRPCFromString(command, out, context, ops(), objectMapper(InteractiveShell.getCordappsClassloader())); } private void emitHelp(InvocationContext context, StringToMethodCallParser parser) { diff --git a/tools/shell/src/main/java/net/corda/tools/shell/StartShellCommand.java b/tools/shell/src/main/java/net/corda/tools/shell/StartShellCommand.java index c37d4b78c3..8a1a1c47c6 100644 --- a/tools/shell/src/main/java/net/corda/tools/shell/StartShellCommand.java +++ b/tools/shell/src/main/java/net/corda/tools/shell/StartShellCommand.java @@ -23,6 +23,6 @@ public class StartShellCommand extends InteractiveShellCommand { logger.info("Executing command \"start {} {}\",", name, (input != null) ? input.stream().collect(joining(" ")) : ""); ANSIProgressRenderer ansiProgressRenderer = ansiProgressRenderer(); - FlowShellCommand.startFlow(name, input, out, ops(), ansiProgressRenderer != null ? ansiProgressRenderer : new CRaSHANSIProgressRenderer(out), objectMapper()); + FlowShellCommand.startFlow(name, input, out, ops(), ansiProgressRenderer != null ? ansiProgressRenderer : new CRaSHANSIProgressRenderer(out), objectMapper(null)); } } \ No newline at end of file diff --git a/tools/shell/src/main/kotlin/net/corda/tools/shell/InteractiveShell.kt b/tools/shell/src/main/kotlin/net/corda/tools/shell/InteractiveShell.kt index 8ed572a14a..062d39b878 100644 --- a/tools/shell/src/main/kotlin/net/corda/tools/shell/InteractiveShell.kt +++ b/tools/shell/src/main/kotlin/net/corda/tools/shell/InteractiveShell.kt @@ -78,6 +78,10 @@ object InteractiveShell { private var classLoader: ClassLoader? = null private lateinit var shellConfiguration: ShellConfiguration private var onExit: () -> Unit = {} + + @JvmStatic + fun getCordappsClassloader() = classLoader + /** * Starts an interactive shell connected to the local terminal. This shell gives administrator access to the node * internals. diff --git a/tools/shell/src/main/kotlin/net/corda/tools/shell/InteractiveShellCommand.kt b/tools/shell/src/main/kotlin/net/corda/tools/shell/InteractiveShellCommand.kt index 6253be2172..5a8aa5d443 100644 --- a/tools/shell/src/main/kotlin/net/corda/tools/shell/InteractiveShellCommand.kt +++ b/tools/shell/src/main/kotlin/net/corda/tools/shell/InteractiveShellCommand.kt @@ -1,5 +1,7 @@ package net.corda.tools.shell +import com.fasterxml.jackson.databind.ObjectMapper +import com.fasterxml.jackson.databind.type.TypeFactory import org.crsh.command.BaseCommand import org.crsh.shell.impl.command.CRaSHSession @@ -9,6 +11,13 @@ import org.crsh.shell.impl.command.CRaSHSession open class InteractiveShellCommand : BaseCommand() { fun ops() = ((context.session as CRaSHSession).authInfo as CordaSSHAuthInfo).rpcOps fun ansiProgressRenderer() = ((context.session as CRaSHSession).authInfo as CordaSSHAuthInfo).ansiProgressRenderer - fun objectMapper() = ((context.session as CRaSHSession).authInfo as CordaSSHAuthInfo).yamlInputMapper + fun objectMapper(classLoader: ClassLoader?): ObjectMapper { + val om = ((context.session as CRaSHSession).authInfo as CordaSSHAuthInfo).yamlInputMapper + if (classLoader != null) { + om.typeFactory = TypeFactory.defaultInstance().withClassLoader(classLoader) + } + return om + } + fun isSsh() = ((context.session as CRaSHSession).authInfo as CordaSSHAuthInfo).isSsh }