Clover coverage report - angkor - 0.4
Coverage timestamp: ti okt 15 2002 22:32:48 CEST
file stats: LOC: 70   Methods: 3
NCLOC: 42   Classes: 2
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
EventValve.java 100% 100% 100% 100%
 1   
 /*
 2   
  * Angkor Web Framework
 3   
  *
 4   
  * Distributable under LGPL license.
 5   
  * See terms of license at gnu.org.
 6   
  */
 7   
 
 8   
 package com.tirsen.angkor.process;
 9   
 
 10   
 import com.tirsen.angkor.Application;
 11   
 import com.tirsen.angkor.RenderContext;
 12   
 import com.tirsen.angkor.event.EventQueue;
 13   
 
 14   
 import java.util.Iterator;
 15   
 
 16   
 /**
 17   
  * <!-- $Id: EventValve.java,v 1.4 2002/10/13 13:37:26 tirsen Exp $ -->
 18   
  * <!-- $Author: tirsen $ -->
 19   
  *
 20   
  * @author Jon Tirs&acute;n (tirsen@users.sourceforge.net)
 21   
  * @version $Revision: 1.4 $
 22   
  */
 23   
 public class EventValve implements Valve
 24   
 {
 25   
     public static final ExecuteContext.Attribute CurrentEventAttribute = new ExecuteContext.Attribute("CurrentEvent");
 26   
 
 27   
     /**
 28   
      * Create a sub-pipeline which is executed for each event. This pipeline catches warnings (according to
 29   
      * {@link Application.isWarning(Throwable)} but not fatal errors. If a warnings occurs event processing continues.
 30   
      */
 31  10
     private Pipeline createEventPipeline()
 32   
     {
 33  10
         Pipeline pipeline = new DefaultPipeline();
 34  10
         pipeline.addValve(new ProcessEventValve());
 35  10
         return pipeline;
 36   
     }
 37   
 
 38   
     public static class ProcessEventValve implements Valve
 39   
     {
 40  6
         public void execute(ExecuteContext exec) throws Exception
 41   
         {
 42  6
             EventQueue.QueuedEvent event = (EventQueue.QueuedEvent) exec.getAttribute(CurrentEventAttribute);
 43  6
             Application application = (Application) exec.getAttribute(ExecuteContext.ApplicationAttribute);
 44  6
             event.send(application);
 45   
         }
 46   
     }
 47   
 
 48  10
     public void execute(ExecuteContext exec) throws Exception
 49   
     {
 50  10
         Application application = (Application) exec.getAttribute(ExecuteContext.ApplicationAttribute);
 51  10
         RenderContext renderContext = (RenderContext) exec.getAttribute(ExecuteContext.RenderContextAttribute);
 52   
         // events no longer need to be postponed until later, but can instead be processed immediately
 53  10
         renderContext.getEventQueue().setPostponeEvents(false);
 54  10
         Pipeline eventPipeline = createEventPipeline();
 55  10
         Iterator it = renderContext.getEventQueue().iterateEvents();
 56  10
         while (it.hasNext())
 57   
         {
 58  6
             EventQueue.QueuedEvent event = (EventQueue.QueuedEvent) it.next();
 59  6
             ExecuteContext subExec = eventPipeline.createExecuteContext(renderContext);
 60  6
             subExec.setAttribute(CurrentEventAttribute, event);
 61   
             // bind current view to get warnings associated with the source of the event
 62  6
             subExec.setAttribute(ExecuteContext.CurrentViewAttribute, event.getEvent().getSource());
 63  6
             eventPipeline.execute(subExec);
 64   
         }
 65  10
         exec.executeNext();
 66   
         // restore to the next time
 67  10
         renderContext.getEventQueue().setPostponeEvents(true);
 68   
     }
 69   
 }
 70