use of org.vcell.util.executable.InheritOutput in project vcell by virtualcell.
the class SBMLStandaloneImporter method createProcess.
private LiveProcess<ClosedInput, InheritOutput, InheritOutput> createProcess() throws ExecutableException, IOException {
@SuppressWarnings("resource") ServerSocket ss = new ServerSocket(0);
InetSocketAddress isa = (InetSocketAddress) ss.getLocalSocketAddress();
String home = System.getProperty("java.home");
String exe = home + "/bin/java";
String classpath = System.getProperty("java.class.path");
String us = getClass().getName();
ArrayList<String> cmdArgs = new ArrayList<String>();
cmdArgs.add(exe);
cmdArgs.addAll(jvmArgs());
String[] invokeArgs = { "-classpath", classpath, us };
cmdArgs.addAll(Arrays.asList(invokeArgs));
InheritOutput i = new InheritOutput();
LiveProcess<ClosedInput, InheritOutput, InheritOutput> lp = new LiveProcess<ClosedInput, InheritOutput, InheritOutput>(new ClosedInput(), i, i, cmdArgs.toArray(new String[cmdArgs.size()]));
lp.setEnvironment(PORT_KEY, Integer.toString(isa.getPort()));
lp.setEnvironment(HOST_KEY, isa.getHostName());
lp.begin(OUR_LABEL);
ss.setSoTimeout(START_TIMEOUT_SECONDS * 1000);
try {
channel = ss.accept();
} catch (SocketTimeoutException sto) {
throw new ExecutableException("Standalone client failed to communicate in " + START_TIMEOUT_SECONDS + " seconds");
}
toChildProcess = new ObjectOutputStream(channel.getOutputStream());
fromChildProcess = new ObjectInputStream(channel.getInputStream());
return lp;
}
Aggregations