portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tay...@apache.org
Subject svn commit: r554827 - in /portals/jetspeed-2/trunk: commons/src/java/org/apache/jetspeed/aggregator/ commons/src/java/org/apache/jetspeed/container/ components/portal/src/java/org/apache/jetspeed/aggregator/impl/ components/portal/src/java/org/apache/j...
Date Tue, 10 Jul 2007 05:12:25 GMT
Author: taylor
Date: Mon Jul  9 22:12:23 2007
New Revision: 554827

URL: http://svn.apache.org/viewvc?view=rev&rev=554827
Log:
we discovered an issue in the parallel aggregation where when mixing sequential + parallel
thread groups on the same page, then the parallel thread groups with step on the
request parameters of the serial thread group. This patch from Woonsan Ko equally protects
all thread groups

Modified:
    portals/jetspeed-2/trunk/commons/src/java/org/apache/jetspeed/aggregator/CurrentWorkerContext.java
    portals/jetspeed-2/trunk/commons/src/java/org/apache/jetspeed/container/JetspeedContainerServlet.java
    portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/AsyncPageAggregatorImpl.java
    portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/RenderingJobImpl.java
    portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/invoker/ServletPortletInvoker.java
    portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/engine/servlet/ServletRequestImpl.java
    portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/request/JetspeedRequestContextComponent.java

Modified: portals/jetspeed-2/trunk/commons/src/java/org/apache/jetspeed/aggregator/CurrentWorkerContext.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/commons/src/java/org/apache/jetspeed/aggregator/CurrentWorkerContext.java?view=diff&rev=554827&r1=554826&r2=554827
==============================================================================
--- portals/jetspeed-2/trunk/commons/src/java/org/apache/jetspeed/aggregator/CurrentWorkerContext.java
(original)
+++ portals/jetspeed-2/trunk/commons/src/java/org/apache/jetspeed/aggregator/CurrentWorkerContext.java
Mon Jul  9 22:12:23 2007
@@ -1,92 +1,108 @@
-/*
+/*
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
  * this work for additional information regarding copyright ownership.
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jetspeed.aggregator;
-
-import java.util.Enumeration;
-import java.util.Hashtable;
-
-/**
- * Maintains a context attributes for the current Thread
- * 
- * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
- * @version $Id: $
- */
-public final class CurrentWorkerContext
-{
-    private static ThreadLocal currentWorkerContext = 
-        new ThreadLocal() {
-            protected synchronized Object initialValue() {
-                return new Hashtable();
-            }
-        };
-    
-    private CurrentWorkerContext()
-    {
-    }
-
-    /**
-     * Returns an Enumeration containing the names of the attributes available to this Thread.

-     * This method returns an empty Enumeration  if the thread has no attributes available
to it.
-     */
-    public static Enumeration getAttributeNames()
-    {
-        return ((Hashtable) currentWorkerContext.get()).keys();
-    }
-
-    /** 
-     * @return an attribute in the current Thread
-     * @param attrName Locale for this Thread 
-     */
-    public static Object getAttribute(String name)
-    {
-        return ((Hashtable) currentWorkerContext.get()).get(name);
-    }
-
-    /**
-     * Stores an attribute in this Thread.
-     * <br>
-     * @param name - a String specifying the name of the attribute
-     * @param o - the Object to be stored
-     */
-    public static void setAttribute(String name, Object o)
-    {
-        if (o != null) {
-            ((Hashtable) currentWorkerContext.get()).put(name, o);
-        } else {
-            removeAttribute(name);
-        }
-    }
-
-    /**
-     * Removes an attribute from this Thread.
-     * <br>
-     * @param name - a String specifying the name of the attribute
-     */
-    public static void removeAttribute(String name)
-    {
-        ((Hashtable) currentWorkerContext.get()).remove(name);
-    }
-
-    /**
-     * Removes all attributes from this Thread.
-     */
-    public static void removeAllAttributes()
-    {
-        ((Hashtable) currentWorkerContext.get()).clear();
-    }
-
-}
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.aggregator;
+
+import java.util.Enumeration;
+import java.util.Hashtable;
+
+/**
+ * Maintains a context attributes for the current Thread
+ * 
+ * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
+ * @version $Id: $
+ */
+public final class CurrentWorkerContext
+{
+    private static ThreadLocal currentWorkerContext = 
+        new ThreadLocal() {
+            protected synchronized Object initialValue() {
+                return new Hashtable();
+            }
+        };
+    
+    private static ThreadLocal currentWorkerContextUsed =
+        new ThreadLocal() {
+            protected synchronized Object initialValue() {
+                return new boolean [] { false };
+            }
+        };
+    
+    private CurrentWorkerContext()
+    {
+    }
+
+    /**
+     * Returns an Enumeration containing the names of the attributes available to this Thread.

+     * This method returns an empty Enumeration  if the thread has no attributes available
to it.
+     */
+    public static Enumeration getAttributeNames()
+    {
+        return ((Hashtable) currentWorkerContext.get()).keys();
+    }
+
+    /** 
+     * @return an attribute in the current Thread
+     * @param attrName Locale for this Thread 
+     */
+    public static Object getAttribute(String name)
+    {
+        return ((Hashtable) currentWorkerContext.get()).get(name);
+    }
+
+    /**
+     * Stores an attribute in this Thread.
+     * <br>
+     * @param name - a String specifying the name of the attribute
+     * @param o - the Object to be stored
+     */
+    public static void setAttribute(String name, Object o)
+    {
+        if (o != null) {
+            ((Hashtable) currentWorkerContext.get()).put(name, o);
+        } else {
+            removeAttribute(name);
+        }
+    }
+
+    /**
+     * Removes an attribute from this Thread.
+     * <br>
+     * @param name - a String specifying the name of the attribute
+     */
+    public static void removeAttribute(String name)
+    {
+        ((Hashtable) currentWorkerContext.get()).remove(name);
+    }
+
+    /**
+     * Removes all attributes from this Thread.
+     */
+    public static void removeAllAttributes()
+    {
+        ((Hashtable) currentWorkerContext.get()).clear();
+    }
+    
+    public static void setCurrentWorkerContextUsed(boolean used)
+    {
+        ((boolean []) currentWorkerContextUsed.get())[0] = used;
+    }
+
+    public static boolean getCurrentWorkerContextUsed()
+    {
+        return ((boolean []) currentWorkerContextUsed.get())[0];
+    }
+}

Modified: portals/jetspeed-2/trunk/commons/src/java/org/apache/jetspeed/container/JetspeedContainerServlet.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/commons/src/java/org/apache/jetspeed/container/JetspeedContainerServlet.java?view=diff&rev=554827&r1=554826&r2=554827
==============================================================================
--- portals/jetspeed-2/trunk/commons/src/java/org/apache/jetspeed/container/JetspeedContainerServlet.java
(original)
+++ portals/jetspeed-2/trunk/commons/src/java/org/apache/jetspeed/container/JetspeedContainerServlet.java
Mon Jul  9 22:12:23 2007
@@ -210,7 +210,7 @@
         
         try
         {
-            isParallelMode = (Thread.currentThread() instanceof Worker);
+            isParallelMode = (Thread.currentThread() instanceof Worker || CurrentWorkerContext.getCurrentWorkerContextUsed());
 
             if (isParallelMode)
             {

Modified: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/AsyncPageAggregatorImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/AsyncPageAggregatorImpl.java?view=diff&rev=554827&r1=554826&r2=554827
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/AsyncPageAggregatorImpl.java
(original)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/AsyncPageAggregatorImpl.java
Mon Jul  9 22:12:23 2007
@@ -1,249 +1,253 @@
-/*
+/*
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
  * this work for additional information regarding copyright ownership.
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jetspeed.aggregator.impl;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.jetspeed.PortalReservedParameters;
-import org.apache.jetspeed.aggregator.FailedToRenderFragmentException;
-import org.apache.jetspeed.aggregator.PageAggregator;
-import org.apache.jetspeed.aggregator.PortletContent;
-import org.apache.jetspeed.aggregator.PortletRenderer;
-import org.apache.jetspeed.aggregator.RenderingJob;
-import org.apache.jetspeed.container.state.NavigationalState;
-import org.apache.jetspeed.exception.JetspeedException;
-import org.apache.jetspeed.om.page.ContentFragment;
-import org.apache.jetspeed.om.page.ContentPage;
-import org.apache.jetspeed.request.RequestContext;
-import org.apache.pluto.om.window.PortletWindow;
-
-/**
- * Asynchronous Page Aggregator builds the content required to render a 
- * page of portlets by rendering the portlets in parallel. Each portlet is
- * rendered on its own thread. A work manager handles the thread pooling
- * and synchronization of worker threads.
- * 
- * @author <a href="mailto:taylor@apache.org">David Sean Taylor </a>
- * @author <a>Woonsan Ko</a>
- * @version $Id: $
- */
-public class AsyncPageAggregatorImpl implements PageAggregator
-{
-    protected final static Log log = LogFactory.getLog(AsyncPageAggregatorImpl.class);
-
-    protected PortletRenderer renderer;
-
-    protected List fallBackContentPathes;
-
-    public AsyncPageAggregatorImpl(PortletRenderer renderer)
-    {
-        this.renderer = renderer;
-    }
-
-    /**
-     * Builds the portlet set defined in the context into a portlet tree.
-     * 
-     * @return Unique Portlet Entity ID
-     */
-    public void build( RequestContext context ) throws JetspeedException, IOException
-    {
-        ContentPage page = context.getPage();
-        if (null == page)
-        {
-            throw new JetspeedException("Failed to find PSML Pin ContentPageAggregator.build");
-        }
-        ContentFragment root = page.getRootContentFragment();
-        if (root == null)
-        {
-            throw new JetspeedException("No root ContentFragment found in ContentPage");
-        }
-        // handle maximized state
-        NavigationalState nav = context.getPortalURL().getNavigationalState();
-        PortletWindow window = nav.getMaximizedWindow();
-        if (null != window)
-        {
-            renderMaximizedWindow(context, page, root, window);
-        }
-        else
-        {
-            aggregateAndRender(root, context, page, true, null, null, null);
-        }        
-        //dispatcher.include(root);
-        context.getResponse().getWriter().write(root.getRenderedContent());
-        if (null != window)
-        {
-            context.getRequest().removeAttribute(PortalReservedParameters.MAXIMIZED_FRAGMENT_ATTRIBUTE);
-            context.getRequest().removeAttribute(PortalReservedParameters.MAXIMIZED_LAYOUT_ATTRIBUTE);
-        }
-    }
-
-    /**
-     * <p>
-     * renderMaximizedWindow
-     * </p>
-     * 
-     * @param context
-     * @param page
-     * @param layoutContentFragment
-     * @param defaultPortletDecorator
-     * @param dispatcher
-     * @param window
-     * @throws FailedToRenderContentFragmentException
-     */
-    protected void renderMaximizedWindow( RequestContext context, ContentPage page, ContentFragment
layoutContentFragment,
-            PortletWindow window ) throws FailedToRenderFragmentException
-    {
-        ContentFragment maxedContentFragment = page.getContentFragmentById(window.getId().toString());
-        if (maxedContentFragment != null)
-        {
-            context.getRequest().setAttribute(PortalReservedParameters.MAXIMIZED_FRAGMENT_ATTRIBUTE,
maxedContentFragment);
-            context.getRequest().setAttribute(PortalReservedParameters.FRAGMENT_ATTRIBUTE,
maxedContentFragment);
-            context.getRequest().setAttribute(PortalReservedParameters.MAXIMIZED_LAYOUT_ATTRIBUTE,
page.getRootContentFragment());
-            try
-            {
-                renderer.renderNow(maxedContentFragment, context);
-                renderer.renderNow(layoutContentFragment, context);                     
        
-            }
-            catch (Exception e)
-            {
-                log.error(e.getMessage(), e);
-                maxedContentFragment.overrideRenderedContent("Sorry, but we were unable access
the requested portlet.  Send the following message to your portal admin:  "+  e.getMessage());
-            }
-        }
-    }
-
-    protected void aggregateAndRender(ContentFragment f, RequestContext context, ContentPage
page, boolean isRoot,
-                                      List sequentialJobs, List parallelJobs, List layoutFragments)
-            throws FailedToRenderFragmentException
-    {
-        // First Pass, kick off async render threads for all portlets on page 
-        // Store portlet rendering jobs in the list to wait later.
-        // Store layout fragment in the list to render later.
-        if (sequentialJobs == null) 
-        {
-            sequentialJobs = new ArrayList();
-        }
-        if (parallelJobs == null) 
-        {
-            parallelJobs = new ArrayList();
-        }        
-        if (layoutFragments == null)
-        {
-            layoutFragments = new ArrayList();
-        }
-
-        if (f.getContentFragments() != null && f.getContentFragments().size() >
0)
-        {
-            Iterator children = f.getContentFragments().iterator();
-            while (children.hasNext())
-            {
-                ContentFragment child = (ContentFragment) children.next();
-                if (!"hidden".equals(f.getState()))
-                {
-                    if (child.getType().equals(ContentFragment.PORTLET))
-                    {
-                        // create and store the portlet rendering job into the jobs lists.
-                        RenderingJob job = renderer.createRenderingJob(child, context);
-
-                        // The returned job can be null for some reason, such as invalid
portlet entity.
-                        if (job != null) 
-                        {
-                            if (job.getTimeout() > 0)
-                                parallelJobs.add(job);
-                            else
-                                sequentialJobs.add(job);
-                        }
-                    }
-                    else
-                    {
-                        // walk thru layout 
-                        // and store the layout rendering job into the layout jobs list.
-                        aggregateAndRender(child, context, page, false, sequentialJobs, parallelJobs,
layoutFragments);
-                        layoutFragments.add(child);
-                    }
-                }
-            }
-        }
-
-        // If the fragment is not root, skip the following.
-        if (!isRoot)
-            return;
-
-        // kick off the parallel rendering jobs
-        Iterator iter = parallelJobs.iterator();
-        while (iter.hasNext())
-        {
-            RenderingJob job = (RenderingJob) iter.next();
-            renderer.processRenderingJob(job);
-        }
-
-        // kick off the sequential rendering jobs
-        iter = sequentialJobs.iterator();
-        while (iter.hasNext())
-        {
-            RenderingJob job = (RenderingJob) iter.next();
-            renderer.processRenderingJob(job);
-        }
-
-        // synchronize on completion of all jobs
-        iter = parallelJobs.iterator();
-        try 
-        {
-            while (iter.hasNext()) 
-            {
-                RenderingJob job = (RenderingJob) iter.next();
-                PortletContent portletContent = job.getPortletContent();
-                
-                if (!portletContent.isComplete()) 
-                {
-                    synchronized (portletContent) 
-                    {
-                        portletContent.wait();
-                    }
-                }
-            }
-        }
-        catch (Exception e)
-        {
-            log.error("Exception during synchronizing all portlet rendering jobs.", e);
-        }
-        
-        // render layout fragments.
-        iter = layoutFragments.iterator();
-        while (iter.hasNext()) 
-        {
-            ContentFragment child = (ContentFragment) iter.next();
-            renderer.renderNow(child, context);
-        }
-        
-        // Start the actual rendering process
-        String defaultPortletDecorator = page.getEffectiveDefaultDecorator(ContentFragment.PORTLET);
-        if (log.isDebugEnabled())
-        {
-            log.debug("Rendering portlet fragment: [[name, " + f.getName() + "], [id, " +
f.getId() + "]]");
-        }        
-        
-        renderer.renderNow(f, context);
-    }
-    
-
-}
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.aggregator.impl;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.jetspeed.PortalReservedParameters;
+import org.apache.jetspeed.aggregator.FailedToRenderFragmentException;
+import org.apache.jetspeed.aggregator.PageAggregator;
+import org.apache.jetspeed.aggregator.PortletContent;
+import org.apache.jetspeed.aggregator.PortletRenderer;
+import org.apache.jetspeed.aggregator.RenderingJob;
+import org.apache.jetspeed.aggregator.CurrentWorkerContext;
+import org.apache.jetspeed.container.state.NavigationalState;
+import org.apache.jetspeed.exception.JetspeedException;
+import org.apache.jetspeed.om.page.ContentFragment;
+import org.apache.jetspeed.om.page.ContentPage;
+import org.apache.jetspeed.request.RequestContext;
+import org.apache.pluto.om.window.PortletWindow;
+
+/**
+ * Asynchronous Page Aggregator builds the content required to render a 
+ * page of portlets by rendering the portlets in parallel. Each portlet is
+ * rendered on its own thread. A work manager handles the thread pooling
+ * and synchronization of worker threads.
+ * 
+ * @author <a href="mailto:taylor@apache.org">David Sean Taylor </a>
+ * @author <a>Woonsan Ko</a>
+ * @version $Id: $
+ */
+public class AsyncPageAggregatorImpl implements PageAggregator
+{
+    protected final static Log log = LogFactory.getLog(AsyncPageAggregatorImpl.class);
+
+    protected PortletRenderer renderer;
+
+    protected List fallBackContentPathes;
+
+    public AsyncPageAggregatorImpl(PortletRenderer renderer)
+    {
+        this.renderer = renderer;
+    }
+
+    /**
+     * Builds the portlet set defined in the context into a portlet tree.
+     * 
+     * @return Unique Portlet Entity ID
+     */
+    public void build( RequestContext context ) throws JetspeedException, IOException
+    {
+        ContentPage page = context.getPage();
+        if (null == page)
+        {
+            throw new JetspeedException("Failed to find PSML Pin ContentPageAggregator.build");
+        }
+        ContentFragment root = page.getRootContentFragment();
+        if (root == null)
+        {
+            throw new JetspeedException("No root ContentFragment found in ContentPage");
+        }
+        // handle maximized state
+        NavigationalState nav = context.getPortalURL().getNavigationalState();
+        PortletWindow window = nav.getMaximizedWindow();
+        if (null != window)
+        {
+            renderMaximizedWindow(context, page, root, window);
+        }
+        else
+        {
+            aggregateAndRender(root, context, page, true, null, null, null);
+        }        
+        //dispatcher.include(root);
+        context.getResponse().getWriter().write(root.getRenderedContent());
+        if (null != window)
+        {
+            context.getRequest().removeAttribute(PortalReservedParameters.MAXIMIZED_FRAGMENT_ATTRIBUTE);
+            context.getRequest().removeAttribute(PortalReservedParameters.MAXIMIZED_LAYOUT_ATTRIBUTE);
+        }
+    }
+
+    /**
+     * <p>
+     * renderMaximizedWindow
+     * </p>
+     * 
+     * @param context
+     * @param page
+     * @param layoutContentFragment
+     * @param defaultPortletDecorator
+     * @param dispatcher
+     * @param window
+     * @throws FailedToRenderContentFragmentException
+     */
+    protected void renderMaximizedWindow( RequestContext context, ContentPage page, ContentFragment
layoutContentFragment,
+            PortletWindow window ) throws FailedToRenderFragmentException
+    {
+        ContentFragment maxedContentFragment = page.getContentFragmentById(window.getId().toString());
+        if (maxedContentFragment != null)
+        {
+            context.getRequest().setAttribute(PortalReservedParameters.MAXIMIZED_FRAGMENT_ATTRIBUTE,
maxedContentFragment);
+            context.getRequest().setAttribute(PortalReservedParameters.FRAGMENT_ATTRIBUTE,
maxedContentFragment);
+            context.getRequest().setAttribute(PortalReservedParameters.MAXIMIZED_LAYOUT_ATTRIBUTE,
page.getRootContentFragment());
+            try
+            {
+                renderer.renderNow(maxedContentFragment, context);
+                renderer.renderNow(layoutContentFragment, context);                     
        
+            }
+            catch (Exception e)
+            {
+                log.error(e.getMessage(), e);
+                maxedContentFragment.overrideRenderedContent("Sorry, but we were unable access
the requested portlet.  Send the following message to your portal admin:  "+  e.getMessage());
+            }
+        }
+    }
+
+    protected void aggregateAndRender(ContentFragment f, RequestContext context, ContentPage
page, boolean isRoot,
+                                      List sequentialJobs, List parallelJobs, List layoutFragments)
+            throws FailedToRenderFragmentException
+    {
+        // First Pass, kick off async render threads for all portlets on page 
+        // Store portlet rendering jobs in the list to wait later.
+        // Store layout fragment in the list to render later.
+        if (sequentialJobs == null) 
+        {
+            sequentialJobs = new ArrayList();
+        }
+        if (parallelJobs == null) 
+        {
+            parallelJobs = new ArrayList();
+        }        
+        if (layoutFragments == null)
+        {
+            layoutFragments = new ArrayList();
+        }
+
+        if (f.getContentFragments() != null && f.getContentFragments().size() >
0)
+        {
+            Iterator children = f.getContentFragments().iterator();
+            while (children.hasNext())
+            {
+                ContentFragment child = (ContentFragment) children.next();
+                if (!"hidden".equals(f.getState()))
+                {
+                    if (child.getType().equals(ContentFragment.PORTLET))
+                    {
+                        // create and store the portlet rendering job into the jobs lists.
+                        RenderingJob job = renderer.createRenderingJob(child, context);
+
+                        // The returned job can be null for some reason, such as invalid
portlet entity.
+                        if (job != null) 
+                        {
+                            if (job.getTimeout() > 0)
+                                parallelJobs.add(job);
+                            else
+                                sequentialJobs.add(job);
+                        }
+                    }
+                    else
+                    {
+                        // walk thru layout 
+                        // and store the layout rendering job into the layout jobs list.
+                        aggregateAndRender(child, context, page, false, sequentialJobs, parallelJobs,
layoutFragments);
+                        layoutFragments.add(child);
+                    }
+                }
+            }
+        }
+
+        // If the fragment is not root, skip the following.
+        if (!isRoot)
+            return;
+        
+        
+        CurrentWorkerContext.setCurrentWorkerContextUsed(parallelJobs.size() > 0 &&
sequentialJobs.size() > 0);
+
+        // kick off the parallel rendering jobs
+        Iterator iter = parallelJobs.iterator();
+        while (iter.hasNext())
+        {
+            RenderingJob job = (RenderingJob) iter.next();
+            renderer.processRenderingJob(job);
+        }
+
+        // kick off the sequential rendering jobs
+        iter = sequentialJobs.iterator();
+        while (iter.hasNext())
+        {
+            RenderingJob job = (RenderingJob) iter.next();
+            renderer.processRenderingJob(job);
+        }
+
+        // synchronize on completion of all jobs
+        iter = parallelJobs.iterator();
+        try 
+        {
+            while (iter.hasNext()) 
+            {
+                RenderingJob job = (RenderingJob) iter.next();
+                PortletContent portletContent = job.getPortletContent();
+                
+                if (!portletContent.isComplete()) 
+                {
+                    synchronized (portletContent) 
+                    {
+                        portletContent.wait();
+                    }
+                }
+            }
+        }
+        catch (Exception e)
+        {
+            log.error("Exception during synchronizing all portlet rendering jobs.", e);
+        }
+        
+        // render layout fragments.
+        iter = layoutFragments.iterator();
+        while (iter.hasNext()) 
+        {
+            ContentFragment child = (ContentFragment) iter.next();
+            renderer.renderNow(child, context);
+        }
+        
+        // Start the actual rendering process
+        String defaultPortletDecorator = page.getEffectiveDefaultDecorator(ContentFragment.PORTLET);
+        if (log.isDebugEnabled())
+        {
+            log.debug("Rendering portlet fragment: [[name, " + f.getName() + "], [id, " +
f.getId() + "]]");
+        }        
+        
+        renderer.renderNow(f, context);
+    }
+    
+
+}

Modified: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/RenderingJobImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/RenderingJobImpl.java?view=diff&rev=554827&r1=554826&r2=554827
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/RenderingJobImpl.java
(original)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/RenderingJobImpl.java
Mon Jul  9 22:12:23 2007
@@ -196,7 +196,7 @@
     {
         long start = System.currentTimeMillis();
         boolean isParallelMode = false;
-        PortletWindow curWindow = null;
+        PortletWindow curWindow = this.window;
         try
         {
             log.debug("Rendering OID "+this.window.getId()+" "+ this.request +" "+this.response);
@@ -204,7 +204,7 @@
             // if the current thread is worker, then store attribues in that.
             if (this.workerAttributes != null)
             {
-                isParallelMode = (Thread.currentThread() instanceof Worker);            
   
+                isParallelMode = (Thread.currentThread() instanceof Worker || CurrentWorkerContext.getCurrentWorkerContextUsed());
               
                 if (isParallelMode)
                 {
                     Iterator itAttrNames = this.workerAttributes.keySet().iterator();
@@ -247,11 +247,11 @@
             if (t instanceof UnavailableException)
             {
                 // no need to dump a full stack trace to the log
-                log.error("Error rendering portlet OID " + this.window.getId() + ": " + t.toString());
+                log.error("Error rendering portlet OID " + curWindow.getId() + ": " + t.toString());
             }
             else
             {
-                log.error("Error rendering portlet OID " + this.window.getId(), t);
+                log.error("Error rendering portlet OID " + curWindow.getId(), t);
             }
             fragment.overrideRenderedContent(t.getMessage());
         }
@@ -282,12 +282,12 @@
                 if (exceededTimeout)
                 {
                     // took too long to render
-                    log.info("Portlet Exceeded timeout: " + window.getPortletEntity().getPortletDefinition().getName()
+ " for window " + window.getId());
-                    portletTracking.incrementRenderTimeoutCount(window);
+                    log.info("Portlet Exceeded timeout: " + curWindow.getPortletEntity().getPortletDefinition().getName()
+ " for window " + curWindow.getId());
+                    portletTracking.incrementRenderTimeoutCount(curWindow);
                 }
                 else
                 {
-                    portletTracking.success(window);
+                    portletTracking.success(curWindow);
                 }
             }
         }

Modified: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/invoker/ServletPortletInvoker.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/invoker/ServletPortletInvoker.java?view=diff&rev=554827&r1=554826&r2=554827
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/invoker/ServletPortletInvoker.java
(original)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/invoker/ServletPortletInvoker.java
Mon Jul  9 22:12:23 2007
@@ -172,13 +172,14 @@
 
         // In case of parallel mode, get portlet definition object from the worker thread
context.
         // Otherwise, refer the member variable.
-        boolean isParallelMode = (Thread.currentThread() instanceof Worker);
+        boolean isParallelMode = (Thread.currentThread() instanceof Worker || CurrentWorkerContext.getCurrentWorkerContextUsed());
 
         if (isParallelMode)
         {
             portletDefinition = (PortletDefinition) CurrentWorkerContext.getAttribute(PortalReservedParameters.PORTLET_DEFINITION_ATTRIBUTE);
         }
-        else
+        
+        if (portletDefinition == null)
         {
             portletDefinition = this.portletDefinition;
         }

Modified: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/engine/servlet/ServletRequestImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/engine/servlet/ServletRequestImpl.java?view=diff&rev=554827&r1=554826&r2=554827
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/engine/servlet/ServletRequestImpl.java
(original)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/engine/servlet/ServletRequestImpl.java
Mon Jul  9 22:12:23 2007
@@ -411,7 +411,7 @@
         // In parallel mode, adjust attributes by the values of the current thread
         Thread ct = Thread.currentThread();
 
-        if (ct instanceof Worker)
+        if (ct instanceof Worker || CurrentWorkerContext.getCurrentWorkerContextUsed())
         {
             // If cached attributes map is null, it should be re-created.
             
@@ -457,7 +457,7 @@
 
         Thread ct = Thread.currentThread();
 
-        if (ct instanceof Worker)
+        if (ct instanceof Worker || CurrentWorkerContext.getCurrentWorkerContextUsed())
         {            
             value = CurrentWorkerContext.getAttribute(name);
 
@@ -628,8 +628,9 @@
         // In parallel mode, put attribute into worker.
 
         Thread ct = Thread.currentThread();
+        boolean currentWorkerContextUsed = CurrentWorkerContext.getCurrentWorkerContextUsed();
 
-        if (ct instanceof Worker) 
+        if (ct instanceof Worker || currentWorkerContextUsed) 
         {
             // when it is parallel rendering, the cached request attributes should be re-created
later by setting it to null.
             cachedAttributes = null;
@@ -643,7 +644,7 @@
                 CurrentWorkerContext.setAttribute(name, value);
             }
 
-            if (name.startsWith("org.apache.jetspeed"))
+            if (currentWorkerContextUsed || name.startsWith("org.apache.jetspeed"))
             {
                 setAttributeInternal(name, value);
             }
@@ -694,7 +695,7 @@
 
         Thread ct = Thread.currentThread();
 
-        if (ct instanceof Worker) 
+        if (ct instanceof Worker || CurrentWorkerContext.getCurrentWorkerContextUsed()) 
         {
             // when it is parallel rendering, the cached request attributes should be re-created
later by setting it to null.
             cachedAttributes = null;

Modified: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/request/JetspeedRequestContextComponent.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/request/JetspeedRequestContextComponent.java?view=diff&rev=554827&r1=554826&r2=554827
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/request/JetspeedRequestContextComponent.java
(original)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/request/JetspeedRequestContextComponent.java
Mon Jul  9 22:12:23 2007
@@ -133,7 +133,7 @@
         RequestContext rc = null;
 
         Thread ct = Thread.currentThread();
-        if (ct instanceof Worker)
+        if (ct instanceof Worker || CurrentWorkerContext.getCurrentWorkerContextUsed())
         {
             rc = (RequestContext) CurrentWorkerContext.getAttribute(PortalReservedParameters.REQUEST_CONTEXT_ATTRIBUTE);
         }



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


Mime
View raw message