Clover coverage report - angkor - 0.4
Coverage timestamp: ti okt 15 2002 22:32:48 CEST
file stats: LOC: 98   Methods: 3
NCLOC: 63   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
PrerenderValve.java 0% 0% 0% 0%
 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.jsp;
 9   
 
 10   
 import com.tirsen.angkor.Application;
 11   
 import com.tirsen.angkor.Debug;
 12   
 import com.tirsen.angkor.RenderContext;
 13   
 import com.tirsen.angkor.View;
 14   
 import com.tirsen.angkor.ViewFactory;
 15   
 import com.tirsen.angkor.process.ExecuteContext;
 16   
 import com.tirsen.angkor.process.Pipeline;
 17   
 import com.tirsen.angkor.process.RenderValve;
 18   
 import com.tirsen.angkor.process.Valve;
 19   
 import org.apache.log4j.Category;
 20   
 
 21   
 import java.util.Iterator;
 22   
 import java.util.Map;
 23   
 
 24   
 /**
 25   
  * <!-- $Id: PrerenderValve.java,v 1.3 2002/10/09 21:37:37 tirsen Exp $ -->
 26   
  * <!-- $Author: tirsen $ -->
 27   
  *
 28   
  * @author Jon Tirs&acute;n (tirsen@users.sourceforge.net)
 29   
  * @version $Revision: 1.3 $
 30   
  */
 31   
 public class PrerenderValve extends RenderValve
 32   
 {
 33   
     private static final Category logger = Debug.getCategory();
 34   
 
 35   
     /**
 36   
      * The resulting {@link PrerenderedComponentsRegistry} resulting from this valve.
 37   
      */
 38   
     public static final ExecuteContext.Attribute PrerenderedComponentsRegistryAttribute = new ExecuteContext.Attribute("PrerenderedComponentsRegistry");
 39   
 
 40   
     /**
 41   
      * Name of the component to be prerendered in the registry.
 42   
      */
 43   
     private static final ExecuteContext.Attribute RegistryNameAttribute = new ExecuteContext.Attribute("RegistryName");
 44   
 
 45   
     public static class DoPrerenderValve implements Valve
 46   
     {
 47  0
         public void execute(ExecuteContext exec) throws Exception
 48   
         {
 49  0
             PrerenderedComponentsRegistry registry = (PrerenderedComponentsRegistry) exec.getAttribute(PrerenderedComponentsRegistryAttribute);
 50  0
             String name = (String) exec.getAttribute(RegistryNameAttribute);
 51  0
             View view = (View) exec.getAttribute(ExecuteContext.CurrentViewAttribute);
 52   
 
 53  0
             logger.debug("prerendering view " + name + " = " + view);
 54  0
             registry.prerender(name, view);
 55   
 
 56  0
             exec.executeNext();
 57   
         }
 58   
     }
 59   
 
 60  0
     protected Pipeline createRenderPipeline()
 61   
     {
 62  0
         Pipeline pipeline = super.createRenderPipeline();
 63  0
         pipeline.addValve(new DoPrerenderValve());
 64  0
         return pipeline;
 65   
     }
 66   
 
 67  0
     public void execute(ExecuteContext exec) throws Exception
 68   
     {
 69  0
         RenderContext context = (RenderContext) exec.getAttribute(ExecuteContext.RenderContextAttribute);
 70  0
         Application application = (Application) exec.getAttribute(ExecuteContext.ApplicationAttribute);
 71   
 
 72  0
         PrerenderedComponentsRegistry registry = new PrerenderedComponentsRegistry(context);
 73  0
         exec.setAttribute(PrerenderedComponentsRegistryAttribute, registry);
 74   
 
 75  0
         Map components = application.getComponentsToPrerender();
 76  0
         Pipeline subPipeline = createRenderPipeline();
 77  0
         for (Iterator iterator = components.entrySet().iterator(); iterator.hasNext();)
 78   
         {
 79  0
             Map.Entry entry = (Map.Entry) iterator.next();
 80  0
             ExecuteContext subExec = subPipeline.createSubContext(exec);
 81  0
             String name = (String) entry.getKey();
 82  0
             subExec.setAttribute(RegistryNameAttribute, name);
 83  0
             if (entry.getValue() instanceof View)
 84   
             {
 85  0
                 subExec.setAttribute(ExecuteContext.CurrentViewAttribute, entry.getValue());
 86   
             }
 87  0
             else if (entry.getValue() instanceof ViewFactory)
 88   
             {
 89  0
                 subExec.setAttribute(ViewFactoryAttribute, entry.getValue());
 90   
             }
 91   
 
 92  0
             subPipeline.execute(subExec);
 93   
         }
 94   
 
 95  0
         exec.executeNext();
 96   
     }
 97   
 }
 98