• R/O
  • SSH
  • HTTPS

pal: Commit


Commit MetaInfo

Revision1618 (tree)
Zeit2008-12-20 22:39:54
Autorshinsuke

Log Message

fixed mt issue.

Ändern Zusammenfassung

Diff

--- pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/portal/src/java/org/apache/jetspeed/aggregator/impl/RenderingJobImpl.java (revision 1617)
+++ pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/portal/src/java/org/apache/jetspeed/aggregator/impl/RenderingJobImpl.java (revision 1618)
@@ -20,6 +20,7 @@
2020 import java.util.Arrays;
2121 import java.util.Collection;
2222 import java.util.Collections;
23+import java.util.Enumeration;
2324 import java.util.HashMap;
2425 import java.util.Iterator;
2526 import java.util.Map;
@@ -100,6 +101,8 @@
100101
101102 protected long timeout;
102103
104+ protected Map<String, Object> requestAttributes;
105+
103106 public RenderingJobImpl(PortletContainer container,
104107 PortletRenderer renderer, PortletDefinition portletDefinition,
105108 PortletContent portletContent, ContentFragment fragment,
@@ -124,6 +127,17 @@
124127 .setFragment(fragment);
125128 this.expirationCache = expirationCache;
126129 this.contentIsCached = contentIsCached;
130+
131+ this.requestAttributes = new HashMap<String, Object>();
132+ ServletRequest servletRequest = ((HttpServletRequestWrapper) ((HttpServletRequestWrapper) this.request)
133+ .getRequest()).getRequest();
134+ Enumeration attrNames = servletRequest.getAttributeNames();
135+ while (attrNames.hasMoreElements())
136+ {
137+ String key = (String) attrNames.nextElement();
138+ requestAttributes.put(key, servletRequest.getAttribute(key));
139+ }
140+
127141 }
128142
129143 public RenderingJobImpl(PortletContainer container,
@@ -281,25 +295,29 @@
281295
282296 if (isParallelMode)
283297 {
284- ServletRequest servletRequest = ((HttpServletRequestWrapper) ((HttpServletRequestWrapper) this.request)
285- .getRequest()).getRequest();
286-
287- synchronized (servletRequest)
298+ for (Map.Entry<String, Object> entry : requestAttributes
299+ .entrySet())
288300 {
289- this.request.setAttribute(
290- PortalReservedParameters.FRAGMENT_ATTRIBUTE,
291- fragment);
292- this.request.setAttribute(
293- PortalReservedParameters.PAGE_ATTRIBUTE,
294- requestContext.getPage());
295- this.request.setAttribute(
296- PortalReservedParameters.REQUEST_CONTEXT_ATTRIBUTE,
297- requestContext);
298- this.request.setAttribute(
299- PortalReservedParameters.REQUEST_CONTEXT_OBJECTS,
300- requestContext.getObjects());
301- // this.request.setAttribute(PortalReservedParameters.CONTENT_DISPATCHER_ATTRIBUTE,dispatcher);
301+ CurrentWorkerContext.setAttribute(entry.getKey(), entry
302+ .getValue());
302303 }
304+
305+ CurrentWorkerContext.setAttribute(
306+ PortalReservedParameters.UPDATED_ATTRIBUTES,
307+ new HashMap<String, Object>());
308+
309+ this.request.setAttribute(
310+ PortalReservedParameters.FRAGMENT_ATTRIBUTE, fragment);
311+ this.request.setAttribute(
312+ PortalReservedParameters.PAGE_ATTRIBUTE, requestContext
313+ .getPage());
314+ this.request.setAttribute(
315+ PortalReservedParameters.REQUEST_CONTEXT_ATTRIBUTE,
316+ requestContext);
317+ this.request.setAttribute(
318+ PortalReservedParameters.REQUEST_CONTEXT_OBJECTS,
319+ requestContext.getObjects());
320+ // this.request.setAttribute(PortalReservedParameters.CONTENT_DISPATCHER_ATTRIBUTE,dispatcher);
303321 }
304322 else
305323 {
@@ -319,6 +337,36 @@
319337
320338 container.renderPortlet(this.window, this.request, this.response);
321339 this.response.flushBuffer();
340+ if (isParallelMode)
341+ {
342+ // flush attributes
343+ ServletRequest servletRequest = ((HttpServletRequestWrapper) ((HttpServletRequestWrapper) this.request)
344+ .getRequest()).getRequest();
345+
346+ synchronized (servletRequest)
347+ {
348+ Map<String, Object> attrs = (Map<String, Object>) this.request
349+ .getAttribute(PortalReservedParameters.UPDATED_ATTRIBUTES);
350+ if (attrs != null)
351+ {
352+ for (Map.Entry<String, Object> entry : attrs.entrySet())
353+ {
354+ if (PortalReservedParameters.NULL_ATTRIBUTE
355+ .equals(entry.getValue()))
356+ {
357+ // remove
358+ servletRequest.removeAttribute(entry.getKey());
359+ }
360+ else
361+ {
362+ // add
363+ servletRequest.setAttribute(entry.getKey(),
364+ entry.getValue());
365+ }
366+ }
367+ }
368+ }
369+ }
322370 }
323371 catch (Throwable t)
324372 {
--- pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/portal/src/java/org/apache/jetspeed/engine/servlet/ServletRequestImpl.java (revision 1617)
+++ pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/portal/src/java/org/apache/jetspeed/engine/servlet/ServletRequestImpl.java (revision 1618)
@@ -464,8 +464,6 @@
464464 */
465465 public Enumeration getAttributeNames()
466466 {
467- Enumeration attrNames = super.getAttributeNames();
468-
469467 // In parallel mode, adjust attributes by the values of the current
470468 // thread
471469
@@ -477,20 +475,8 @@
477475 {
478476 HashMap adjustedAttrMap = new HashMap();
479477
480- // first, add all attributes of original request.
481-
482- while (attrNames.hasMoreElements())
483- {
484- String key = (String) attrNames.nextElement();
485- adjustedAttrMap.put(key, super.getAttribute(key));
486- }
487-
488- // second, add or override all attributes by the current worker
489- // context.
490-
491478 Enumeration cwAttrNames = CurrentWorkerContext
492479 .getAttributeNames();
493-
494480 while (cwAttrNames.hasMoreElements())
495481 {
496482 String key = (String) cwAttrNames.nextElement();
@@ -501,10 +487,12 @@
501487 cachedAttributes = Collections.unmodifiableMap(adjustedAttrMap);
502488 }
503489
504- attrNames = Collections.enumeration(cachedAttributes.keySet());
490+ return Collections.enumeration(cachedAttributes.keySet());
505491 }
506-
507- return attrNames;
492+ else
493+ {
494+ return super.getAttributeNames();
495+ }
508496 }
509497
510498 /**
@@ -715,9 +703,33 @@
715703 CurrentWorkerContext.setAttribute(name, value);
716704 }
717705
718- if (name.startsWith("org.apache.jetspeed"))
706+ if (name
707+ .startsWith(PortalReservedParameters.ORG_APACHE_JETSPEED_PREFIX))
719708 {
720- setAttributeInternal(name, value);
709+ Map<String, Object> updatedAttributes = (Map<String, Object>) CurrentWorkerContext
710+ .getAttribute(PortalReservedParameters.UPDATED_ATTRIBUTES);
711+ String encodedKey = nameSpaceMapper.encode(portletWindow
712+ .getId(), name);
713+
714+ // title
715+ if (name
716+ .startsWith(PortalReservedParameters.OVERRIDE_PORTLET_TITLE_ATTR))
717+ {
718+ encodedKey = name;
719+ }
720+
721+ if (value == null)
722+ {
723+ // remove
724+ updatedAttributes.put(encodedKey,
725+ PortalReservedParameters.NULL_ATTRIBUTE);
726+ }
727+ else
728+ {
729+ // add
730+ updatedAttributes.put(encodedKey, value);
731+ }
732+
721733 }
722734 }
723735 else
@@ -731,16 +743,17 @@
731743 {
732744 // This allows us to make jetpseed objects avaiable to portlets
733745 // This makes the portlet non-portable but is a must admin portlets
734- if (name.startsWith("org.apache.jetspeed"))
746+ if (name
747+ .startsWith(PortalReservedParameters.ORG_APACHE_JETSPEED_PREFIX))
735748 {
749+ String encodedKey = nameSpaceMapper.encode(portletWindow.getId(),
750+ name);
736751 if (value == null)
737752 {
738- this.removeAttribute(name);
753+ this.removeAttribute(encodedKey);
739754 }
740755 else
741756 {
742- String encodedKey = nameSpaceMapper.encode(portletWindow
743- .getId(), name);
744757 this._getHttpServletRequest().setAttribute(encodedKey, value);
745758 }
746759 }
@@ -770,13 +783,32 @@
770783
771784 CurrentWorkerContext.removeAttribute(name);
772785
773- if (name.startsWith("org.apache.jetspeed"))
786+ if (name
787+ .startsWith(PortalReservedParameters.ORG_APACHE_JETSPEED_PREFIX))
774788 {
775- super.removeAttribute(name);
789+ Map<String, Object> updatedAttributes = (Map<String, Object>) CurrentWorkerContext
790+ .getAttribute(PortalReservedParameters.UPDATED_ATTRIBUTES);
791+ String encodedKey = nameSpaceMapper.encode(portletWindow
792+ .getId(), name);
793+ // title
794+ if (name
795+ .startsWith(PortalReservedParameters.OVERRIDE_PORTLET_TITLE_ATTR))
796+ {
797+ encodedKey = name;
798+ }
799+ updatedAttributes.put(encodedKey,
800+ PortalReservedParameters.NULL_ATTRIBUTE);
776801 }
777802 }
778803 else
779804 {
805+ if (name
806+ .startsWith(PortalReservedParameters.ORG_APACHE_JETSPEED_PREFIX))
807+ {
808+ String encodedKey = nameSpaceMapper.encode(portletWindow
809+ .getId(), name);
810+ super.removeAttribute(encodedKey);
811+ }
780812 // remove attribute from request.
781813 super.removeAttribute(name);
782814 }
@@ -953,4 +985,5 @@
953985 super.setCharacterEncoding(arg0);
954986 }
955987 }
988+
956989 }
--- pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/jetspeed-api/src/java/org/apache/jetspeed/PortalReservedParameters.java (revision 1617)
+++ pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/jetspeed-api/src/java/org/apache/jetspeed/PortalReservedParameters.java (revision 1618)
@@ -206,4 +206,10 @@
206206 * directly, similar as an ActionURL but as a direct Portlet Render request.
207207 */
208208 public static final String PORTLET_RESOURCE_URL_REQUEST_PARAMETER = "org.apache.jetspeed.portlet.resource.url";
209+
210+ public static final String UPDATED_ATTRIBUTES = "org.apache.jetspeed.UpdatedAttributes";
211+
212+ public static final String NULL_ATTRIBUTE = "org.apache.jetspeed.NULL";
213+
214+ public static final String ORG_APACHE_JETSPEED_PREFIX = "org.apache.jetspeed";
209215 }
Show on old repository browser