1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.jetspeed.pipeline.valve.impl;
18
19 import java.util.Stack;
20
21 import javax.servlet.RequestDispatcher;
22 import javax.servlet.http.HttpServletRequest;
23
24 import org.apache.commons.logging.Log;
25 import org.apache.commons.logging.LogFactory;
26 import org.apache.jetspeed.pipeline.PipelineException;
27 import org.apache.jetspeed.pipeline.valve.AbstractValve;
28 import org.apache.jetspeed.pipeline.valve.CleanupValve;
29 import org.apache.jetspeed.pipeline.valve.ValveContext;
30 import org.apache.jetspeed.request.RequestContext;
31
32 /***
33 * <p>
34 * CleanupValveImpl
35 * </p>
36 *
37 * All this valve does right now is look for JSP pages that were
38 * pushed onto the <code>org.apache.jetspeed.renderStack</code>
39 * request attribute, and attempts to includde them.
40 *
41 * @author <a href="mailto:weaver@apache.org">Scott T. Weaver</a>
42 * @version $Id: CleanupValveImpl.java 516448 2007-03-09 16:25:47Z ate $
43 *
44 */
45 public class CleanupValveImpl extends AbstractValve implements CleanupValve
46 {
47
48 public static final String RENDER_STACK_ATTR = "org.apache.jetspeed.renderStack";
49
50 private static final Log log = LogFactory.getLog(CleanupValveImpl.class);
51
52
53 public CleanupValveImpl()
54 {
55 }
56
57 /***
58 * @see org.apache.jetspeed.pipeline.valve.Valve#invoke(org.apache.jetspeed.request.RequestContext, org.apache.jetspeed.pipeline.valve.ValveContext)
59 */
60 public void invoke(RequestContext request, ValveContext context) throws PipelineException
61 {
62
63
64
65
66
67
68 HttpServletRequest httpRequest = request.getRequest();
69 Stack renderStack = (Stack) httpRequest.getAttribute(RENDER_STACK_ATTR);
70 String fragment = null;
71 try
72 {
73 if (renderStack != null)
74 {
75 while (!renderStack.empty())
76 {
77 fragment = (String) renderStack.pop();
78 RequestDispatcher rd = httpRequest.getRequestDispatcher(fragment);
79 rd.include(httpRequest, request.getResponse());
80 }
81 }
82 }
83 catch (Exception e)
84 {
85 log.error("CleanupValveImpl: failed while trying to render fragment " + fragment);
86 log.error("CleanupValveImpl: Unable to complete all renderings", e);
87 }
88 }
89
90 /***
91 * @see java.lang.Object#toString()
92 */
93 public String toString()
94 {
95 return "CleanupValveImpl";
96 }
97
98 }