You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by gn...@apache.org on 2012/05/19 14:20:38 UTC
svn commit: r1340431 -
/mina/sshd/trunk/sshd-core/src/main/java/org/apache/sshd/server/shell/InvertedShellWrapper.java
Author: gnodet
Date: Sat May 19 12:20:38 2012
New Revision: 1340431
URL: http://svn.apache.org/viewvc?rev=1340431&view=rev
Log:
[SSHD-162] Allow the configuration of InvertedShellWrapper's thread pool
Modified:
mina/sshd/trunk/sshd-core/src/main/java/org/apache/sshd/server/shell/InvertedShellWrapper.java
Modified: mina/sshd/trunk/sshd-core/src/main/java/org/apache/sshd/server/shell/InvertedShellWrapper.java
URL: http://svn.apache.org/viewvc/mina/sshd/trunk/sshd-core/src/main/java/org/apache/sshd/server/shell/InvertedShellWrapper.java?rev=1340431&r1=1340430&r2=1340431&view=diff
==============================================================================
--- mina/sshd/trunk/sshd-core/src/main/java/org/apache/sshd/server/shell/InvertedShellWrapper.java (original)
+++ mina/sshd/trunk/sshd-core/src/main/java/org/apache/sshd/server/shell/InvertedShellWrapper.java Sat May 19 12:20:38 2012
@@ -21,7 +21,10 @@ package org.apache.sshd.server.shell;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
+import java.util.concurrent.Executor;
+import java.util.concurrent.Executors;
+import org.apache.mina.util.NamePreservingRunnable;
import org.apache.sshd.server.Command;
import org.apache.sshd.server.Environment;
import org.apache.sshd.server.ExitCallback;
@@ -41,6 +44,7 @@ public class InvertedShellWrapper implem
public static final int DEFAULT_BUFFER_SIZE = 8192;
private final InvertedShell shell;
+ private final Executor executor;
private final int bufferSize;
private InputStream in;
private OutputStream out;
@@ -49,14 +53,22 @@ public class InvertedShellWrapper implem
private InputStream shellOut;
private InputStream shellErr;
private ExitCallback callback;
- private Thread thread;
public InvertedShellWrapper(InvertedShell shell) {
- this(shell, DEFAULT_BUFFER_SIZE);
+ this(shell, Executors.newSingleThreadExecutor(), DEFAULT_BUFFER_SIZE);
+ }
+
+ public InvertedShellWrapper(InvertedShell shell, Executor executor) {
+ this(shell, executor, DEFAULT_BUFFER_SIZE);
}
public InvertedShellWrapper(InvertedShell shell, int bufferSize) {
+ this(shell, Executors.newSingleThreadExecutor(), bufferSize);
+ }
+
+ public InvertedShellWrapper(InvertedShell shell, Executor executor, int bufferSize) {
this.shell = shell;
+ this.executor = executor;
this.bufferSize = bufferSize;
}
@@ -82,13 +94,11 @@ public class InvertedShellWrapper implem
shellIn = shell.getInputStream();
shellOut = shell.getOutputStream();
shellErr = shell.getErrorStream();
- thread = new Thread("inverted-shell-pump") {
- @Override
+ executor.execute(new NamePreservingRunnable(new Runnable() {
public void run() {
pumpStreams();
}
- };
- thread.start();
+ }, "inverted-shell-pump"));
}
public void destroy() {