jvanzyl 02/01/17 19:33:58
Modified: . default.properties
conf turbine-classic-pipeline.xml
src/java/org/apache/turbine/pipeline ClassicPipeline.java
DefaultActionValve.java DefaultResolver.java
DefaultTargetValve.java DirectClassicPipeline.java
DirectRenderer.java DirectTargetValve.java
Renderer.java
Added: conf turbine-direct-pipeline.xml
Log:
- Applying a nice big patch by James Taylor (that's right James Taylor)
which is a great start to cleanup of the pipeline. Thanks!
Revision Changes Path
1.10 +1 -1 jakarta-turbine-3/default.properties
Index: default.properties
===================================================================
RCS file: /home/cvs/jakarta-turbine-3/default.properties,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- default.properties 17 Jan 2002 16:43:22 -0000 1.9
+++ default.properties 18 Jan 2002 03:33:57 -0000 1.10
@@ -65,4 +65,4 @@
# Port that will be used to start the servlet engines for testing. This is
# optional and if omitted will default to 8080. This is used when you don't
# want to interfere with a running servlet engine on port 8080.
-test.port=8180
+test.port=8182
1.2 +3 -0 jakarta-turbine-3/conf/turbine-classic-pipeline.xml
Index: turbine-classic-pipeline.xml
===================================================================
RCS file: /home/cvs/jakarta-turbine-3/conf/turbine-classic-pipeline.xml,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- turbine-classic-pipeline.xml 17 Jan 2002 16:37:31 -0000 1.1
+++ turbine-classic-pipeline.xml 18 Jan 2002 03:33:58 -0000 1.2
@@ -1,7 +1,10 @@
<pipeline>
<name>TurbineClassicPipeline</name>
<valves>
+ <valve className="org.apache.turbine.pipeline.DetermineActionValve"/>
+ <valve className="org.apache.turbine.pipeline.DetermineTargetValve"/>
<valve className="org.apache.turbine.pipeline.DefaultActionValve"/>
+ <valve className="org.apache.turbine.pipeline.RunModulesValve"/>
<valve className="org.apache.turbine.pipeline.DefaultTargetValve"/>
</valves>
</pipeline>
1.1 jakarta-turbine-3/conf/turbine-direct-pipeline.xml
Index: turbine-direct-pipeline.xml
===================================================================
<pipeline>
<name>TurbineClassicPipeline</name>
<valves>
<valve className="org.apache.turbine.pipeline.DetermineActionValve"/>
<valve className="org.apache.turbine.pipeline.DetermineTargetValve"/>
<valve className="org.apache.turbine.pipeline.DefaultActionValve"/>
<valve className="org.apache.turbine.pipeline.RunModulesValve"/>
<valve className="org.apache.turbine.pipeline.DirectTargetValve"/>
</valves>
</pipeline>
1.15 +2 -2
jakarta-turbine-3/src/java/org/apache/turbine/pipeline/ClassicPipeline.java
Index: ClassicPipeline.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-3/src/java/org/apache/turbine/pipeline/ClassicPipeline.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- ClassicPipeline.java 3 Jan 2002 04:53:55 -0000 1.14
+++ ClassicPipeline.java 18 Jan 2002 03:33:58 -0000 1.15
@@ -65,11 +65,11 @@
* The ClassicPipeline uses the 'template' (as described by RunData's
* target attribute) as a starting point for output.
*
- * @author <a href="mailto:[EMAIL PROTECTED]">Mike Haberman</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Jon S. Stevens</a>
+ * @author <a href="mailto:[EMAIL PROTECTED]">Mike Haberman</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Daniel Rall</a>
- * @version $Id: ClassicPipeline.java,v 1.14 2002/01/03 04:53:55 dlr Exp $
+ * @version $Id: ClassicPipeline.java,v 1.15 2002/01/18 03:33:58 jvanzyl Exp $
* @deprecated Use TurbinePipeline with the
* turbine-classic-pipeline.xml pipeline descriptor instead.
*/
1.3 +12 -14
jakarta-turbine-3/src/java/org/apache/turbine/pipeline/DefaultActionValve.java
Index: DefaultActionValve.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-3/src/java/org/apache/turbine/pipeline/DefaultActionValve.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DefaultActionValve.java 11 Jan 2002 23:16:40 -0000 1.2
+++ DefaultActionValve.java 18 Jan 2002 03:33:58 -0000 1.3
@@ -58,7 +58,6 @@
import java.util.Enumeration;
import org.apache.commons.collections.ExtendedProperties;
-import org.apache.turbine.Log;
import org.apache.turbine.DynamicURI;
import org.apache.turbine.Turbine;
import org.apache.turbine.TurbineConstants;
@@ -70,23 +69,27 @@
import org.apache.turbine.Valve;
import org.apache.turbine.ValveContext;
import org.apache.turbine.modules.Module;
-import org.apache.turbine.modules.ModuleLoader;
+import org.apache.turbine.modules.Action;
import org.apache.turbine.modules.actions.AccessController;
import org.apache.turbine.modules.actions.SessionValidator;
+import org.apache.log4j.Category;
/**
* Implements the action portion of the "Turbine classic" processing
* pipeline (from the Turbine 2.x series).
*
- * @author <a href="mailto:[EMAIL PROTECTED]">Mike Haberman</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Jon S. Stevens</a>
+ * @author <a href="mailto:[EMAIL PROTECTED]">Mike Haberman</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Daniel Rall</a>
- * @version $Id: DefaultActionValve.java,v 1.2 2002/01/11 23:16:40 dlr Exp $
+ * @version $Id: DefaultActionValve.java,v 1.3 2002/01/18 03:33:58 jvanzyl Exp $
*/
public class DefaultActionValve
implements Valve, TurbineConstants
{
+ private static final Category log =
+ Category.getInstance( DefaultActionValve.class );
+
/**
* The default session timeout.
*/
@@ -157,7 +160,7 @@
protected void process(RunData data)
throws Exception
{
- Log.debug("[ClassicValve] process()");
+ log.debug("Entering process method");
if (data.getSession().isNew())
{
@@ -169,10 +172,6 @@
}
}
- // Fill in the screen and action variables.
- data.setAction(data.getParameters()
- .getString(ACTION));
-
// Special case for login and logout, this must happen before the
// session validator is executed in order either to allow a user to
// even login, or to ensure that the session validator gets to
@@ -208,9 +207,8 @@
}
}
- Module action;
- action = Turbine.getResolver().getModule(ACTIONS,
- data.getAction());
+ Action action =
+ (Action) Turbine.getResolver().getModule( ACTION, data.getAction()
);
action.execute(data);
data.setAction(null);
}
@@ -260,8 +258,8 @@
// can re-define the template definition.
if (data.hasAction())
{
- Turbine.getResolver().getModule
- (Turbine.ACTIONS, data.getAction()).execute(data);
+ Turbine.getResolver()
+ .getModule( ACTION, data.getAction() ).execute( data );
}
}
1.11 +6 -3
jakarta-turbine-3/src/java/org/apache/turbine/pipeline/DefaultResolver.java
Index: DefaultResolver.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-3/src/java/org/apache/turbine/pipeline/DefaultResolver.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- DefaultResolver.java 17 Jan 2002 16:38:54 -0000 1.10
+++ DefaultResolver.java 18 Jan 2002 03:33:58 -0000 1.11
@@ -61,9 +61,9 @@
import java.util.Iterator;
import org.apache.turbine.Turbine;
import org.apache.turbine.TurbineConstants;
-import org.apache.turbine.Log;
import org.apache.turbine.Resolver;
import org.apache.turbine.modules.Module;
+import org.apache.log4j.Category;
// Renderers and context builders
// We need to match up the target template with sibling
@@ -134,11 +134,14 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Mike Haberman</a>
- * @version $Id: DefaultResolver.java,v 1.10 2002/01/17 16:38:54 jvanzyl Exp $
+ * @version $Id: DefaultResolver.java,v 1.11 2002/01/18 03:33:58 jvanzyl Exp $
*/
public class DefaultResolver
implements Resolver, TurbineConstants
{
+ private static final Category log =
+ Category.getInstance( DefaultResolver.class );
+
protected String defaultTemplate;
public void init()
@@ -156,7 +159,7 @@
defaultTemplate = "/" + defaultTemplate;
}
- Log.debug("DefaultResolver: default template " + defaultTemplate);
+ log.debug("DefaultResolver: default template " + defaultTemplate);
}
/**
1.5 +43 -44
jakarta-turbine-3/src/java/org/apache/turbine/pipeline/DefaultTargetValve.java
Index: DefaultTargetValve.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-3/src/java/org/apache/turbine/pipeline/DefaultTargetValve.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- DefaultTargetValve.java 17 Jan 2002 16:38:54 -0000 1.4
+++ DefaultTargetValve.java 18 Jan 2002 03:33:58 -0000 1.5
@@ -59,7 +59,6 @@
import org.apache.commons.collections.ExtendedProperties;
import org.apache.fulcrum.security.util.AccessControlList;
-import org.apache.turbine.Log;
import org.apache.turbine.DynamicURI;
import org.apache.turbine.Turbine;
import org.apache.turbine.TurbineConstants;
@@ -70,25 +69,28 @@
import org.apache.turbine.Valve;
import org.apache.turbine.ValveContext;
import org.apache.turbine.modules.Module;
-import org.apache.turbine.modules.ModuleLoader;
import org.apache.turbine.modules.actions.AccessController;
+import org.apache.log4j.Category;
/**
* Implements the RunData target portion of the "Turbine classic"
* processing pipeline (from the Turbine 2.x series).
*
- * @author <a href="mailto:[EMAIL PROTECTED]">Mike Haberman</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Jon S. Stevens</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Daniel Rall</a>
- * @version $Id: DefaultTargetValve.java,v 1.4 2002/01/17 16:38:54 jvanzyl Exp $
+ * @author <a href="mailto:[EMAIL PROTECTED]">Mike Haberman</a>
+ * @author <a href="mailto:[EMAIL PROTECTED]">James Taylor</a>
+ * @version $Id: DefaultTargetValve.java,v 1.5 2002/01/18 03:33:58 jvanzyl Exp $
*/
public class DefaultTargetValve
implements Valve
{
+ private static final Category log =
+ Category.getInstance( DefaultTargetValve.class );
+
protected static final String DEFAULT_MODULE_TYPE = "screens";
- protected ModuleRunner runner = null;
protected String targetModuleType = DEFAULT_MODULE_TYPE;
/**
@@ -98,10 +100,8 @@
*/
public DefaultTargetValve()
{
- // Instantiate the ModuleRunner
- runner = new ModuleRunner();
-
ExtendedProperties cfg = Turbine.getConfiguration();
+
if (cfg != null)
{
// Get the module type
@@ -142,47 +142,46 @@
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.
+ // Get the target that will determine the template / layout
+
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 ...
+ // Get the template context, already populated by any context
+ // builders that were found for this target
+
+ TemplateContext context = Module.getTemplateContext( data );
+
+ // Resolve the layout template for this target
+
+ String layout = Turbine.getResolver().getTemplate("layouts", target);
+
+ // Use the renderer to render the layout,
+
+ render( data, context, layout );
+ }
+
+ protected void render( RunData data, TemplateContext context, String target )
+ throws Exception
+ {
+ if ( log.isDebugEnabled() )
+ {
+ log.debug( "Rendering target " + target );
+ }
+
Renderer r = new Renderer();
- TemplateContext context = Module.getTemplateContext(data);
- // FIXME: Remove hard coding!
+
+ // FIXME: Can we remove some hardcoding here?
+
context.put("renderer", r);
- context.put("template", target);
- context.put("runner", runner);
+ context.put("template", target);
- // 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);
- data.getOut().print(out);
-
- // Note that the target is not yet rendered in the classic
- // Turbine 2.x -- $screen_placeholder held the result of
- // r.render(data, data.getTarget()).
+ // Render the target
+
+ String out = r.render(data, target);
+
+ // Write the composed string to the response
+
+ data.getOut().print( out );
}
/**
1.5 +3 -3
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.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- DirectClassicPipeline.java 3 Jan 2002 04:54:47 -0000 1.4
+++ DirectClassicPipeline.java 18 Jan 2002 03:33:58 -0000 1.5
@@ -54,7 +54,6 @@
* <http://www.apache.org/>.
*/
-import org.apache.turbine.Log;
import org.apache.turbine.RunData;
import org.apache.turbine.Turbine;
import org.apache.turbine.TemplateContext;
@@ -70,12 +69,13 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">John McNally</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Daniel Rall</a>
- * @version $Id: DirectClassicPipeline.java,v 1.4 2002/01/03 04:54:47 dlr Exp $
+ * @version $Id: DirectClassicPipeline.java,v 1.5 2002/01/18 03:33:58 jvanzyl Exp $
* @see org.apache.turbine.pipeline.ClassicPipeline
* @deprecated Use TurbinePipeline with the
* direct-classic-turbine-pipeline.xml pipeline descriptor instead.
*/
-public class DirectClassicPipeline extends TurbinePipeline
+public class DirectClassicPipeline
+ extends TurbinePipeline
{
/**
* Supplies an unbuffered version of the
1.3 +9 -5
jakarta-turbine-3/src/java/org/apache/turbine/pipeline/DirectRenderer.java
Index: DirectRenderer.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-3/src/java/org/apache/turbine/pipeline/DirectRenderer.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DirectRenderer.java 7 Dec 2001 23:06:26 -0000 1.2
+++ DirectRenderer.java 18 Jan 2002 03:33:58 -0000 1.3
@@ -60,7 +60,7 @@
import org.apache.turbine.modules.Module;
import org.apache.turbine.TemplateContext;
import org.apache.turbine.TurbineException;
-import org.apache.turbine.Log;
+import org.apache.log4j.Category;
/**
* This class is used in the context to render templates.
@@ -68,10 +68,14 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Jon S. Stevens</a>
* @author <a href="mailto:[EMAIL PROTECTED]">John McNally</a>
- * @version $Id: DirectRenderer.java,v 1.2 2001/12/07 23:06:26 jon Exp $
+ * @version $Id: DirectRenderer.java,v 1.3 2002/01/18 03:33:58 jvanzyl Exp $
*/
-public class DirectRenderer extends Renderer
+public class DirectRenderer
+ extends Renderer
{
+ private static final Category log =
+ Category.getInstance( DirectRenderer.class );
+
private static final String EMPTY = "";
private Writer writer;
@@ -90,12 +94,12 @@
{
try
{
- Log.debug("[DirectClassicPipeline] render target => " + target);
+ log.debug("Rendering target " + target);
Module.handleRequest(context, target, writer);
}
catch (Exception e)
{
- Log.error(e);
+ log.error("Rendering failed", e);
Module.handleRequest(context, "screens/Error.vm", writer);
}
return EMPTY;
1.2 +23 -47
jakarta-turbine-3/src/java/org/apache/turbine/pipeline/DirectTargetValve.java
Index: DirectTargetValve.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-3/src/java/org/apache/turbine/pipeline/DirectTargetValve.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DirectTargetValve.java 3 Jan 2002 04:55:18 -0000 1.1
+++ DirectTargetValve.java 18 Jan 2002 03:33:58 -0000 1.2
@@ -54,14 +54,14 @@
* <http://www.apache.org/>.
*/
-import org.apache.turbine.Log;
import org.apache.turbine.RunData;
import org.apache.turbine.Turbine;
import org.apache.turbine.TemplateContext;
import org.apache.turbine.modules.Module;
+import org.apache.log4j.Category;
/**
- * This <code>Valve</code> overrides the <code>execute()</code> method
+ * This <code>Valve</code> overrides the <code>render()</code> method
* of DefaultTargetValve, so that the response is written as the
* template is rendered. In "Turbine classic" mode (from the 2.x
* days) the results of template rendering are buffered (built up as a
@@ -69,63 +69,39 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">John McNally</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Daniel Rall</a>
- * @version $Id: DirectTargetValve.java,v 1.1 2002/01/03 04:55:18 dlr Exp $
+ * @author <a href="mailto:[EMAIL PROTECTED]">James Taylor</a>
+ * @version $Id: DirectTargetValve.java,v 1.2 2002/01/18 03:33:58 jvanzyl Exp $
* @see org.apache.turbine.pipeline.ClassicPipeline
*/
-public class DirectTargetValve extends DefaultTargetValve
+public class DirectTargetValve
+ extends DefaultTargetValve
{
+ private static final Category log =
+ Category.getInstance( DirectTargetValve.class );
+
/**
* 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)
+ protected void render( RunData data, TemplateContext context, String target )
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.
+ {
+ if ( log.isDebugEnabled() )
+ {
+ log.debug( "Rendering target " + target );
+ }
- // 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);
+ Renderer r = new DirectRenderer( data.getOut() );
+
+ // FIXME: Can we remove some hardcoding here?
+
context.put("renderer", r);
- context.put("template", target);
- context.put("runner", runner);
+ context.put("template", target);
- // 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);
- }
+ // Render the target directly to the response
+
+ r.render( data, target );
}
}
1.6 +9 -6
jakarta-turbine-3/src/java/org/apache/turbine/pipeline/Renderer.java
Index: Renderer.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-3/src/java/org/apache/turbine/pipeline/Renderer.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- Renderer.java 7 Dec 2001 23:09:04 -0000 1.5
+++ Renderer.java 18 Jan 2002 03:33:58 -0000 1.6
@@ -59,30 +59,33 @@
import org.apache.turbine.RunData;
import org.apache.turbine.modules.Module;
import org.apache.turbine.TurbineException;
-import org.apache.turbine.Log;
import org.apache.turbine.TemplateContext;
+import org.apache.log4j.Category;
/**
* This class is used in the context to render templates.
*
- * @author <a href="mailto:[EMAIL PROTECTED]">Mike Haberman</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Jon S. Stevens</a>
- * @version $Id: Renderer.java,v 1.5 2001/12/07 23:09:04 jon Exp $
+ * @author <a href="mailto:[EMAIL PROTECTED]">Mike Haberman</a>
+ * @version $Id: Renderer.java,v 1.6 2002/01/18 03:33:58 jvanzyl Exp $
*/
public class Renderer
{
+ private static final Category log =
+ Category.getInstance( Renderer.class );
+
public String render(TemplateContext context, String target)
throws TurbineException, Exception
{
try
{
- Log.debug("[ClassicPipeline] render target => " + target);
+ log.debug("Rendering target " + target);
return Module.handleRequest(context, target);
}
catch (Exception e)
{
- Log.error(e);
+ log.error("Rendering failed", e);
return Module.handleRequest(context, "screens/Error.vm");
}
}
@@ -107,7 +110,7 @@
public String render(RunData data, String target)
throws TurbineException, Exception
{
- Log.debug("[ClassicPipeline] render target => " + target);
+ log.debug("Rendering target " + target);
TemplateContext context = Module.getTemplateContext(data);
return Module.handleRequest(context, target);
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>