portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tay...@apache.org
Subject svn commit: r279462 - /portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/
Date Wed, 07 Sep 2005 23:44:10 GMT
Author: taylor
Date: Wed Sep  7 16:44:03 2005
New Revision: 279462

URL: http://svn.apache.org/viewcvs?rev=279462&view=rev
Log:
http://issues.apache.org/jira/browse/JS2-360 - Springize Aggregation

refactored spring assembly of aggregation components
made work manager a component, with configurable workers parameters
made the header resource factory a component
dependency injected new components associations into render and aggregator
abstracted out content manager coupling from aggregator via an adapter (JS2-24)

started on a new 'experimental' aggregator: AsyncPageAggregatorImpl
This aggregator is under development and will be changing over the next week quite a bit
It is NOT hooked into the pipeline




Added:
    portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/RenderingJobImpl.java
      - copied, changed from r264709, portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/RenderingJob.java
    portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/WorkerImpl.java
      - copied, changed from r264709, portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/Worker.java
    portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/WorkerMonitorImpl.java
      - copied, changed from r264709, portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/WorkerMonitor.java
Removed:
    portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/RenderingJob.java
    portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/Worker.java
    portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/WorkerMonitor.java
Modified:
    portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/PageAggregatorImpl.java
    portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/PortletRendererImpl.java

Modified: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/PageAggregatorImpl.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/PageAggregatorImpl.java?rev=279462&r1=279461&r2=279462&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/PageAggregatorImpl.java
(original)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/PageAggregatorImpl.java
Wed Sep  7 16:44:03 2005
@@ -16,23 +16,18 @@
 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.Jetspeed;
 import org.apache.jetspeed.PortalReservedParameters;
 import org.apache.jetspeed.aggregator.ContentDispatcher;
+import org.apache.jetspeed.aggregator.ContentServerAdapter;
 import org.apache.jetspeed.aggregator.FailedToRenderFragmentException;
 import org.apache.jetspeed.aggregator.PageAggregator;
 import org.apache.jetspeed.aggregator.PortletRenderer;
 import org.apache.jetspeed.container.state.NavigationalState;
-import org.apache.jetspeed.contentserver.ContentFilter;
 import org.apache.jetspeed.exception.JetspeedException;
-import org.apache.jetspeed.headerresource.HeaderResource;
-import org.apache.jetspeed.headerresource.HeaderResourceFactory;
 import org.apache.jetspeed.om.page.ContentFragment;
 import org.apache.jetspeed.om.page.ContentPage;
 import org.apache.jetspeed.request.RequestContext;
@@ -54,19 +49,19 @@
 
     private int strategy = STRATEGY_SEQUENTIAL;
     private PortletRenderer renderer;
+    private ContentServerAdapter contentServer;
 
-    private List fallBackContentPathes;
 
-    public PageAggregatorImpl( PortletRenderer renderer, int strategy, List fallBackContentPathes
)
+    public PageAggregatorImpl( PortletRenderer renderer, int strategy, ContentServerAdapter
contentServer)
     {
         this.renderer = renderer;
         this.strategy = strategy;
-        this.fallBackContentPathes = fallBackContentPathes;
+        this.contentServer = contentServer;
     }
 
-    public PageAggregatorImpl( PortletRenderer renderer, List fallBackContentPathes )
+    public PageAggregatorImpl( PortletRenderer renderer, ContentServerAdapter contentServer)
     {
-        this(renderer, STRATEGY_SEQUENTIAL, fallBackContentPathes);
+        this(renderer, STRATEGY_SEQUENTIAL, contentServer);
     }
 
     /**
@@ -95,52 +90,7 @@
             layoutDecorator = page.getDefaultDecorator(root.getType());
         }
 
-        String defaultPortletDecorator = page.getDefaultDecorator(ContentFragment.PORTLET);
-
-        ///////////////////////////////////////////////////////////////////////////////////////////////
-        //TODO: Remove hard coding of locations and use CM + TL
-        //      DST: Im going to encapsulate this into a class, which can be accessed
-        // by
-        //           the PowerTool when aggregating content, and make sure to modify the
-        // search path
-        //           according to the current decorator. Assigned issue to JiRa JS2-24
-        List contentPathes = (List) context.getSessionAttribute(ContentFilter.SESSION_CONTENT_PATH_ATTR);
-
-        if (contentPathes == null)
-        {
-            contentPathes = new ArrayList(2);
-            context.setSessionAttribute(ContentFilter.SESSION_CONTENT_PATH_ATTR, contentPathes);
-        }
-        String mediaType = context.getCapabilityMap().getPreferredMediaType().getName();
-        if (contentPathes.size() < 1)
-        {
-            // define the lookup order
-
-            contentPathes.add(root.getType() + "/" + mediaType + "/" + layoutDecorator);
-            // Start added by jamesliao, 27-05-2005
-            contentPathes.add(ContentFragment.PORTLET + "/" + mediaType + "/" + defaultPortletDecorator);
-            // End
-            
-            Iterator defaults = fallBackContentPathes.iterator();
-            while (defaults.hasNext())
-            {
-                String path = (String) defaults.next();
-                contentPathes.add(path.replaceAll("\\{mediaType\\}", mediaType));
-            }
-
-        }
-        else
-        {
-            contentPathes.set(0, root.getType() + "/" + mediaType + "/" + layoutDecorator);
-            // Start added by jamesliao, 27-05-2005, override the previous portlet-decorator
-            contentPathes.set(1, ContentFragment.PORTLET + "/" + mediaType + "/" + defaultPortletDecorator);
-            // End
-        }
-
-        if (layoutDecorator != null)
-        {
-            addStyle(context, layoutDecorator, ContentFragment.LAYOUT);
-        }
+        contentServer.prepareContentPaths(context, page);
 
         ///////////////////////////////////////////////////////////////////////////////////////////////
         ContentDispatcher dispatcher = renderer.getDispatcher(context, (strategy == STRATEGY_PARALLEL));
@@ -193,13 +143,13 @@
             if (maxedContentFragment.getDecorator() != null)
             {
                 log.debug("decorator=" + layoutContentFragment.getDecorator());
-                addStyle(context, maxedContentFragment.getDecorator(), ContentFragment.PORTLET);
+                contentServer.addStyle(context, maxedContentFragment.getDecorator(), ContentFragment.PORTLET);
             }
             else
             {
                 log.debug("no decorator for defined for portlet fragement," + layoutContentFragment.getId()
                         + ".  So using page default, " + defaultPortletDecorator);
-                addStyle(context, defaultPortletDecorator, ContentFragment.PORTLET);
+                contentServer.addStyle(context, defaultPortletDecorator, ContentFragment.PORTLET);
             }
             try
             {
@@ -217,21 +167,6 @@
         }
     }
 
-    private void addStyle( RequestContext context, String decoratorName, String decoratorType
)
-    {
-        HeaderResourceFactory headerResourceFactory=(HeaderResourceFactory)Jetspeed.getComponentManager().getComponent(HeaderResourceFactory.class);
-        HeaderResource headerResource=headerResourceFactory.getHeaderResouce(context);
-
-        if (decoratorType.equals(ContentFragment.LAYOUT))
-        {
-            headerResource.addStyleSheet("content/css/styles.css");
-        }
-        else
-        {
-            headerResource.addStyleSheet("content/" + decoratorName + "/css/styles.css");
-        }
-    }
-
     protected void aggregateAndRender( ContentFragment f, RequestContext context, ContentPage
page )
             throws FailedToRenderFragmentException
     {
@@ -271,13 +206,13 @@
         if (f.getDecorator() != null && f.getType().equals(ContentFragment.PORTLET))
         {
             log.debug("decorator=" + f.getDecorator());
-            addStyle(context, f.getDecorator(), ContentFragment.PORTLET);
+            contentServer.addStyle(context, f.getDecorator(), ContentFragment.PORTLET);
         }
         else if (f.getDecorator() == null && f.getType().equals(ContentFragment.PORTLET))
         {
             log.debug("no decorator for defined for portlet fragement," + f.getId() + ".
 So using page default, "
                     + defaultPortletDecorator);
-            addStyle(context, defaultPortletDecorator, ContentFragment.PORTLET);
+            contentServer.addStyle(context, defaultPortletDecorator, ContentFragment.PORTLET);
         }
     }
 }

Modified: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/PortletRendererImpl.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/PortletRendererImpl.java?rev=279462&r1=279461&r2=279462&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/PortletRendererImpl.java
(original)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/PortletRendererImpl.java
Wed Sep  7 16:44:03 2005
@@ -26,7 +26,9 @@
 import org.apache.jetspeed.aggregator.FailedToRenderFragmentException;
 import org.apache.jetspeed.aggregator.PortletContent;
 import org.apache.jetspeed.aggregator.PortletRenderer;
+import org.apache.jetspeed.aggregator.RenderingJob;
 import org.apache.jetspeed.aggregator.UnknownPortletDefinitionException;
+import org.apache.jetspeed.aggregator.WorkerMonitor;
 import org.apache.jetspeed.components.portletentity.PortletEntityNotStoredException;
 import org.apache.jetspeed.container.window.FailedToRetrievePortletWindow;
 import org.apache.jetspeed.container.window.PortletWindowAccessor;
@@ -53,21 +55,22 @@
 {
     protected final static Log log = LogFactory.getLog(PortletRendererImpl.class);
 
-    private WorkerMonitor monitor;
-
+    private WorkerMonitor workMonitor;
     private PortletContainer container;
     private PortletWindowAccessor windowAccessor;
 
-    public PortletRendererImpl( PortletContainer container, PortletWindowAccessor windowAccessor
)
+    public PortletRendererImpl(PortletContainer container, 
+                               PortletWindowAccessor windowAccessor,
+                               WorkerMonitor workMonitor)
     {
         this.container = container;
         this.windowAccessor = windowAccessor;
+        this.workMonitor = workMonitor;
     }
 
     public void start()
     {
-        this.monitor = new WorkerMonitor();
-        this.monitor.init();
+        // workMonitor.start();
     }
 
     public void stop()
@@ -167,7 +170,7 @@
             servletRequest = requestContext.getRequestForWindow(portletWindow);
             servletResponse = dispatcherCtrl.getResponseForWindow(portletWindow, requestContext);
             RenderingJob rJob = buildRenderingJob(fragment, servletRequest, servletResponse,
requestContext);
-            monitor.process(rJob);            
+            workMonitor.process(rJob);            
         }
         catch (Exception e1)
         {
@@ -241,7 +244,7 @@
         
         PortletContent portletContent = dispatcher.getPortletContent(fragment);
         fragment.setPortletContent(portletContent);
-        return new RenderingJob(container, portletContent, fragment, request, response, requestContext,
portletWindow);
+        return new RenderingJobImpl(container, portletContent, fragment, request, response,
requestContext, portletWindow);
 
     }
 }

Copied: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/RenderingJobImpl.java
(from r264709, portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/RenderingJob.java)
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/RenderingJobImpl.java?p2=portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/RenderingJobImpl.java&p1=portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/RenderingJob.java&r1=264709&r2=279462&rev=279462&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/RenderingJob.java
(original)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/RenderingJobImpl.java
Wed Sep  7 16:44:03 2005
@@ -23,6 +23,7 @@
 import org.apache.commons.logging.LogFactory;
 import org.apache.jetspeed.PortalReservedParameters;
 import org.apache.jetspeed.aggregator.PortletContent;
+import org.apache.jetspeed.aggregator.RenderingJob;
 import org.apache.jetspeed.om.page.ContentFragment;
 import org.apache.jetspeed.request.RequestContext;
 import org.apache.pluto.PortletContainer;
@@ -36,10 +37,10 @@
  * @author <a href="mailto:raphael@apache.org">Rapha�l Luta</a>
  * @version $Id$
  */
-public class RenderingJob implements Runnable
+public class RenderingJobImpl implements RenderingJob
 {
     /** Commons logging */
-    protected final static Log log = LogFactory.getLog(RenderingJob.class);
+    protected final static Log log = LogFactory.getLog(RenderingJobImpl.class);
 
     /** WorkerMonitor used to flush the queue */
     private PortletWindow window = null;
@@ -52,7 +53,7 @@
 
     private PortletContent portletContent;
     
-    public RenderingJob(PortletContainer container, PortletContent portletContent, ContentFragment
fragment, HttpServletRequest request, HttpServletResponse response, RequestContext requestContext,
PortletWindow window)
+    public RenderingJobImpl(PortletContainer container, PortletContent portletContent, ContentFragment
fragment, HttpServletRequest request, HttpServletResponse response, RequestContext requestContext,
PortletWindow window)
     {
         this.container = container;
         
@@ -95,7 +96,7 @@
      *
      * 
      */
-    protected void execute()
+    public void execute()
     {
         
         try

Copied: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/WorkerImpl.java
(from r264709, portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/Worker.java)
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/WorkerImpl.java?p2=portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/WorkerImpl.java&p1=portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/Worker.java&r1=264709&r2=279462&rev=279462&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/Worker.java
(original)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/WorkerImpl.java
Wed Sep  7 16:44:03 2005
@@ -23,6 +23,9 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.jetspeed.aggregator.RenderingJob;
+import org.apache.jetspeed.aggregator.Worker;
+import org.apache.jetspeed.aggregator.WorkerMonitor;
 
 /**
  * Worker thread processes jobs and notify its WorkerMonitor when completed.
@@ -32,10 +35,10 @@
  * @author <a href="mailto:raphael@apache.org">Rapha�l Luta</a>
  * @version $Id$
  */
-public class Worker extends Thread
+public class WorkerImpl extends Thread implements Worker
 {
     /** Commons logging */
-    protected final static Log log = LogFactory.getLog(Worker.class);
+    protected final static Log log = LogFactory.getLog(WorkerImpl.class);
 
     /** Running status of this worker */
     private boolean running = true;
@@ -53,14 +56,14 @@
     /** Monitor for this Worker */
     private WorkerMonitor monitor = null;
 
-    public Worker(WorkerMonitor monitor)
+    public WorkerImpl(WorkerMonitor monitor)
     {
         super();
         this.setMonitor(monitor);
         this.setDaemon(true);
     }
 
-    public Worker(WorkerMonitor monitor, ThreadGroup tg, String name)
+    public WorkerImpl(WorkerMonitor monitor, ThreadGroup tg, String name)
     {
         super(tg, name);
         this.setMonitor(monitor);
@@ -168,7 +171,7 @@
                             {
                                 try 
                                 {
-                                    Worker.this.job.run();
+                                    WorkerImpl.this.job.run();
                                 }
                                 catch (Throwable t)
                                 {                        

Copied: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/WorkerMonitorImpl.java
(from r264709, portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/WorkerMonitor.java)
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/WorkerMonitorImpl.java?p2=portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/WorkerMonitorImpl.java&p1=portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/WorkerMonitor.java&r1=264709&r2=279462&rev=279462&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/WorkerMonitor.java
(original)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/WorkerMonitorImpl.java
Wed Sep  7 16:44:03 2005
@@ -22,6 +22,9 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.jetspeed.aggregator.RenderingJob;
+import org.apache.jetspeed.aggregator.Worker;
+import org.apache.jetspeed.aggregator.WorkerMonitor;
 import org.apache.jetspeed.util.Queue;
 import org.apache.jetspeed.util.FIFOQueue;
 
@@ -33,12 +36,21 @@
  * which is flushed periodically by a QueueMonitor.
  *
  * @author <a href="mailto:raphael@apache.org">Rapha\u00ebl Luta</a>
+ * @author <a href="mailto:taylor@apache.org">David Sean Taylor </a>
  * @version $Id$
  */
-public class WorkerMonitor
+public class WorkerMonitorImpl implements WorkerMonitor
 {
+    public WorkerMonitorImpl(int minWorkers, int maxWorkers, int spareWorkers, int maxJobsPerWorker)
+    {
+        this.minWorkers = minWorkers;
+        this.maxWorkers = maxWorkers;
+        this.spareWorkers = spareWorkers;
+        this.maxJobsPerWorker = maxJobsPerWorker;
+    }
+    
     /** Commons logging */
-    protected final static Log log = LogFactory.getLog(WorkerMonitor.class);
+    protected final static Log log = LogFactory.getLog(WorkerMonitorImpl.class);
 
     /** Static counters for identifying workers */
     private static long sCount = 0;
@@ -64,12 +76,16 @@
     /** Job queue */
     private Queue queue;
 
-    public void init()
+    public void start()
     {
         addWorkers(this.minWorkers);
         setQueue(new FIFOQueue());
     }
 
+    public void stop()
+    {        
+    }
+    
     public void setQueue(Queue queue)
     {
         this.queue = queue;
@@ -96,7 +112,7 @@
 
             for (int i = 0; i < wCount; ++i)
             {
-                Worker worker = new Worker(this, this.tg, "WORKER_" + (++sCount));
+                Worker worker = new WorkerImpl(this, this.tg, "WORKER_" + (++sCount));
                 worker.start();
                 workers.push(worker);
             }



---------------------------------------------------------------------
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