Coverage report

  %line %branch
nl.toolforge.karma.core.vc.threads.RunnerThread
82% 
100% 

 1  
 /*
 2  
 Karma core - Core of the Karma application
 3  
 Copyright (C) 2004  Toolforge <www.toolforge.nl>
 4  
 
 5  
 This library is free software; you can redistribute it and/or
 6  
 modify it under the terms of the GNU Lesser General Public
 7  
 License as published by the Free Software Foundation; either
 8  
 version 2.1 of the License, or (at your option) any later version.
 9  
 
 10  
 This library is distributed in the hope that it will be useful,
 11  
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 12  
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 13  
 Lesser General Public License for more details.
 14  
 
 15  
 You should have received a copy of the GNU Lesser General Public
 16  
 License along with this library; if not, write to the Free Software
 17  
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 18  
 */
 19  
 package nl.toolforge.karma.core.vc.threads;
 20  
 
 21  
 import nl.toolforge.karma.core.KarmaRuntimeException;
 22  
 import nl.toolforge.karma.core.module.Module;
 23  
 
 24  
 /**
 25  
  * @author D.A. Smedes
 26  
  * @version $Id: RunnerThread.java,v 1.6 2004/11/10 23:53:09 asmedes Exp $
 27  
  */
 28  
 public abstract class RunnerThread extends Thread {
 29  
 
 30  50
   private boolean running = true;
 31  
 
 32  50
   protected Throwable exception = null;
 33  50
   protected RunnerResult result = null;
 34  50
   private Module module = null;
 35  
 
 36  50
   public RunnerThread(Module module) {
 37  50
     this.module = module;
 38  50
   }
 39  
 
 40  
   /**
 41  
    * Must be implemented by subclasses. The subclass is where all logic is performed.
 42  
    */
 43  
   public abstract void run();
 44  
 
 45  
   /**
 46  
    * Should be called to demarkate the start of the 'transaction'.
 47  
    */
 48  
   protected void startRunning() {
 49  50
     running = true;
 50  50
   }
 51  
 
 52  
   /**
 53  
    * Should be called to demarkate the end of the 'transaction'.
 54  
    */
 55  
   protected void stopRunning() {
 56  50
     running = false;
 57  50
   }
 58  
 
 59  
   /**
 60  
    * Should be checked to ensure that <code>run()</code> is finished.
 61  
    *
 62  
    * @return
 63  
    */
 64  
   public final boolean isRunning() {
 65  0
     return running;
 66  
   }
 67  
 
 68  
   public final RunnerResult getResult() {
 69  50
     return result;
 70  
   }
 71  
 
 72  
   /**
 73  
    * Returns the module status, irrespective of whether this thread has finished executing or not. This check can be
 74  
    * performed by calling {@link #isRunning()}.
 75  
    *
 76  
    * @return The ModuleStatus instance generated based on what the {@link #run()} has done when executed properly.
 77  
    */
 78  
   public Module getModule() {
 79  250
     if (module == null) {
 80  0
       throw new KarmaRuntimeException("Module instance has not been set.");
 81  
     }
 82  250
     return module;
 83  
   }
 84  
 
 85  
   public Throwable getException() {
 86  0
     return exception;
 87  
   }
 88  
 
 89  
 }

This report is generated by jcoverage, Maven and Maven JCoverage Plugin.