Coverage report

  %line %branch
nl.toolforge.karma.core.cmd.threads.ParallelCommandWrapper
0% 
0% 

 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.cmd.threads;
 20  
 
 21  
 import nl.toolforge.karma.core.cmd.Command;
 22  
 import nl.toolforge.karma.core.cmd.CommandException;
 23  
 import nl.toolforge.karma.core.cmd.CommandResponse;
 24  
 import nl.toolforge.karma.core.cmd.event.CommandResponseListener;
 25  
 
 26  
 
 27  
 /**
 28  
  *
 29  
  * @author D.A. Smedes
 30  
  *
 31  
  * @version $Id: ParallelCommandWrapper.java,v 1.3 2004/09/23 07:18:08 asmedes Exp $
 32  
  */
 33  
 public final class ParallelCommandWrapper extends Thread {
 34  
 
 35  0
   private boolean running = true;
 36  
 
 37  0
   private Command command = null;
 38  
   private CommandResponseListener listener;
 39  0
   private CommandException exception = null;
 40  
 
 41  0
   public ParallelCommandWrapper(Command command, CommandResponseListener listener) {
 42  0
     this.command = command;
 43  0
     this.listener = listener;
 44  0
   }
 45  
 
 46  
   public CommandResponse getCommandResponse() {
 47  0
     return null;
 48  
   }
 49  
 
 50  
   public void run() {
 51  
 
 52  
     try {
 53  
 
 54  0
       startRunning();
 55  
 
 56  0
       command.execute();
 57  
 
 58  0
     } catch (CommandException c) {
 59  0
       exception = c;
 60  
     } finally {
 61  0
       stopRunning();
 62  0
     }
 63  0
   }
 64  
 
 65  
   private synchronized void startRunning() {
 66  
 
 67  0
     running = true;
 68  0
     command.registerCommandResponseListener(listener);
 69  0
   }
 70  
 
 71  
   private synchronized void stopRunning() {
 72  
 
 73  0
     command.deregisterCommandResponseListener(listener);
 74  0
     command.cleanUp();
 75  
 
 76  0
     running = false;
 77  0
   }
 78  
 
 79  
   public synchronized boolean isRunning() {
 80  0
     return running;
 81  
   }
 82  
 
 83  
   /**
 84  
    * Returns the <code>CommandException</code> when the <code>run</code>-method had thrown one. This method can thus be
 85  
    * used to check the actual results (if an error occurred).
 86  
    *
 87  
    * @return A <code>CommandException</code> or <code>null</code> if no exception was thrown.
 88  
    */
 89  
   public CommandException getException() {
 90  0
     return exception;
 91  
   }
 92  
 
 93  
 }

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