org.apache.commons.launcher
Class ParentListener

java.lang.Object
  |
  +--java.lang.Thread
        |
        +--org.apache.commons.launcher.ParentListener
All Implemented Interfaces:
java.lang.Runnable

public class ParentListener
extends java.lang.Thread

A class for detecting if the parent JVM that launched this process has terminated.

Author:
Patrick Luby

Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
ParentListener(java.io.File heartbeatFile)
          Validates and caches a lock file created by the parent JVM.
 
Method Summary
 void run()
          Periodically check that the parent JVM has not terminated by checking if System#out and System#err are open.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ParentListener

public ParentListener(java.io.File heartbeatFile)
Validates and caches a lock file created by the parent JVM.
Parameters:
heartbeatFile - the lock file that the parent JVM will delete when it wants this process to exit
Method Detail

run

public void run()
Periodically check that the parent JVM has not terminated by checking if System#out and System#err are open. If either stream is in an error state, the parent JVM is assumed to be terminated and this method will invoke System#exit(int). This method must be executed before either System#setOut(PrintStream) or System#setErr(PrintStream) is ever invoked.

In addition, we check if the heartbeat file has been deleted. If so, we assume the parent is requesting that this process terminate itself.

Overrides:
run in class java.lang.Thread


Copyright (c) 2001-2002 - Apache Software Foundation