Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow configuration of SSHD console classloader #486

Merged
merged 1 commit into from
Nov 9, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions sshd/src/main/scala/ammonite/sshd/SshdRepl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,16 @@ import scala.language.postfixOps
* such as users credentials or port to be listening to
* @param predef predef that will be installed on repl instances served by this server
* @param replArgs arguments to pass to ammonite repl on initialization of the session
* @param classloader classloader for ammonite to use
*/
class SshdRepl(sshConfig: SshServerConfig,
predef: String = "",
defaultPredef: Boolean = true,
wd: Path = ammonite.ops.pwd,
replArgs: Seq[Bind[_]] = Nil) {
replArgs: Seq[Bind[_]] = Nil,
classLoader: ClassLoader = SshdRepl.getClass.getClassLoader) {
private lazy val sshd = SshServer(sshConfig, shellServer =
SshdRepl.runRepl(sshConfig.ammoniteHome, predef, defaultPredef, wd, replArgs))
SshdRepl.runRepl(sshConfig.ammoniteHome, predef, defaultPredef, wd, replArgs, classLoader))

def port = sshd.getPort
def start(): Unit = sshd.start()
Expand All @@ -37,14 +39,13 @@ class SshdRepl(sshConfig: SshServerConfig,


object SshdRepl {
private def replServerClassLoader = SshdRepl.getClass.getClassLoader

// Actually runs a repl inside of session serving a remote user shell.
private def runRepl(homePath: Path,
predef: String,
defaultPredef: Boolean,
wd: Path,
replArgs: Seq[Bind[_]])
replArgs: Seq[Bind[_]],
replServerClassLoader: ClassLoader)
(in: InputStream, out: OutputStream): Unit = {
// since sshd server has it's own customised environment,
// where things like System.out will output to the
Expand Down