Code polish. Removed irrelevant classes.

This commit is contained in:
nathan 2017-11-28 21:07:43 +01:00
parent ee968be141
commit aa9b2bc5ea
3 changed files with 21 additions and 94 deletions

View File

@ -104,11 +104,11 @@ class JvmExecutor extends ShellExecutor {
private List<String> jvmOptions = new ArrayList<String>(); private List<String> jvmOptions = new ArrayList<String>();
private List<String> classpathEntries = new ArrayList<String>(); private List<String> classpathEntries = new ArrayList<String>();
// what version of java??
// so, this starts a NEW java, from an ALREADY existing java.
private List<String> mainClassArguments = new ArrayList<String>(); private List<String> mainClassArguments = new ArrayList<String>();
private String jarFile; private String jarFile;
// what version of java??
// so, this starts a NEW JVM, from an ALREADY existing JVM.
public public
JvmExecutor() { JvmExecutor() {
super(null, null, null); super(null, null, null);
@ -140,7 +140,7 @@ class JvmExecutor extends ShellExecutor {
} }
public final public final
void addJvmClasspaths(List<String> paths) { void addJvmClasspath(List<String> paths) {
this.classpathEntries.addAll(paths); this.classpathEntries.addAll(paths);
} }

View File

@ -40,7 +40,8 @@ import java.util.Map;
public public
class ShellExecutor { class ShellExecutor {
// TODO: Add the ability to get the process PID via java for mac/windows/linux. Linux is avail from jvm, windows needs JNA // TODO: Add the ability to get the process PID via java for mac/windows/linux. Linux is avail from jvm, windows needs JNA, mac ???
// of important note, the pid needs to be gotten "on demand", as linux can change the pid if it wants to
static final String LINE_SEPARATOR = System.getProperty("line.separator"); static final String LINE_SEPARATOR = System.getProperty("line.separator");
static final boolean isWindows; static final boolean isWindows;
@ -68,9 +69,9 @@ class ShellExecutor {
private Process process = null; private Process process = null;
private ProcessProxy writeToProcess_input = null; private ProcessStreamProxy writeToProcess_input = null;
private ProcessProxy readFromProcess_output = null; private ProcessStreamProxy readFromProcess_output = null;
private ProcessProxy readFromProcess_error = null; private ProcessStreamProxy readFromProcess_error = null;
private boolean createReadWriterThreads = false; private boolean createReadWriterThreads = false;
@ -261,7 +262,7 @@ class ShellExecutor {
} }
/** /**
* @return the executable command issued to the shell * @return the executable command issued
*/ */
public public
String getCommand() { String getCommand() {
@ -462,7 +463,7 @@ class ShellExecutor {
// readers (read process -> write console) // readers (read process -> write console)
// have to keep the output buffers from filling in the target process. // have to keep the output buffers from filling in the target process.
readFromProcess_output = new ProcessProxy("Process Reader: " + this.executableName, readFromProcess_output = new ProcessStreamProxy("Process Reader: " + this.executableName,
this.process.getInputStream(), this.process.getInputStream(),
nullOutputStream); nullOutputStream);
} }
@ -474,12 +475,12 @@ class ShellExecutor {
* to the user's window. This is important or the spawned process could block. * to the user's window. This is important or the spawned process could block.
*/ */
// readers (read process -> write console) // readers (read process -> write console)
readFromProcess_output = new ProcessProxy("Process Reader: " + this.executableName, readFromProcess_output = new ProcessStreamProxy("Process Reader: " + this.executableName,
this.process.getInputStream(), this.process.getInputStream(),
this.outputStream); this.outputStream);
if (this.outputErrorStream != this.outputStream) { if (this.outputErrorStream != this.outputStream) {
readFromProcess_error = new ProcessProxy("Process Reader: " + this.executableName, readFromProcess_error = new ProcessStreamProxy("Process Reader: " + this.executableName,
this.process.getErrorStream(), this.process.getErrorStream(),
this.outputErrorStream); this.outputErrorStream);
} }
@ -490,7 +491,7 @@ class ShellExecutor {
* Proxy System.in from the user's window to the spawned process * Proxy System.in from the user's window to the spawned process
*/ */
// writer (read console -> write process) // writer (read console -> write process)
writeToProcess_input = new ProcessProxy("Process Writer: " + this.executableName, writeToProcess_input = new ProcessStreamProxy("Process Writer: " + this.executableName,
this.inputStream, this.inputStream,
this.process.getOutputStream()); this.process.getOutputStream());
} }

View File

@ -1,74 +0,0 @@
/*
* Copyright 2010 dorkbox, llc
*
* Licensed 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 dorkbox.executor;
import java.io.IOException;
import java.io.OutputStream;
public
class TeeOutputStream extends OutputStream {
private final OutputStream out;
private final OutputStream tee;
public
TeeOutputStream(OutputStream out, OutputStream tee) {
if (out == null) {
throw new NullPointerException();
}
else if (tee == null) {
throw new NullPointerException();
}
else {
this.out = out;
this.tee = tee;
}
}
@Override
public
void write(int b) throws IOException {
this.out.write(b);
this.tee.write(b);
}
@Override
public
void write(byte[] b) throws IOException {
this.out.write(b);
this.tee.write(b);
}
@Override
public
void write(byte[] b, int off, int len) throws IOException {
this.out.write(b, off, len);
this.tee.write(b, off, len);
}
@Override
public
void flush() throws IOException {
this.out.flush();
this.tee.flush();
}
@Override
public
void close() throws IOException {
this.out.close();
this.tee.close();
}
}