dlr 02/01/02 20:54:47
Modified: src/java/org/apache/turbine/pipeline
DirectClassicPipeline.java
Log:
o Moved DirectTargetValve inner instance class into a stand-alone
class.
o Using addValve() API to add default Valves.
o Deprecated DirectClassicPipeline in favor of TurbinePipeline +
direct-classic-pipeline.xml.
Revision Changes Path
1.4 +10 -63
jakarta-turbine-3/src/java/org/apache/turbine/pipeline/DirectClassicPipeline.java
Index: DirectClassicPipeline.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-3/src/java/org/apache/turbine/pipeline/DirectClassicPipeline.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -u -r1.3 -r1.4
--- DirectClassicPipeline.java 29 Dec 2001 22:32:48 -0000 1.3
+++ DirectClassicPipeline.java 3 Jan 2002 04:54:47 -0000 1.4
@@ -58,6 +58,7 @@
import org.apache.turbine.RunData;
import org.apache.turbine.Turbine;
import org.apache.turbine.TemplateContext;
+import org.apache.turbine.Valve;
import org.apache.turbine.modules.Module;
/**
@@ -69,76 +70,22 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">John McNally</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Daniel Rall</a>
- * @version $Id: DirectClassicPipeline.java,v 1.3 2001/12/29 22:32:48 dlr Exp $
+ * @version $Id: DirectClassicPipeline.java,v 1.4 2002/01/03 04:54:47 dlr Exp $
* @see org.apache.turbine.pipeline.ClassicPipeline
+ * @deprecated Use TurbinePipeline with the
+ * direct-classic-turbine-pipeline.xml pipeline descriptor instead.
*/
-public class DirectClassicPipeline extends ClassicPipeline
+public class DirectClassicPipeline extends TurbinePipeline
{
/**
- * Supplies our version of the <code>DefaultTargetValve</code>.
+ * Supplies an unbuffered version of the
+ * <code>DefaultTargetValve</code>.
*/
public void init()
throws Exception
{
- super.init();
- super.valves[1] = new DirectTargetValve();
- }
-
- protected class DirectTargetValve extends DefaultTargetValve
- {
- /**
- * Renders and writes result to the output stream in an
- * unbuffered fashion.
- *
- * @see org.apache.turbine.pipeline.DefaultTargetValve#execute(RunData)
- */
- protected void execute(RunData data)
- throws Exception
- {
- data.getResponse().setLocale(data.getLocale());
- data.getResponse().setContentType(data.getContentType());
-
- // run the module chain
- // Need to execute the module that matches the template
- // if it exists.
- // As long as data.getTarget() changes during execution,
- // the new target is run , and so on
-
- runner.run(targetModuleType, data);
-
- // The execution of the module that corresponds to the requested
- // template may result in the target template being changed.
- // This happens for example when a user isn't logged in. The
- // template requested is '/Index.vm', but executing an Index
- // module might result in the target template being changed
- // to '/Login.vm'. We want to reset the target template value
- // here in case it has changed.
- String target = data.getTarget();
-
- // With this target template we start by rendering
- // the appropriate layout template and everything
- // goes from there.
-
- // Now I think we have to find a page template based
- // on the content type. What other criterion could
- // we use. Maybe you might want to change it if
- // you were branding ...
- Renderer r = new DirectRenderer(data.getOut());
- TemplateContext context = Module.getTemplateContext(data);
- context.put("renderer", r);
- context.put("template", target);
- context.put("runner", runner);
-
- // now we can use the renderer here
- // use the renderer to start the whole shabang
- String layoutTemplate = Turbine.getResolver()
- .getTemplate("layouts", target);
- String out = r.render(data, layoutTemplate);
- if (out != null && out.length() > 0)
- {
- // Write the response directly to the output stream.
- data.getOut().print(out);
- }
- }
+ // Add the unbuffered classic Valves to our pipeline
+ addValve(new DefaultActionValve());
+ addValve(new DirectTargetValve());
}
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>