com.tc.lcp
Class LinkedJavaProcess

java.lang.Object
  extended by java.lang.Process
      extended by com.tc.lcp.LinkedJavaProcess

public class LinkedJavaProcess
extends java.lang.Process

A child Java process that uses a socket-based ping protocol to make sure that if the parent dies, the child dies a short time thereafter. Useful for avoiding 'zombie child processes' when writing tests, etc. — otherwise, if the parent process crashes or otherwise terminates abnormally, you'll get child processes accumulating until all hell breaks loose on the box.

Although it can't actually be related through Java inheritance (because Processis a class, not an interface), this class behaves essentially identical to Processwith two differences:


Constructor Summary
LinkedJavaProcess(java.lang.String mainClassName)
           
LinkedJavaProcess(java.lang.String mainClassName, java.util.List<java.lang.String> classArguments)
           
LinkedJavaProcess(java.lang.String mainClassName, java.util.List<java.lang.String> classArguments, java.util.List<java.lang.String> jvmArgs)
           
 
Method Summary
 void addAllJvmArgs(java.util.List<java.lang.String> jvmArgs)
           
 void addJvmArg(java.lang.String jvmArg)
           
 void destroy()
           
 int exitValue()
           
 java.lang.String[] getCommand()
           
 java.io.InputStream getErrorStream()
          This is the spawned process's stderr.
 java.io.InputStream getInputStream()
          Java names these things a bit funny — this is the spawned process's stdout.
 java.io.File getJavaHome()
           
 long getMaxRuntime()
           
 java.io.OutputStream getOutputStream()
          Java names these things a bit funny — this is the spawned process's stdin.
 void mergeSTDERR()
           
 void mergeSTDERR(java.lang.String identifier)
           
 void mergeSTDOUT()
           
 void mergeSTDOUT(java.lang.String identifier)
           
 void setAddL1Repos(boolean flag)
           
 void setClasspath(java.lang.String classpath)
           
 void setDirectory(java.io.File directory)
           
 void setEnvironment(java.util.List<java.lang.String> environment)
           
 void setJavaExecutable(java.io.File javaExecutable)
           
 void setJavaHome(java.io.File javaHome)
           
 void setMaxRuntime(long maxRuntime)
           
 void start()
           
 java.io.InputStream STDERR()
           
 java.io.OutputStream STDIN()
           
 java.io.InputStream STDOUT()
           
 int waitFor()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LinkedJavaProcess

public LinkedJavaProcess(java.lang.String mainClassName,
                         java.util.List<java.lang.String> classArguments,
                         java.util.List<java.lang.String> jvmArgs)

LinkedJavaProcess

public LinkedJavaProcess(java.lang.String mainClassName)

LinkedJavaProcess

public LinkedJavaProcess(java.lang.String mainClassName,
                         java.util.List<java.lang.String> classArguments)
Method Detail

setMaxRuntime

public void setMaxRuntime(long maxRuntime)

getMaxRuntime

public long getMaxRuntime()

setClasspath

public void setClasspath(java.lang.String classpath)

getJavaHome

public java.io.File getJavaHome()

setJavaHome

public void setJavaHome(java.io.File javaHome)

setJavaExecutable

public void setJavaExecutable(java.io.File javaExecutable)

addAllJvmArgs

public void addAllJvmArgs(java.util.List<java.lang.String> jvmArgs)

addJvmArg

public void addJvmArg(java.lang.String jvmArg)

setEnvironment

public void setEnvironment(java.util.List<java.lang.String> environment)

setDirectory

public void setDirectory(java.io.File directory)

setAddL1Repos

public void setAddL1Repos(boolean flag)

destroy

public void destroy()
Specified by:
destroy in class java.lang.Process

start

public void start()
           throws java.io.IOException
Throws:
java.io.IOException

getInputStream

public java.io.InputStream getInputStream()
Java names these things a bit funny — this is the spawned process's stdout.

Specified by:
getInputStream in class java.lang.Process

getCommand

public java.lang.String[] getCommand()

STDOUT

public java.io.InputStream STDOUT()

STDIN

public java.io.OutputStream STDIN()

STDERR

public java.io.InputStream STDERR()

mergeSTDOUT

public void mergeSTDOUT()

mergeSTDOUT

public void mergeSTDOUT(java.lang.String identifier)

mergeSTDERR

public void mergeSTDERR()

mergeSTDERR

public void mergeSTDERR(java.lang.String identifier)

getErrorStream

public java.io.InputStream getErrorStream()
This is the spawned process's stderr.

Specified by:
getErrorStream in class java.lang.Process

getOutputStream

public java.io.OutputStream getOutputStream()
Java names these things a bit funny — this is the spawned process's stdin.

Specified by:
getOutputStream in class java.lang.Process

exitValue

public int exitValue()
Specified by:
exitValue in class java.lang.Process

waitFor

public int waitFor()
            throws java.lang.InterruptedException
Specified by:
waitFor in class java.lang.Process
Throws:
java.lang.InterruptedException


Copyright © 2010 Terracotta, Inc.. All Rights Reserved.