/*
* Angkor Web Framework
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package com.tirsen.angkor.process;
import com.tirsen.angkor.Application;
import com.tirsen.angkor.Debug;
import com.tirsen.angkor.RenderContext;
import com.tirsen.angkor.View;
import org.apache.log4j.Category;
import java.util.Iterator;
/**
* <!-- $Id: ParseValve.java,v 1.4 2002/10/13 13:37:26 tirsen Exp $ -->
* <!-- $Author: tirsen $ -->
* @author Jon Tirs´n (tirsen@users.sourceforge.net)
* @version $Revision: 1.4 $
public class ParseValve implements Valve
{
private static final Category logger = Debug.getCategory();
private Pipeline createParsePipeline()
Pipeline pipeline = new DefaultPipeline();
pipeline.addValve(new ParseComponentValve());
return pipeline;
}
public static class ParseComponentValve implements Valve
public void execute(ExecuteContext exec) throws Exception
View currentView = (View) exec.getAttribute(ExecuteContext.CurrentViewAttribute);
RenderContext renderContext = (RenderContext) exec.getAttribute(ExecuteContext.RenderContextAttribute);
logger.debug("parsing view " + currentView);
currentView.parse(renderContext);
Application application = (Application) exec.getAttribute(ExecuteContext.ApplicationAttribute);
try
Pipeline parsePipeline = createParsePipeline();
Iterator it = application.iterateParsingComponents();
while (it.hasNext())
View view = (View) it.next();
ExecuteContext subExec = parsePipeline.createSubContext(exec);
subExec.setAttribute(ExecuteContext.CurrentViewAttribute, view);
parsePipeline.execute(subExec);
finally
application.resetParsingComponents();
exec.executeNext();