You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beehive.apache.org by cr...@apache.org on 2006/11/17 18:21:30 UTC
svn commit: r476221 - in /beehive/trunk/netui:
src/scoping/org/apache/beehive/netui/pageflow/scoping/
src/scoping/org/apache/beehive/netui/pageflow/scoping/internal/
test/webapps/drt/src/mockportal/
Author: crogers
Date: Fri Nov 17 09:21:29 2006
New Revision: 476221
URL: http://svn.apache.org/viewvc?view=rev&rev=476221
Log:
For BEEHIVE-1031, ScopedRequest.getNamesOfRemovableAttributes() returns names of attributes that do not need to be saved in a session or restored later for a follow up refresh request. They are not required for the refresh request. Use this to optimize the set of request attributes that may be stored in a user session and later restored as attributes for a refresh request.
The MockPortletTag class was updated to use this new method for our the mock portal tests.
Tests: NetUI BVT (WinXP passed)
Modified:
beehive/trunk/netui/src/scoping/org/apache/beehive/netui/pageflow/scoping/ScopedRequest.java
beehive/trunk/netui/src/scoping/org/apache/beehive/netui/pageflow/scoping/internal/ScopedRequestImpl.java
beehive/trunk/netui/test/webapps/drt/src/mockportal/MockPortletTag.java
Modified: beehive/trunk/netui/src/scoping/org/apache/beehive/netui/pageflow/scoping/ScopedRequest.java
URL: http://svn.apache.org/viewvc/beehive/trunk/netui/src/scoping/org/apache/beehive/netui/pageflow/scoping/ScopedRequest.java?view=diff&rev=476221&r1=476220&r2=476221
==============================================================================
--- beehive/trunk/netui/src/scoping/org/apache/beehive/netui/pageflow/scoping/ScopedRequest.java (original)
+++ beehive/trunk/netui/src/scoping/org/apache/beehive/netui/pageflow/scoping/ScopedRequest.java Fri Nov 17 09:21:29 2006
@@ -20,6 +20,7 @@
import javax.servlet.http.HttpServletRequest;
import java.util.Map;
+import java.util.List;
/**
@@ -33,25 +34,25 @@
extends HttpServletRequest
{
public String AUTOSCOPE_PREFIX = "_autoscope_";
-
-
+
+
public void setRequestURI( String uri );
/**
* Adds a scope to "listen" to. This scope will see all request parameters from a ScopedRequest
* of the given scope.
- */
+ */
public void addListenScope( Object scopeKey );
-
+
public void doForward();
public String getForwardedURI();
/**
* @deprecated Use {@link ScopedResponse#didRedirect} instead.
- */
+ */
public boolean didRedirect();
-
+
/**
* Stores the current map of request attributes in the Session.
* @deprecated Moved the persisting of attributes out of the beehive NetUI
@@ -65,7 +66,7 @@
* layer. Use {@link #setAttributeMap} to set/merge the attributes.
*/
public void restoreAttributes();
-
+
/**
* Get the current map of request attributes.
*/
@@ -76,17 +77,29 @@
*/
public void setAttributeMap( Map map );
+ /**
+ * Returns names of attributes that do not need to be saved in a session
+ * or restored later for a follow up refresh request. They are not
+ * required for the refresh request. Use this to optimize the set of
+ * request attributes that may be stored in a user session and later
+ * restored as attributes for a refresh request.
+ *
+ * @return a list of names of attribute that do not need to be persisted
+ * in the user session.
+ */
+ public List getNamesOfRemovableAttributes();
+
public HttpServletRequest getOuterRequest();
-
+
public Object getScopeKey();
-
+
public void renameScope( Object newScopeKey );
-
+
/**
* Makes this request listen to specially-prefixed request parameters.
- */
+ */
public void setActiveRequest();
-
+
public String getScopedName( String baseName );
public void registerOuterAttribute( String attrName );
@@ -94,18 +107,18 @@
public String getLocalParameter( String attrName );
public String getListenScopeParameter( String attrName );
public boolean hasListenScopes();
-
+
/**
* Same as <code>getAttribute</code>, but allows outer request attributes to be hidden explicitly, even if the implementation
* of getAttribute shows them by default.
- */
+ */
public Object getAttribute( String attrName, boolean allowOuterRequestAttributes );
-
+
/**
* @exclude
- */
+ */
public Map filterParameterMap( Map parameterMap );
-
+
/**
* Simply stores the URI that was being forwarded to.
*/
Modified: beehive/trunk/netui/src/scoping/org/apache/beehive/netui/pageflow/scoping/internal/ScopedRequestImpl.java
URL: http://svn.apache.org/viewvc/beehive/trunk/netui/src/scoping/org/apache/beehive/netui/pageflow/scoping/internal/ScopedRequestImpl.java?view=diff&rev=476221&r1=476220&r2=476221
==============================================================================
--- beehive/trunk/netui/src/scoping/org/apache/beehive/netui/pageflow/scoping/internal/ScopedRequestImpl.java (original)
+++ beehive/trunk/netui/src/scoping/org/apache/beehive/netui/pageflow/scoping/internal/ScopedRequestImpl.java Fri Nov 17 09:21:29 2006
@@ -18,29 +18,29 @@
*/
package org.apache.beehive.netui.pageflow.scoping.internal;
-import org.apache.beehive.netui.pageflow.scoping.ScopedRequest;
-import org.apache.beehive.netui.pageflow.scoping.ScopedServletUtils;
-import org.apache.beehive.netui.util.logging.Logger;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
-import javax.servlet.http.HttpServletRequestWrapper;
-import javax.servlet.RequestDispatcher;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletContext;
-import java.util.Enumeration;
-import java.util.Map;
-import java.util.Collections;
+import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
-import java.util.Iterator;
+import java.util.Collections;
+import java.util.Enumeration;
import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
import java.util.List;
+import java.util.Map;
import java.util.Set;
-import java.util.HashSet;
-import java.io.UnsupportedEncodingException;
+import javax.servlet.RequestDispatcher;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+import javax.servlet.http.HttpServletRequestWrapper;
+
+import org.apache.beehive.netui.pageflow.scoping.ScopedRequest;
+import org.apache.beehive.netui.pageflow.scoping.ScopedServletUtils;
+import org.apache.beehive.netui.util.logging.Logger;
-import org.apache.commons.codec.net.URLCodec;
import org.apache.commons.codec.DecoderException;
+import org.apache.commons.codec.net.URLCodec;
/**
@@ -70,25 +70,38 @@
private static final String OUR_SESSION_ATTR = ATTR_PREFIX + "scopedSession";
private static final String STORED_ATTRS_ATTR = ATTR_PREFIX + "storedAttrs";
- private static final Logger _log = Logger.getInstance( ScopedRequestImpl.class );
+ private static final Logger LOGGER = Logger.getInstance( ScopedRequestImpl.class );
private static final URLCodec URL_CODEC = new URLCodec();
+ private static final ArrayList REMOVABLE_ATTRIBUTE_NAMES = new ArrayList();
+
+ static {
+ // set on the request by the PageFlowPageFilter via ImplicitObjectUtil
+ REMOVABLE_ATTRIBUTE_NAMES.add("pageFlow");
+ REMOVABLE_ATTRIBUTE_NAMES.add("sharedFlow");
+ REMOVABLE_ATTRIBUTE_NAMES.add("globalApp");
+
+ // set on the request by the PageFlowPageFilter via InternalUtils.selectModule()
+ REMOVABLE_ATTRIBUTE_NAMES.add("_defaultMsgs");
+
+ REMOVABLE_ATTRIBUTE_NAMES.add("_netui:fwdModule");
+ }
public ScopedRequestImpl( HttpServletRequest req, String overrideRequestURI, Object scopeKey,
ServletContext servletContext, boolean seeOuterRequestAttributes )
{
super( req );
-
+
_scopedContainer = new ScopedAttributeContainer( scopeKey );
setRequestURI( overrideRequestURI );
_seeOuterRequestAttributes = seeOuterRequestAttributes;
-
+
if ( ! seeOuterRequestAttributes ) _visibleOuterRequestAttrs = new HashSet();
}
/**
* @deprecated Use {@link #ScopedRequestImpl(HttpServletRequest, String, Object, ServletContext, boolean)}.
- */
+ */
public ScopedRequestImpl( HttpServletRequest req, String overrideRequestURI, Object scopeKey,
ServletContext context )
{
@@ -108,47 +121,42 @@
public void setRequestURI( String uri )
{
_requestURI = uri;
-
+
if ( uri == null )
{
_servletPath = null;
return;
}
-
- //
+
// Set the servlet path (decoded)
- //
assert uri.startsWith( getOuterRequest().getContextPath() ) : uri;
setServletPath( uri.substring( getOuterRequest().getContextPath().length() ) );
}
-
+
public void setRequestURI( String contextPath, String servletPath )
{
_requestURI = contextPath + servletPath;
setServletPath( servletPath );
}
-
+
private void setServletPath( String servletPath )
{
String encoding = getCharacterEncoding();
-
- try
- {
+
+ try {
if ( encoding == null ) encoding = "utf-8";
servletPath = URL_CODEC.decode( servletPath, encoding );
}
- catch ( DecoderException e )
- {
- _log.error( "error decoding path " + servletPath, e );
+ catch (DecoderException e) {
+ LOGGER.error("error decoding path " + servletPath, e);
}
- catch ( UnsupportedEncodingException e )
- {
- _log.error( "unsupported encoding " + encoding + " while decoding path " + servletPath, e );
+ catch (UnsupportedEncodingException e) {
+ LOGGER.error("unsupported encoding " + encoding + " while decoding path " + servletPath, e);
}
-
+
_servletPath = ScopedServletUtils.normalizeURI( servletPath );
}
-
+
public StringBuffer getRequestURL()
{
HttpServletRequest outerRequest = getOuterRequest();
@@ -171,26 +179,26 @@
{
retVal = getListenScopeParameter( paramName );
}
-
+
return retVal;
}
/**
* Add a parameter to the request.
- *
+ *
* @param name the parameter name.
* @param value the parameter value.
- */
+ */
public void addParameter( String name, String value )
{
if ( _additionalParameters == null )
{
_additionalParameters = new HashMap();
}
-
+
_additionalParameters.put( name, value );
}
-
+
/**
* Get the parameter from the scoped request only (don't check in listen scoped requests)
* @param paramName
@@ -215,7 +223,7 @@
{
retVal = request.getParameter( paramName );
}
-
+
return retVal;
}
@@ -240,7 +248,7 @@
return retVal;
}
-
+
public Enumeration getParameterNames()
{
ArrayList paramNames = new ArrayList();
@@ -300,10 +308,10 @@
{
return filterParameterMap( getRequest().getParameterMap() );
}
-
+
/**
* @exclude
- */
+ */
public Map filterParameterMap( Map parameterMap )
{
HashMap map = new HashMap();
@@ -361,7 +369,7 @@
public void doForward()
{
String forwardedURI = _forwardedURI;
-
+
if ( forwardedURI != null )
{
if ( ! forwardedURI.startsWith( "/" ) )
@@ -374,7 +382,7 @@
{
setRequestURI( getOuterRequest().getContextPath(), forwardedURI );
}
-
+
// Parse the query string and add parameters to the internal map
parseQueryParameters();
}
@@ -403,7 +411,7 @@
}
HashMap queryParameters = new HashMap();
- ParseUtils.parseQueryString(queryString, queryParameters, getCharacterEncoding());
+ ParseUtils.parseQueryString(queryString, queryParameters, getCharacterEncoding());
Iterator itor = queryParameters.keySet().iterator();
while (itor.hasNext())
@@ -430,7 +438,7 @@
/**
* @deprecated Use {@link ScopedResponseImpl#didRedirect} instead.
- */
+ */
public boolean didRedirect()
{
return false;
@@ -495,6 +503,20 @@
_scopedContainer.setAttrMap( attrs );
}
+ /**
+ * Returns names of attributes that do not need to be saved in a session
+ * or restored later for a follow up refresh request. They are not
+ * required for the refresh request. Use this to optimize the set of
+ * request attributes that may be stored in a user session and later
+ * restored as attributes for a refresh request.
+ *
+ * @return a list of names of attribute that do not need to be persisted
+ * in the user session.
+ */
+ public List getNamesOfRemovableAttributes() {
+ return REMOVABLE_ATTRIBUTE_NAMES;
+ }
+
public final HttpServletRequest getOuterRequest()
{
return ( HttpServletRequest ) getRequest();
@@ -504,25 +526,25 @@
{
return getAttribute( attrName, true );
}
-
+
public final Object getAttribute( String attrName, boolean allowOuterRequestAttributes )
{
if ( ! allowOuterRequestAttributes ) return _scopedContainer.getAttribute( attrName );
-
+
ServletRequest outerRequest = getRequest();
-
+
if ( ! _seeOuterRequestAttributes && _visibleOuterRequestAttrs.contains( attrName ) )
{
return outerRequest.getAttribute( attrName );
}
Object value = _scopedContainer.getAttribute( attrName );
-
+
if ( value == null && _seeOuterRequestAttributes )
{
value = outerRequest.getAttribute( attrName );
}
-
+
return value;
}
@@ -555,7 +577,7 @@
{
set.add( e.nextElement() );
}
-
+
if ( _seeOuterRequestAttributes )
{
for ( Enumeration e = getRequest().getAttributeNames(); e.hasMoreElements(); )
@@ -586,7 +608,7 @@
"this method is not valid unless the ScopedRequest is configured not to see outer request attributes";
if (_seeOuterRequestAttributes) {
- _log.error("the ScopedRequest is already configured to see outer request attributes");
+ LOGGER.error("the ScopedRequest is already configured to see outer request attributes");
return;
}
@@ -633,7 +655,7 @@
{
_isActiveRequest = true;
}
-
+
public final String getScopedName( String baseName )
{
return _scopedContainer.getScopedName( baseName );
Modified: beehive/trunk/netui/test/webapps/drt/src/mockportal/MockPortletTag.java
URL: http://svn.apache.org/viewvc/beehive/trunk/netui/test/webapps/drt/src/mockportal/MockPortletTag.java?view=diff&rev=476221&r1=476220&r2=476221
==============================================================================
--- beehive/trunk/netui/test/webapps/drt/src/mockportal/MockPortletTag.java (original)
+++ beehive/trunk/netui/test/webapps/drt/src/mockportal/MockPortletTag.java Fri Nov 17 09:21:29 2006
@@ -18,6 +18,23 @@
*/
package mockportal;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.Serializable;
+import java.io.StringWriter;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import javax.servlet.jsp.tagext.BodyTagSupport;
+import javax.servlet.jsp.JspException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+
import org.apache.beehive.netui.core.urls.URLRewriterService;
import org.apache.beehive.netui.pageflow.PageFlowUtils;
import org.apache.beehive.netui.pageflow.FlowControllerFactory;
@@ -28,22 +45,6 @@
import org.apache.beehive.netui.pageflow.scoping.ScopedServletUtils;
import org.apache.beehive.netui.pageflow.scoping.ScopedResponse;
-import javax.servlet.jsp.tagext.BodyTagSupport;
-import javax.servlet.jsp.JspException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import javax.servlet.http.HttpSession;
-import javax.servlet.ServletContext;
-import javax.servlet.ServletException;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.io.Serializable;
-import java.io.StringWriter;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
public class MockPortletTag extends BodyTagSupport
{
private String _portletID;
@@ -76,18 +77,14 @@
{
try
{
- //
// outerRequest and outerResponse are the "real" request and response.
- //
HttpServletRequest outerRequest = ( HttpServletRequest ) pageContext.getRequest();
HttpServletResponse outerResponse = ( HttpServletResponse ) pageContext.getResponse();
ServletContext outerServletContext = pageContext.getServletContext();
PrintWriter out = outerResponse.getWriter();
- //
// We're having each portlet keep track of its current URL in the session. 'Cause it was easy.
- //
String currentURL = ( String ) outerRequest.getSession().getAttribute( CURRENT_URL_ATTR_PREFIX + _portletID );
//
@@ -350,14 +347,14 @@
String attrName = scopedRequest.getScopedName( STORED_ATTRS_ATTR );
Map attrs = scopedRequest.getAttributeMap();
Map serializableAttrs = new HashMap();
+ List removableAttrs = scopedRequest.getNamesOfRemovableAttributes();
for ( Iterator i = attrs.entrySet().iterator(); i.hasNext(); )
{
Map.Entry entry = ( Map.Entry ) i.next();
- if ( entry.getValue() instanceof Serializable )
- {
- serializableAttrs.put( entry.getKey(), entry.getValue() );
+ if (entry.getValue() instanceof Serializable && !removableAttrs.contains(entry.getKey())) {
+ serializableAttrs.put(entry.getKey(), entry.getValue());
}
}