Home | History | Annotate | Download | only in stack
      1 /*
      2  * @author:     Brett Buckingham
      3  * @author:     Last modified by: $Author: emcho $
      4  * @version:    $Date: 2009/07/17 18:58:14 $ $Revision: 1.3 $
      5  *
      6  * This source code has been contributed to the public domain.
      7  */
      8 
      9 package gov.nist.javax.sip.stack;
     10 
     11 import java.util.TimerTask;
     12 
     13 /**
     14  * A subclass of TimerTask which runs TimerTask code within a try/catch block to
     15  * avoid killing the SIPTransactionStack timer thread. Note: subclasses MUST not
     16  * override run(); instead they should override runTask().
     17  *
     18  * @author Brett Buckingham
     19  *
     20  */
     21 public abstract class SIPStackTimerTask extends TimerTask {
     22     // / Implements code to be run when the SIPStackTimerTask is executed.
     23     protected abstract void runTask();
     24 
     25     // / The run() method is final to ensure that all subclasses inherit the
     26     // exception handling.
     27     public final void run() {
     28         try {
     29             runTask();
     30         } catch (Throwable e) {
     31             System.out.println("SIP stack timer task failed due to exception:");
     32             e.printStackTrace();
     33         }
     34     }
     35 }
     36