weaver 2003/08/12 11:29:03
Modified: portal/src/webapp/WEB-INF/conf jetspeed-pipeline.xml
portal/src/test/org/apache/jetspeed/pipeline
TestPipeline.java
Added: portal/src/java/org/apache/jetspeed/pipeline/valve/impl
CleanupValveImpl.java
VerySimpleLayoutValveImpl.java
portal/src/webapp/pages SimpleLayoutHeader.jsp
SimpleLayoutFooter.jsp
Log:
Created a extremely simple layout valve as proof of concept
Revision Changes Path
1.1
jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/pipeline/valve/impl/CleanupValveImpl.java
Index: CleanupValveImpl.java
===================================================================
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Jetspeed" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* "Apache Jetspeed", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.jetspeed.pipeline.valve.impl;
import java.util.Stack;
import javax.servlet.RequestDispatcher;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.jetspeed.pipeline.PipelineException;
import org.apache.jetspeed.pipeline.valve.AbstractValve;
import org.apache.jetspeed.pipeline.valve.CleanupValve;
import org.apache.jetspeed.pipeline.valve.ValveContext;
import org.apache.jetspeed.request.RequestContext;
/**
* <p>
* CleanupValveImpl
* </p>
*
* All this valve does right now is look for JSP pages that were
* pushed onto the <code>org.apache.jetspeed.renderStack</code>
* request attribute, and attempts to includde them.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Scott T. Weaver</a>
* @version $Id: CleanupValveImpl.java,v 1.1 2003/08/12 18:29:03 weaver Exp $
*
*/
public class CleanupValveImpl extends AbstractValve implements CleanupValve
{
public static final String RENDER_STACK_ATTR = "org.apache.jetspeed.renderStack";
private static final Log log = LogFactory.getLog(CleanupValveImpl.class);
/**
* @see
org.apache.jetspeed.pipeline.valve.Valve#invoke(org.apache.jetspeed.request.RequestContext,
org.apache.jetspeed.pipeline.valve.ValveContext)
*/
public void invoke(RequestContext request, ValveContext context) throws
PipelineException
{
// Complete any renderings that are on the rendering stack
// TODO: we should abstract the rendering as we will
// wnat to eventually support other types of templates
// other than JSPs.
HttpServletRequest httpRequest = request.getRequest();
Stack renderStack = (Stack) httpRequest.getAttribute(RENDER_STACK_ATTR);
String fragment = null;
try
{
if (renderStack != null)
{
while (!renderStack.empty())
{
fragment = (String) renderStack.pop();
RequestDispatcher rd =
httpRequest.getRequestDispatcher(fragment);
rd.include(httpRequest, request.getResponse());
}
}
}
catch (Exception e)
{
log.error("CleanupValveImpl: failed while trying to render fragment " +
fragment);
log.error("CleanupValveImpl: Unable to complete all renderings", e);
}
}
/**
* @see java.lang.Object#toString()
*/
public String toString()
{
return "CleanupValveImpl";
}
}
1.1
jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/pipeline/valve/impl/VerySimpleLayoutValveImpl.java
Index: VerySimpleLayoutValveImpl.java
===================================================================
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Jetspeed" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* "Apache Jetspeed", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.jetspeed.pipeline.valve.impl;
import java.util.Stack;
import javax.servlet.RequestDispatcher;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.jetspeed.pipeline.PipelineException;
import org.apache.jetspeed.pipeline.valve.AbstractValve;
import org.apache.jetspeed.pipeline.valve.LayoutValve;
import org.apache.jetspeed.pipeline.valve.ValveContext;
import org.apache.jetspeed.request.RequestContext;
/**
* <p>
* VerySimpleLayoutValveImpl
* </p>
*
* Like the descriptions said this is a <b><i>very</i></b> simple
* layout valve and should not be used in production.
*
*
* @author <a href="mailto:[EMAIL PROTECTED]">Scott T. Weaver</a>
* @version $Id: VerySimpleLayoutValveImpl.java,v 1.1 2003/08/12 18:29:03 weaver Exp
$
*
*/
public class VerySimpleLayoutValveImpl extends AbstractValve implements LayoutValve
{
private static final Log log =
LogFactory.getLog(VerySimpleLayoutValveImpl.class);
/**
* @see
org.apache.jetspeed.pipeline.valve.Valve#invoke(org.apache.jetspeed.request.RequestContext,
org.apache.jetspeed.pipeline.valve.ValveContext)
*/
public void invoke(RequestContext request, ValveContext context) throws
PipelineException
{
try
{
log.info("Invoking the VerySimpleLayoutValve...");
HttpServletRequest httpRequest = request.getRequest();
RequestDispatcher rd =
httpRequest.getRequestDispatcher("/pages/SimpleLayoutHeader.jsp");
rd.include(httpRequest, request.getResponse());
Stack renderStack = (Stack)
httpRequest.getAttribute(CleanupValveImpl.RENDER_STACK_ATTR);
if (renderStack == null)
{
renderStack = new Stack();
httpRequest.setAttribute(CleanupValveImpl.RENDER_STACK_ATTR,
renderStack);
}
renderStack.push("/pages/SimpleLayoutFooter.jsp");
}
catch (Exception e)
{
log.error("VerySimpleLayout: Unable to include layout header. Layout
not processed", e);
}
finally
{
context.invokeNext(request);
}
}
/**
* @see java.lang.Object#toString()
*/
public String toString()
{
return "VerySimpleLayoutValveImpl";
}
}
1.1
jakarta-jetspeed-2/portal/src/webapp/pages/SimpleLayoutHeader.jsp
Index: SimpleLayoutHeader.jsp
===================================================================
<!-- pages/SimpleLayoutHader.jsp -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Welcome to Jetspeed 2</title>
</head>
<body>
<p>
<img src="../images/logo.png" alt="Jetspeed 2 Logo" width="311" height="106"
border="0">
</p>
1.1
jakarta-jetspeed-2/portal/src/webapp/pages/SimpleLayoutFooter.jsp
Index: SimpleLayoutFooter.jsp
===================================================================
<!-- pages/SimpleLayoutFooter.jsp -->
</body>
</html>
1.3 +6 -0
jakarta-jetspeed-2/portal/src/webapp/WEB-INF/conf/jetspeed-pipeline.xml
Index: jetspeed-pipeline.xml
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed-2/portal/src/webapp/WEB-INF/conf/jetspeed-pipeline.xml,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- jetspeed-pipeline.xml 11 Aug 2003 23:33:00 -0000 1.2
+++ jetspeed-pipeline.xml 12 Aug 2003 18:29:03 -0000 1.3
@@ -13,8 +13,14 @@
<valveDescriptor>
<className>org.apache.jetspeed.pipeline.valve.impl.ActionValveImpl</className>
</valveDescriptor>
+ <valveDescriptor>
+
<className>org.apache.jetspeed.pipeline.valve.impl.VerySimpleLayoutValveImpl</className>
+ </valveDescriptor>
<valveDescriptor>
<className>org.apache.jetspeed.aggregator.AggregatorValve</className>
+ </valveDescriptor>
+ <valveDescriptor>
+
<className>org.apache.jetspeed.pipeline.valve.impl.CleanupValveImpl</className>
</valveDescriptor>
</valveDescriptors>
</pipelineDescriptor>
1.3 +4 -2
jakarta-jetspeed-2/portal/src/test/org/apache/jetspeed/pipeline/TestPipeline.java
Index: TestPipeline.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed-2/portal/src/test/org/apache/jetspeed/pipeline/TestPipeline.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- TestPipeline.java 11 Aug 2003 23:31:00 -0000 1.2
+++ TestPipeline.java 12 Aug 2003 18:29:03 -0000 1.3
@@ -119,6 +119,8 @@
assertTrue(valves[1].toString().equals("ContainerValve"));
assertTrue(valves[2].toString().equals("ProfilerValve"));
assertTrue(valves[3].toString().equals("ActionValveImpl"));
- assertTrue(valves[4].toString().equals("AggregatorValve"));
+ assertTrue(valves[4].toString().equals("VerySimpleLayoutValveImpl"));
+ assertTrue(valves[5].toString().equals("AggregatorValve"));
+ assertTrue(valves[6].toString().equals("CleanupValveImpl"));
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]