Clover coverage report - Replica - 1.0-Alpha
Coverage timestamp: Dom Fev 1 2004 17:00:58 WET
file stats: LOC: 80   Methods: 4
NCLOC: 32   Classes: 1
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover
 
 Source file Conditionals Statements Methods TOTAL
ApplicationCommandProcessor.java 0% 8,3% 25% 10%
coverage coverage
 1   
 /*
 2   
  * Replica is published under the terms
 3   
  * of the Apache Software License.
 4   
  */
 5   
 package replica.core;
 6   
 
 7   
 import java.util.logging.Level;
 8   
 import java.util.logging.Logger;
 9   
 
 10   
 import replica.command.Command;
 11   
 import replica.command.CommandException;
 12   
 import replica.command.beans.BeansCommandProcessor;
 13   
 
 14   
 /**
 15   
  * This processor extends the beans processor to provide suport for
 16   
  * ApplicationMessages as command argument.
 17   
  *  
 18   
  * @author Pedro Costa
 19   
  * @author Helder Silva
 20   
  * @since 21/Jan/2004
 21   
  */
 22   
 public class ApplicationCommandProcessor extends BeansCommandProcessor {
 23   
 
 24   
     static Logger logger = Logger.getLogger(ApplicationCommandProcessor.class.getName());
 25   
     
 26   
     /**
 27   
      * 
 28   
      */
 29  6
     public ApplicationCommandProcessor() {
 30  6
         super();
 31   
     }
 32   
 
 33   
     /**
 34   
      * This default implementation assumes that command is a string and that the first word is the action Id.
 35   
      * 
 36   
      *  It passes the all command instruction, including the action Id, to the mapped command on execute.
 37   
      *  
 38   
      * @return Object the result of the command execution.
 39   
      * @see replica.server.cmd.CommandProcessor#process(java.lang.String)
 40   
      * @throws CommandException if there is a problem executing the command.
 41   
      *          Callers can choose to catch or not.
 42   
      */
 43  0
     public Object process(Object command){
 44   
         
 45  0
         if( command instanceof ApplicationMessage )
 46  0
             return process((ApplicationMessage) command);
 47   
         
 48  0
         return super.process(command);
 49   
     }
 50   
     
 51  0
     protected Object process(ApplicationMessage appMsg){
 52   
         
 53  0
         try{
 54  0
             Command c = getCommand( appMsg.getBody());
 55   
             
 56  0
             if( c == null)
 57  0
                 throw new CommandException("Command not found.");
 58   
                 
 59  0
             return executeCommand( c, appMsg);
 60   
         }
 61   
         catch(Throwable e){
 62  0
             logger.log(Level.WARNING, e.getMessage(), e);
 63  0
             return "Error executing [" + appMsg.getBody().toString() + "] : " + e.getMessage();
 64   
         }
 65   
     }
 66   
     
 67   
     /**
 68   
      * Default beahavior,simple call the execute method on command.
 69   
      * 
 70   
      * @param command
 71   
      * @param appMsg
 72   
      * @return
 73   
      */
 74  0
     protected Object executeCommand( Command command, ApplicationMessage appMsg ){
 75   
         
 76  0
         return command.execute( appMsg);
 77   
     }
 78   
     
 79   
 }
 80