Coverage report

  %line %branch
nl.toolforge.karma.core.cmd.impl.DocAllModules
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.impl;
 20  
 
 21  
 import nl.toolforge.karma.core.KarmaRuntimeException;
 22  
 import nl.toolforge.karma.core.cmd.Command;
 23  
 import nl.toolforge.karma.core.cmd.CommandDescriptor;
 24  
 import nl.toolforge.karma.core.cmd.CommandException;
 25  
 import nl.toolforge.karma.core.cmd.CommandFactory;
 26  
 import nl.toolforge.karma.core.cmd.CommandLoadException;
 27  
 import nl.toolforge.karma.core.cmd.CommandResponse;
 28  
 import nl.toolforge.karma.core.cmd.DefaultCommand;
 29  
 import nl.toolforge.karma.core.cmd.event.ErrorEvent;
 30  
 import nl.toolforge.karma.core.cmd.threads.ParallelCommandWrapper;
 31  
 import nl.toolforge.karma.core.manifest.ManifestException;
 32  
 import nl.toolforge.karma.core.module.Module;
 33  
 
 34  
 import java.util.Collection;
 35  
 import java.util.Iterator;
 36  
 
 37  
 /**
 38  
  * Generates API documentation for all modules.
 39  
  *
 40  
  * @author W.H. Schraal
 41  
  * @author D.A. Schraal
 42  
  */
 43  
 public class DocAllModules extends DefaultCommand {
 44  
 
 45  0
   private CommandResponse commandResponse = new CommandResponse();
 46  
 
 47  
   public DocAllModules(CommandDescriptor descriptor) {
 48  0
     super(descriptor);
 49  0
   }
 50  
 
 51  
   public void execute() throws CommandException {
 52  
 
 53  
     // A manifest must be present for this command
 54  
     //
 55  0
     if (!getContext().isManclass="keyword">ifestLoaded()) {
 56  0
       throw new CommandException(ManifestException.NO_ACTIVE_MANIFEST);
 57  
     }
 58  
 
 59  0
     Collection modules = getContext().getCurrentManifest().getAllModules().values();
 60  
 
 61  
     // Initialize an array of threads.
 62  
     //
 63  0
     ParallelCommandWrapper[] threads = new ParallelCommandWrapper[modules.size()];
 64  
 
 65  0
     int j = 0;
 66  0
     for (Iterator i = modules.iterator(); i.hasNext();) {
 67  0
       Module module = (Module) i.next();
 68  
 
 69  0
       String commandLineString = "dm -m " + module.getName();
 70  0
       Command clone = null;
 71  
       try {
 72  0
         clone = CommandFactory.getInstance().getCommand(commandLineString);
 73  0
       } catch (CommandLoadException e) {
 74  0
         throw new CommandException(e.getErrorCode(), e.getMessageArguments());
 75  0
       }
 76  0
       clone.setContext(getContext());
 77  
 
 78  0
       threads[j] = new ParallelCommandWrapper(clone, getResponseListener());
 79  0
       threads[j].start();
 80  0
       j++;
 81  
     }
 82  
 
 83  0
     int totalThreads = threads.length;
 84  
 
 85  0
     for (int i = 0; i < totalThreads; i++) {
 86  
 
 87  
       try {
 88  0
         threads[i].join();
 89  
 
 90  0
         if (threads[i].getException() != null) {
 91  0
           getCommandResponse().addEvent(
 92  
               new ErrorEvent(this, threads[i].getException().getErrorCode(), threads[i].getException().getMessageArguments()));
 93  
         }
 94  0
       } catch (InterruptedException e) {
 95  0
         throw new KarmaRuntimeException(e.getMessage());
 96  0
       }
 97  
     }
 98  0
   }
 99  
 
 100  
   public CommandResponse getCommandResponse() {
 101  0
     return commandResponse;
 102  
   }
 103  
 
 104  
 }

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