org.mortbay.util
Class LifeCycleThread

java.lang.Object
  extended by org.mortbay.util.LifeCycleThread
All Implemented Interfaces:
java.lang.Runnable, LifeCycle
Direct Known Subclasses:
Listener, Server

public abstract class LifeCycleThread
extends java.lang.Object
implements LifeCycle, java.lang.Runnable

Base Thread class implementing LifeCycle.

Version:
$Revision: 1.9 $
Author:
Greg Wilkins (gregw)

Constructor Summary
LifeCycleThread()
           
 
Method Summary
 boolean error(java.lang.Error e)
          Handle error from loop.
 boolean exception(java.lang.Exception e)
          Handle exception from loop.
 java.lang.Thread getThread()
           
 boolean isDaemon()
           
 boolean isStarted()
           
abstract  void loop()
           
 void run()
           
 void setDaemon(boolean d)
           
 void start()
          Start the LifeCycle.
 void stop()
          Stop the LifeCycle.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LifeCycleThread

public LifeCycleThread()
Method Detail

isDaemon

public boolean isDaemon()

setDaemon

public void setDaemon(boolean d)

getThread

public java.lang.Thread getThread()

isStarted

public boolean isStarted()
Specified by:
isStarted in interface LifeCycle
Returns:
True if the LifeCycle has been started.

start

public void start()
           throws java.lang.Exception
Description copied from interface: LifeCycle
Start the LifeCycle.

Specified by:
start in interface LifeCycle
Throws:
java.lang.Exception - An arbitrary exception may be thrown.

stop

public void stop()
          throws java.lang.InterruptedException
Description copied from interface: LifeCycle
Stop the LifeCycle. The LifeCycle may wait for current activities to complete normally, but it can be interrupted.

Specified by:
stop in interface LifeCycle
Throws:
java.lang.InterruptedException - Stopping a lifecycle is rarely atomic and may be interrupted by another thread. If this happens InterruptedException is throw and the component will be in an indeterminant state and should probably be discarded.

run

public final void run()
Specified by:
run in interface java.lang.Runnable

exception

public boolean exception(java.lang.Exception e)
Handle exception from loop.

Parameters:
e - The exception
Returns:
True of the loop should continue;

error

public boolean error(java.lang.Error e)
Handle error from loop.

Parameters:
e - The exception
Returns:
True of the loop should continue;

loop

public abstract void loop()
                   throws java.lang.InterruptedException,
                          java.io.InterruptedIOException,
                          java.lang.Exception
Throws:
java.lang.InterruptedException
java.io.InterruptedIOException
java.lang.Exception


Copyright © 2004 Mortbay Consulting Pty. Ltd. All Rights Reserved.